source: main/waeup.aaue/trunk/src/waeup/aaue/applicants/browser.py @ 13438

Last change on this file since 13438 was 13422, checked in by Henrik Bettermann, 9 years ago

Remove details about course admitted.

  • Property svn:keywords set to Id
File size: 7.1 KB
Line 
1## $Id: browser.py 13422 2015-11-09 17:16:43Z 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
21import os
22from zope.component import getUtility
23from waeup.kofa.interfaces import (
24    IExtFileStore, IFileStoreNameChooser)
25from zope.formlib.textwidgets import BytesDisplayWidget
26from waeup.kofa.utils.helpers import string_from_bytes, file_size
27from waeup.kofa.applicants.browser import ApplicantCheckStatusPage
28from waeup.aaue.interfaces import MessageFactory as _
29from kofacustom.nigeria.applicants.browser import (
30    NigeriaApplicantDisplayFormPage,
31    NigeriaApplicantManageFormPage,
32    NigeriaApplicantEditFormPage,
33    NigeriaPDFApplicationSlip,
34    NigeriaApplicantRegistrationPage,
35    NigeriaExportPDFPaymentSlipPage,
36    UG_OMIT_DISPLAY_FIELDS,
37    UG_OMIT_PDF_FIELDS,
38    UG_OMIT_MANAGE_FIELDS,
39    UG_OMIT_EDIT_FIELDS)
40from waeup.aaue.applicants.interfaces import (
41    ICustomApplicant,
42    ICustomUGApplicant,
43    ICustomUGApplicantEdit
44    )
45
46UG_OMIT_PDF_FIELDS = tuple([
47    element for element in UG_OMIT_PDF_FIELDS if not element == 'phone'])
48UG_OMIT_PDF_FIELDS += ('reg_number','alr_fname', 'alr_no', 'alr_date',
49    'alr_results', 'notice')
50
51FP_OMIT_FIELDS = ('hq_type', 'hq_fname', 'hq_matric_no',
52     'hq_degree', 'hq_school', 'hq_session', 'hq_disc')
53FP_OMIT_DISPLAY_FIELDS = UG_OMIT_DISPLAY_FIELDS + FP_OMIT_FIELDS
54FP_OMIT_PDF_FIELDS = UG_OMIT_PDF_FIELDS + FP_OMIT_FIELDS
55FP_OMIT_MANAGE_FIELDS = UG_OMIT_MANAGE_FIELDS + FP_OMIT_FIELDS
56FP_OMIT_EDIT_FIELDS = UG_OMIT_EDIT_FIELDS + FP_OMIT_FIELDS
57
58class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage):
59    """A display view for applicant data.
60    """
61
62    @property
63    def form_fields(self):
64        form_fields = grok.AutoFields(ICustomUGApplicant)
65        if self.target is not None and self.target.startswith('fp'):
66            for field in FP_OMIT_DISPLAY_FIELDS:
67                form_fields = form_fields.omit(field)
68        else:
69            for field in UG_OMIT_DISPLAY_FIELDS:
70                form_fields = form_fields.omit(field)
71        form_fields['perm_address'].custom_widget = BytesDisplayWidget
72        form_fields['notice'].custom_widget = BytesDisplayWidget
73        if not getattr(self.context, 'student_id'):
74            form_fields = form_fields.omit('student_id')
75        if not getattr(self.context, 'screening_score'):
76            form_fields = form_fields.omit('screening_score')
77        if not getattr(self.context, 'screening_venue'):
78            form_fields = form_fields.omit('screening_venue')
79        if not getattr(self.context, 'screening_date'):
80            form_fields = form_fields.omit('screening_date')
81        return form_fields
82
83class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
84
85    column_two_fields = ('applicant_id', 'reg_number',
86        'firstname', 'middlename', 'lastname', 'sex', 'date_of_birth')
87    two_columns_design_fields = [
88        'fst_sit_fname', 'fst_sit_no', 'fst_sit_date',
89        'fst_sit_type', 'fst_sit_results',
90        'scd_sit_fname', 'scd_sit_no', 'scd_sit_date',
91        'scd_sit_type', 'scd_sit_results']
92
93    @property
94    def note(self):
95        if self.context.sex == 'm':
96            pronoun = 'he'
97        else:
98            pronoun = 'she'
99        return '''
100The applicant has acknowledged that, if discovered at any time that %s does not possess
101any of the qualifications which %s claims %s has obtained, %s will be expelled from the
102University not be re-admitted for the same or any other programme, even if %s has
103upgraded previous and shall qualifications or possess additional qualifications.
104''' % (
105    pronoun, pronoun, pronoun, pronoun, pronoun)
106
107    @property
108    def form_fields(self):
109        form_fields = grok.AutoFields(ICustomUGApplicant)
110        if self.target is not None and self.target.startswith('fp'):
111            for field in FP_OMIT_PDF_FIELDS:
112                form_fields = form_fields.omit(field)
113        else:
114            for field in UG_OMIT_PDF_FIELDS:
115                form_fields = form_fields.omit(field)
116        if not getattr(self.context, 'student_id'):
117            form_fields = form_fields.omit('student_id')
118        if not getattr(self.context, 'screening_score'):
119            form_fields = form_fields.omit('screening_score')
120        if not getattr(self.context, 'screening_venue'):
121            form_fields = form_fields.omit('screening_venue')
122        if not getattr(self.context, 'screening_date'):
123            form_fields = form_fields.omit('screening_date')
124        return form_fields
125
126class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
127    """A full edit view for applicant data.
128    """
129
130    @property
131    def form_fields(self):
132        form_fields = grok.AutoFields(ICustomUGApplicant)
133        if self.target is not None and self.target.startswith('fp'):
134            for field in FP_OMIT_MANAGE_FIELDS:
135                form_fields = form_fields.omit(field)
136        else:
137            for field in UG_OMIT_MANAGE_FIELDS:
138                form_fields = form_fields.omit(field)
139        form_fields['student_id'].for_display = True
140        form_fields['applicant_id'].for_display = True
141        return form_fields
142
143class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
144    """An applicant-centered edit view for applicant data.
145    """
146
147    @property
148    def form_fields(self):
149        form_fields = grok.AutoFields(ICustomUGApplicantEdit)
150        if self.target is not None and self.target.startswith('fp'):
151            for field in FP_OMIT_EDIT_FIELDS:
152                form_fields = form_fields.omit(field)
153        else:
154            for field in UG_OMIT_EDIT_FIELDS:
155                form_fields = form_fields.omit(field)
156        form_fields['applicant_id'].for_display = True
157        form_fields['reg_number'].for_display = True
158        return form_fields
159
160class CustomApplicantRegistrationPage(NigeriaApplicantRegistrationPage):
161    """Captcha'd registration page for applicants.
162    """
163
164    def _redirect(self, email, password, applicant_id):
165        # Forward email and credentials to landing page.
166        self.redirect(self.url(self.context, 'registration_complete',
167            data = dict(email=email, password=password,
168            applicant_id=applicant_id)))
169        return
170
171class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage):
172
173    @property
174    def payment_slip_download_warning(self):
175        return ''
176
177class CustomApplicantCheckStatusPage(ApplicantCheckStatusPage):
178    """Captcha'd status checking page for applicants.
179    """
180    grok.template('applicantcheckstatus')
Note: See TracBrowser for help on using the repository browser.