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

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

Simplify application

  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1## $Id: browser.py 17711 2024-03-07 12:57:10Z 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', 'course_admitted',
46    'result_uploaded', 'suspended', 'special_application',)
47
48UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + (
49    'programme_type', 'course1', 'course2', 'course_admitted')
50UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS + ('phone',)
51UG_OMIT_MANAGE_FIELDS = (
52    'special_application',
53    'programme_type', 'course1', 'course2', 'course_admitted')
54UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
55    'student_id',
56    'notice',
57    'jamb_age',
58    'jamb_subjects',
59    'jamb_score',
60    'jamb_reg_number',
61    'aggregate')
62
63class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
64    """A display view for applicant data.
65    """
66
67    def _not_paid(self):
68        return self.context.state in ('initialized', 'started',)
69
70    @property
71    def form_fields(self):
72        form_fields = grok.AutoFields(ICustomUGApplicant)
73        for field in UG_OMIT_PDF_FIELDS:
74            form_fields = form_fields.omit(field)
75        form_fields['notice'].custom_widget = BytesDisplayWidget
76        if not getattr(self.context, 'student_id'):
77            form_fields = form_fields.omit('student_id')
78        return form_fields
79
80class CustomPDFApplicationSlip(PDFApplicationSlip):
81
82    def _addLoginInformation(self):
83        """ We do no longer render login information on
84        pdf application slips.
85        """
86        return
87
88    def _reduced_slip(self):
89        return getattr(self.context, 'result_uploaded', False)
90
91    @property
92    def form_fields(self):
93        form_fields = grok.AutoFields(ICustomUGApplicant)
94        for field in UG_OMIT_PDF_FIELDS:
95            form_fields = form_fields.omit(field)
96        if not getattr(self.context, 'student_id'):
97            form_fields = form_fields.omit('student_id')
98        return form_fields
99
100class CustomApplicantManageFormPage(ApplicantManageFormPage):
101    """A full edit view for applicant data.
102    """
103
104    @property
105    def form_fields(self):
106        form_fields = grok.AutoFields(ICustomUGApplicant)
107        for field in UG_OMIT_MANAGE_FIELDS:
108            form_fields = form_fields.omit(field)
109        form_fields['student_id'].for_display = True
110        form_fields['applicant_id'].for_display = True
111        return form_fields
112
113class CustomApplicantEditFormPage(ApplicantEditFormPage):
114    """An applicant-centered edit view for applicant data.
115    """
116
117    @property
118    def form_fields(self):
119        form_fields = grok.AutoFields(ICustomUGApplicantEdit)
120        for field in UG_OMIT_EDIT_FIELDS:
121            form_fields = form_fields.omit(field)
122        form_fields['applicant_id'].for_display = True
123        form_fields['reg_number'].for_display = True
124        return form_fields
125
126    def unremovable(self, ticket):
127        return True
128
Note: See TracBrowser for help on using the repository browser.