[10298] | 1 | ## $Id: browser.py 10301 2013-06-16 08:52:25Z 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 | """ |
---|
| 20 | import grok |
---|
| 21 | import os |
---|
| 22 | from zope.component import getUtility |
---|
| 23 | from waeup.kofa.interfaces import ( |
---|
| 24 | IExtFileStore, IFileStoreNameChooser) |
---|
| 25 | from zope.formlib.textwidgets import BytesDisplayWidget |
---|
| 26 | from waeup.kofa.utils.helpers import string_from_bytes, file_size |
---|
| 27 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
| 28 | from 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) |
---|
| 41 | from waeup.aaue.applicants.interfaces import ( |
---|
| 42 | ICustomApplicant, |
---|
| 43 | ICustomUGApplicant, |
---|
| 44 | ICustomPGApplicant, |
---|
| 45 | ICustomPGApplicantEdit, |
---|
| 46 | ICustomUGApplicantEdit) |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | class CustomApplicantDisplayFormPage(NigeriaApplicantDisplayFormPage): |
---|
| 50 | """A display view for applicant data. |
---|
| 51 | """ |
---|
| 52 | |
---|
| 53 | @property |
---|
| 54 | def form_fields(self): |
---|
| 55 | if self.target is not None and self.target.startswith('pg'): |
---|
| 56 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 57 | for field in PG_OMIT_DISPLAY_FIELDS: |
---|
| 58 | form_fields = form_fields.omit(field) |
---|
| 59 | else: |
---|
| 60 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 61 | for field in UG_OMIT_DISPLAY_FIELDS: |
---|
| 62 | form_fields = form_fields.omit(field) |
---|
| 63 | form_fields['perm_address'].custom_widget = BytesDisplayWidget |
---|
| 64 | form_fields['notice'].custom_widget = BytesDisplayWidget |
---|
| 65 | if not getattr(self.context, 'student_id'): |
---|
| 66 | form_fields = form_fields.omit('student_id') |
---|
| 67 | if not getattr(self.context, 'screening_score'): |
---|
| 68 | form_fields = form_fields.omit('screening_score') |
---|
| 69 | if not getattr(self.context, 'screening_venue'): |
---|
| 70 | form_fields = form_fields.omit('screening_venue') |
---|
| 71 | if not getattr(self.context, 'screening_date'): |
---|
| 72 | form_fields = form_fields.omit('screening_date') |
---|
| 73 | return form_fields |
---|
| 74 | |
---|
| 75 | class CustomPDFApplicationSlip(NigeriaPDFApplicationSlip): |
---|
| 76 | |
---|
[10301] | 77 | @property |
---|
| 78 | def note(self): |
---|
| 79 | if self.context.sex == 'm': |
---|
| 80 | pronoun = 'he' |
---|
| 81 | else: |
---|
| 82 | pronoun = 'she' |
---|
| 83 | return ''' |
---|
[10298] | 84 | |
---|
[10301] | 85 | The applicant has acknowledged that, if discovered at any time that %s does not possess |
---|
| 86 | any of the qualifications which %s claims %s has obtained, %s will be expelled from the |
---|
| 87 | University and shall not be re-admitted for the same or any other programme, even if %s |
---|
| 88 | has upgraded previous qualifications or possess additional qualifications.''' % ( |
---|
| 89 | pronoun, pronoun, pronoun, pronoun, pronoun) |
---|
[10298] | 90 | |
---|
| 91 | @property |
---|
| 92 | def form_fields(self): |
---|
| 93 | if self.target is not None and self.target.startswith('pg'): |
---|
| 94 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 95 | for field in PG_OMIT_PDF_FIELDS: |
---|
| 96 | form_fields = form_fields.omit(field) |
---|
| 97 | else: |
---|
| 98 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 99 | for field in UG_OMIT_PDF_FIELDS: |
---|
| 100 | form_fields = form_fields.omit(field) |
---|
| 101 | if not getattr(self.context, 'student_id'): |
---|
| 102 | form_fields = form_fields.omit('student_id') |
---|
| 103 | if not getattr(self.context, 'screening_score'): |
---|
| 104 | form_fields = form_fields.omit('screening_score') |
---|
| 105 | if not getattr(self.context, 'screening_venue'): |
---|
| 106 | form_fields = form_fields.omit('screening_venue') |
---|
| 107 | if not getattr(self.context, 'screening_date'): |
---|
| 108 | form_fields = form_fields.omit('screening_date') |
---|
| 109 | return form_fields |
---|
| 110 | |
---|
| 111 | class CustomApplicantManageFormPage(NigeriaApplicantManageFormPage): |
---|
| 112 | """A full edit view for applicant data. |
---|
| 113 | """ |
---|
| 114 | |
---|
| 115 | @property |
---|
| 116 | def form_fields(self): |
---|
| 117 | if self.target is not None and self.target.startswith('pg'): |
---|
| 118 | form_fields = grok.AutoFields(ICustomPGApplicant) |
---|
| 119 | for field in PG_OMIT_MANAGE_FIELDS: |
---|
| 120 | form_fields = form_fields.omit(field) |
---|
| 121 | else: |
---|
| 122 | form_fields = grok.AutoFields(ICustomUGApplicant) |
---|
| 123 | for field in UG_OMIT_MANAGE_FIELDS: |
---|
| 124 | form_fields = form_fields.omit(field) |
---|
| 125 | form_fields['student_id'].for_display = True |
---|
| 126 | form_fields['applicant_id'].for_display = True |
---|
| 127 | return form_fields |
---|
| 128 | |
---|
| 129 | class CustomApplicantEditFormPage(NigeriaApplicantEditFormPage): |
---|
| 130 | """An applicant-centered edit view for applicant data. |
---|
| 131 | """ |
---|
| 132 | |
---|
| 133 | @property |
---|
| 134 | def form_fields(self): |
---|
| 135 | if self.target is not None and self.target.startswith('pg'): |
---|
| 136 | form_fields = grok.AutoFields(ICustomPGApplicantEdit) |
---|
| 137 | for field in PG_OMIT_EDIT_FIELDS: |
---|
| 138 | form_fields = form_fields.omit(field) |
---|
| 139 | else: |
---|
| 140 | form_fields = grok.AutoFields(ICustomUGApplicantEdit) |
---|
| 141 | for field in UG_OMIT_EDIT_FIELDS: |
---|
| 142 | form_fields = form_fields.omit(field) |
---|
| 143 | form_fields['applicant_id'].for_display = True |
---|
| 144 | form_fields['reg_number'].for_display = True |
---|
| 145 | return form_fields |
---|