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

Last change on this file since 10322 was 10311, checked in by Henrik Bettermann, 12 years ago

Add jamb_reg_number.

Move jamb fields.

Add phone number on slip.

  • Property svn:keywords set to Id
File size: 6.0 KB
Line 
1## $Id: browser.py 10311 2013-06-17 08:34:22Z 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.aaue.interfaces import MessageFactory as _
28from kofacustom.nigeria.applicants.browser import (
29    NigeriaApplicantDisplayFormPage,
30    NigeriaApplicantManageFormPage,
31    NigeriaApplicantEditFormPage,
32    NigeriaPDFApplicationSlip,
33    UG_OMIT_DISPLAY_FIELDS,
34    UG_OMIT_PDF_FIELDS,
35    UG_OMIT_MANAGE_FIELDS,
36    UG_OMIT_EDIT_FIELDS,
37    PG_OMIT_DISPLAY_FIELDS,
38    PG_OMIT_PDF_FIELDS,
39    PG_OMIT_MANAGE_FIELDS,
40    PG_OMIT_EDIT_FIELDS)
41from waeup.aaue.applicants.interfaces import (
42    ICustomApplicant,
43    ICustomUGApplicant,
44    ICustomPGApplicant,
45    ICustomPGApplicantEdit,
46    ICustomUGApplicantEdit)
47
48UG_OMIT_PDF_FIELDS = [
49    element for element in UG_OMIT_PDF_FIELDS if not element == 'phone']
50UG_OMIT_PDF_FIELDS += ('reg_number',)
51
52class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage):
53    """A display view for applicant data.
54    """
55
56    @property
57    def form_fields(self):
58        if self.target is not None and self.target.startswith('pg'):
59            form_fields = grok.AutoFields(ICustomPGApplicant)
60            for field in PG_OMIT_DISPLAY_FIELDS:
61                form_fields = form_fields.omit(field)
62        else:
63            form_fields = grok.AutoFields(ICustomUGApplicant)
64            for field in UG_OMIT_DISPLAY_FIELDS:
65                form_fields = form_fields.omit(field)
66        form_fields['perm_address'].custom_widget = BytesDisplayWidget
67        form_fields['notice'].custom_widget = BytesDisplayWidget
68        if not getattr(self.context, 'student_id'):
69            form_fields = form_fields.omit('student_id')
70        if not getattr(self.context, 'screening_score'):
71            form_fields = form_fields.omit('screening_score')
72        if not getattr(self.context, 'screening_venue'):
73            form_fields = form_fields.omit('screening_venue')
74        if not getattr(self.context, 'screening_date'):
75            form_fields = form_fields.omit('screening_date')
76        return form_fields
77
78class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip):
79
80    column_two_fields = ('applicant_id', 'reg_number',
81        'firstname', 'middlename', 'lastname', 'sex', 'date_of_birth')
82
83    @property
84    def note(self):
85        if self.context.sex == 'm':
86            pronoun = 'he'
87        else:
88            pronoun = 'she'
89        return '''
90
91The applicant has acknowledged that, if discovered at any time that %s does not possess
92any of the qualifications which %s claims %s has obtained, %s will be expelled from the
93University and shall not be re-admitted for the same or any other programme, even if %s
94has upgraded previous qualifications or possess additional qualifications.''' % (
95    pronoun, pronoun, pronoun, pronoun, pronoun)
96
97    @property
98    def form_fields(self):
99        if self.target is not None and self.target.startswith('pg'):
100            form_fields = grok.AutoFields(ICustomPGApplicant)
101            for field in PG_OMIT_PDF_FIELDS:
102                form_fields = form_fields.omit(field)
103        else:
104            form_fields = grok.AutoFields(ICustomUGApplicant)
105            for field in UG_OMIT_PDF_FIELDS:
106                form_fields = form_fields.omit(field)
107        if not getattr(self.context, 'student_id'):
108            form_fields = form_fields.omit('student_id')
109        if not getattr(self.context, 'screening_score'):
110            form_fields = form_fields.omit('screening_score')
111        if not getattr(self.context, 'screening_venue'):
112            form_fields = form_fields.omit('screening_venue')
113        if not getattr(self.context, 'screening_date'):
114            form_fields = form_fields.omit('screening_date')
115        return form_fields
116
117class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage):
118    """A full edit view for applicant data.
119    """
120
121    @property
122    def form_fields(self):
123        if self.target is not None and self.target.startswith('pg'):
124            form_fields = grok.AutoFields(ICustomPGApplicant)
125            for field in PG_OMIT_MANAGE_FIELDS:
126                form_fields = form_fields.omit(field)
127        else:
128            form_fields = grok.AutoFields(ICustomUGApplicant)
129            for field in UG_OMIT_MANAGE_FIELDS:
130                form_fields = form_fields.omit(field)
131        form_fields['student_id'].for_display = True
132        form_fields['applicant_id'].for_display = True
133        return form_fields
134
135class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage):
136    """An applicant-centered edit view for applicant data.
137    """
138
139    @property
140    def form_fields(self):
141        if self.target is not None and self.target.startswith('pg'):
142            form_fields = grok.AutoFields(ICustomPGApplicantEdit)
143            for field in PG_OMIT_EDIT_FIELDS:
144                form_fields = form_fields.omit(field)
145        else:
146            form_fields = grok.AutoFields(ICustomUGApplicantEdit)
147            for field in UG_OMIT_EDIT_FIELDS:
148                form_fields = form_fields.omit(field)
149        form_fields['applicant_id'].for_display = True
150        form_fields['reg_number'].for_display = True
151        return form_fields
Note: See TracBrowser for help on using the repository browser.