source: main/ikobacustom.pcn/trunk/src/ikobacustom/pcn/customers/browser.py @ 14395

Last change on this file since 14395 was 13068, checked in by Henrik Bettermann, 9 years ago

Rename views.

  • Property svn:keywords set to Id
File size: 3.7 KB
RevLine 
[12493]1## $Id: browser.py 13068 2015-06-16 14:50:12Z henrik $
2##
3## Copyright (C) 2015 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18
[12600]19import grok
[12493]20from zope.component import getUtility
[12534]21from waeup.ikoba.interfaces import IIkobaUtils, IExtFileStore
[12803]22from waeup.ikoba.browser.layout import action
[12529]23from waeup.ikoba.customers.browser import (
[13068]24    PDFContractSlip, CustomerBaseEditFormPage, ContractSelectProductPage, msave)
[12493]25from ikobacustom.pcn.interfaces import MessageFactory as _
[12617]26from ikobacustom.pcn.customers.interfaces import (
27    IRPCContract, IAPPITContract, IAPPTContract)
[12493]28
[13068]29class PDFContractSlip(PDFContractSlip):
[12493]30    """Deliver pdf file including metadata.
31    """
32
33    @property
34    def label(self):
35        portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
[12529]36        return self.context.title
37
[12600]38    def _signatures(self):
39        return ()
[12529]40
[12600]41    def _sigsInFooter(self):
42        return ()
43
[13068]44class PDFRPCContractSlip(PDFContractSlip):
[12600]45    """Deliver pdf file including metadata.
46    """
47
48    grok.context(IRPCContract)
49
50    def _sigsInFooter(self):
51        return (_('Date, Signature of Witness'),
52                _('Date, Signature of Registrant'),
53                )
54
[13068]55class PDFAPPITContractSlip(PDFContractSlip):
[12611]56    """Deliver pdf file including metadata.
57    """
58
59    grok.context(IAPPITContract)
60
61    def _sigsInFooter(self):
62        return (_('Date, Signature of Internee'),
[12612]63                _('Date, Signature of Supervising Pharmacist'),
[12611]64                )
65
[13068]66class PDFAPPTContractSlip(PDFContractSlip):
[12617]67    """Deliver pdf file including metadata.
68    """
69
70    grok.context(IAPPTContract)
71
72    def _sigsInFooter(self):
73        return (_('Date, Signature of Applicant'),
74                _('Date, Signature of Supervisor'),
75                )
76
[12529]77class CustomerBaseEditFormPage(CustomerBaseEditFormPage):
78    """ View to edit customer base data
79    """
80
81    def dataNotComplete(self):
[12534]82        store = getUtility(IExtFileStore)
83        error = ''
84        if not store.getFileByContext(self.context, attr=u'birth_certificate.pdf'):
85            error += _('Birth certificate is missing. ')
86        if not store.getFileByContext(self.context, attr=u'passport.jpg'):
87            error += _('Passport picture is missing.')
88        if error:
89            return error
90        return
[12803]91
92
93class ContractSelectProductPage(ContractSelectProductPage):
94    """ Page to select a contract product
95
96    This page is for both customers and officers.
97    """
98
99    @action(_('Save and proceed'), style='primary')
100    def save(self, **data):
101        msave(self, **data)
102        self.context.contract_year = self.context.product_object.contract_year
103        self.context.title = self.context.product_object.contract_autotitle
104        self.context.tc_dict = self.context.product_object.tc_dict
105        self.context.valid_from = self.context.product_object.valid_from
106        self.context.valid_to = self.context.product_object.valid_to
107        isCustomer = getattr(
108            self.request.principal, 'user_type', None) == 'customer'
109        if isCustomer:
110            self.redirect(self.url(self.context, 'edit'))
111        else:
112            self.redirect(self.url(self.context, 'manage'))
113        return
Note: See TracBrowser for help on using the repository browser.