source: main/kofacustom.udss/trunk/src/kofacustom/udss/applicants/browser.py @ 17712

Last change on this file since 17712 was 17712, checked in by Henrik Bettermann, 7 months ago

Customize application form

  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1## $Id: browser.py 17712 2024-03-08 11:04:44Z henrik $
2##
3## Copyright (C) 2011 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"""UI components for basic applicants and related components.
19"""
20import grok
21from zope.formlib.textwidgets import BytesDisplayWidget
22from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
23from waeup.kofa.applicants.browser import (
24    ApplicantRegistrationPage, ApplicantsContainerPage)
25from waeup.kofa.applicants.browser import (
26    ApplicantDisplayFormPage,
27    ApplicantManageFormPage,
28    ApplicantEditFormPage,
29    ApplicantRegistrationPage,
30    OnlinePaymentDisplayFormPage,
31    OnlinePaymentBreadcrumb,
32    ExportPDFPaymentSlipPage,
33    )
34from waeup.kofa.applicants.pdf import PDFApplicationSlip
35
36from kofacustom.udss.applicants.interfaces import (
37    ICustomUGApplicant,
38    ICustomApplicant,
39    ICustomUGApplicantEdit,
40    ICustomApplicantOnlinePayment,
41    )
42
43from kofacustom.udss.interfaces import MessageFactory as _
44
45OMIT_DISPLAY_FIELDS = ('locked', 'suspended',)
46
47UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ()
48UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS
49UG_OMIT_MANAGE_FIELDS = ()
50UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
51    'student_id',
52    'notice')
53
54class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
55    """A display view for applicant data.
56    """
57
58    def _not_paid(self):
59        return self.context.state in ('initialized', 'started',)
60
61    @property
62    def form_fields(self):
63        form_fields = grok.AutoFields(ICustomUGApplicant)
64        for field in UG_OMIT_PDF_FIELDS:
65            form_fields = form_fields.omit(field)
66        form_fields['notice'].custom_widget = BytesDisplayWidget
67        if not getattr(self.context, 'student_id'):
68            form_fields = form_fields.omit('student_id')
69        return form_fields
70
71class CustomPDFApplicationSlip(PDFApplicationSlip):
72
73    def _addLoginInformation(self):
74        """ We do no longer render login information on
75        pdf application slips.
76        """
77        return
78
79    def _reduced_slip(self):
80        return False
81
82    @property
83    def form_fields(self):
84        form_fields = grok.AutoFields(ICustomUGApplicant)
85        for field in UG_OMIT_PDF_FIELDS:
86            form_fields = form_fields.omit(field)
87        if not getattr(self.context, 'student_id'):
88            form_fields = form_fields.omit('student_id')
89        return form_fields
90
91class CustomApplicantManageFormPage(ApplicantManageFormPage):
92    """A full edit view for applicant data.
93    """
94
95    @property
96    def form_fields(self):
97        form_fields = grok.AutoFields(ICustomUGApplicant)
98        for field in UG_OMIT_MANAGE_FIELDS:
99            form_fields = form_fields.omit(field)
100        form_fields['student_id'].for_display = True
101        form_fields['applicant_id'].for_display = True
102        return form_fields
103
104class CustomApplicantEditFormPage(ApplicantEditFormPage):
105    """An applicant-centered edit view for applicant data.
106    """
107
108    @property
109    def form_fields(self):
110        form_fields = grok.AutoFields(ICustomUGApplicantEdit)
111        for field in UG_OMIT_EDIT_FIELDS:
112            form_fields = form_fields.omit(field)
113        form_fields['applicant_id'].for_display = True
114        form_fields['reg_number'].for_display = True
115        return form_fields
116
117    def unremovable(self, ticket):
118        return True
119
Note: See TracBrowser for help on using the repository browser.