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

Last change on this file was 17714, checked in by Henrik Bettermann, 8 months ago

Further customizations

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