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, 8 months ago

Customize application form

  • Property svn:keywords set to Id
File size: 3.9 KB
RevLine 
[16717]1## $Id: browser.py 17712 2024-03-08 11:04:44Z henrik $
[15614]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
[17711]21from zope.formlib.textwidgets import BytesDisplayWidget
22from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
[15614]23from waeup.kofa.applicants.browser import (
24    ApplicantRegistrationPage, ApplicantsContainerPage)
[17711]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
[15614]35
[17689]36from kofacustom.udss.applicants.interfaces import (
[17711]37    ICustomUGApplicant,
38    ICustomApplicant,
39    ICustomUGApplicantEdit,
[16718]40    ICustomApplicantOnlinePayment,
41    )
42
[17689]43from kofacustom.udss.interfaces import MessageFactory as _
[15614]44
[17712]45OMIT_DISPLAY_FIELDS = ('locked', 'suspended',)
[17711]46
[17712]47UG_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + ()
48UG_OMIT_PDF_FIELDS = UG_OMIT_DISPLAY_FIELDS
49UG_OMIT_MANAGE_FIELDS = ()
[17711]50UG_OMIT_EDIT_FIELDS = UG_OMIT_MANAGE_FIELDS + OMIT_DISPLAY_FIELDS + (
51    'student_id',
[17712]52    'notice')
[17711]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):
[17712]80        return False
[17711]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):
[16718]105    """An applicant-centered edit view for applicant data.
106    """
107
[17711]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
[16718]117    def unremovable(self, ticket):
118        return True
119
Note: See TracBrowser for help on using the repository browser.