source: main/kofacustom.lpng/trunk/src/kofacustom/lpng/applicants/browser.py @ 17015

Last change on this file since 17015 was 17013, checked in by Henrik Bettermann, 2 years ago

Add ICustomApplicantEdit interface.

  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1## $Id: browser.py 17013 2022-07-08 11:14:06Z 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.applicants.pdf import PDFApplicationSlip
23from waeup.kofa.applicants.browser import (
24    ApplicantRegistrationPage, ApplicantsContainerPage,
25    ApplicantDisplayFormPage,
26    ApplicantManageFormPage,
27    ApplicantEditFormPage)
28
29from kofacustom.lpng.applicants.interfaces import (
30    ICustomApplicant,
31    ICustomApplicantOnlinePayment,
32    ICustomApplicantEdit,
33    )
34
35from kofacustom.lpng.interfaces import MessageFactory as _
36
37       
38class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
39    """A display view for applicant data.
40    """
41
42    @property
43    def form_fields(self):
44        form_fields = grok.AutoFields(ICustomApplicant)
45        form_fields['perm_address'].custom_widget = BytesDisplayWidget
46        form_fields['notice'].custom_widget = BytesDisplayWidget
47        if not getattr(self.context, 'student_id'):
48            form_fields = form_fields.omit('student_id')
49        return form_fields
50
51class CustomPDFApplicationSlip(PDFApplicationSlip):
52
53    @property
54    def form_fields(self):
55        form_fields = grok.AutoFields(ICustomApplicant)
56        if not getattr(self.context, 'student_id'):
57            form_fields = form_fields.omit('student_id')
58        return form_fields
59
60class CustomApplicantManageFormPage(ApplicantManageFormPage):
61    """A full edit view for applicant data.
62    """
63
64    @property
65    def form_fields(self):
66        form_fields = grok.AutoFields(ICustomApplicant)
67        if not getattr(self.context, 'student_id'):
68            form_fields = form_fields.omit('student_id')
69        form_fields['applicant_id'].for_display = True
70        return form_fields
71
72class CustomApplicantEditFormPage(ApplicantEditFormPage):
73    """An applicant-centered edit view for applicant data.
74    """
75
76    def unremovable(self, ticket):
77        return True
78
79    @property
80    def form_fields(self):
81        form_fields = grok.AutoFields(ICustomApplicantEdit)
82        form_fields = form_fields.omit('notice')
83        if not getattr(self.context, 'student_id'):
84            form_fields = form_fields.omit('student_id')
85        form_fields['applicant_id'].for_display = True
86        form_fields['reg_number'].for_display = True
87        return form_fields
88
Note: See TracBrowser for help on using the repository browser.