[7853] | 1 | ## $Id: interfaces.py 8931 2012-07-07 10:37:30Z 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 | """Customized interfaces of the university application package. |
---|
| 19 | """ |
---|
| 20 | |
---|
[8012] | 21 | from zope import schema |
---|
[8051] | 22 | from waeup.kofa.applicants.interfaces import ( |
---|
[8053] | 23 | IApplicantBaseData, |
---|
[8051] | 24 | AppCatCertificateSource, CertificateSource) |
---|
| 25 | from waeup.kofa.schoolgrades import ResultEntryField |
---|
[8532] | 26 | from waeup.kofa.interfaces import ( |
---|
| 27 | SimpleKofaVocabulary, academic_sessions_vocab, validate_email) |
---|
| 28 | from waeup.kofa.schema import FormattedDate, TextLineChoice |
---|
| 29 | from waeup.kofa.students.vocabularies import nats_vocab, GenderSource |
---|
| 30 | from waeup.kofa.applicants.interfaces import contextual_reg_num_source |
---|
[8931] | 31 | from kofacustom.nigeria.applicants.interfaces import ( |
---|
| 32 | LGASource, high_qual, high_grade, exam_types, |
---|
| 33 | INigeriaUGApplicant, INigeriaPGApplicant, |
---|
| 34 | INigeriaApplicantOnlinePayment, |
---|
| 35 | UG_OMIT_DISPLAY_FIELDS, |
---|
| 36 | UG_OMIT_PDF_FIELDS, |
---|
| 37 | UG_OMIT_MANAGE_FIELDS, |
---|
| 38 | UG_OMIT_EDIT_FIELDS, |
---|
| 39 | PUTME_OMIT_EDIT_FIELDS, |
---|
| 40 | UG_OMIT_RESULT_SLIP_FIELDS, |
---|
| 41 | PG_OMIT_DISPLAY_FIELDS, |
---|
| 42 | PG_OMIT_PDF_FIELDS, |
---|
| 43 | PG_OMIT_MANAGE_FIELDS, |
---|
| 44 | PG_OMIT_EDIT_FIELDS, |
---|
| 45 | ) |
---|
[8444] | 46 | from waeup.aaue.interfaces import MessageFactory as _ |
---|
| 47 | from waeup.aaue.payments.interfaces import ICustomOnlinePayment |
---|
[7853] | 48 | |
---|
[8931] | 49 | class ICustomUGApplicant(INigeriaUGApplicant): |
---|
[8012] | 50 | """An undergraduate applicant. |
---|
| 51 | |
---|
[8521] | 52 | This interface defines the least common multiple of all fields |
---|
| 53 | in ug application forms. In customized forms, fields can be excluded by |
---|
| 54 | adding them to the UG_OMIT* tuples. |
---|
[8012] | 55 | """ |
---|
| 56 | |
---|
[8931] | 57 | class ICustomPGApplicant(INigeriaPGApplicant): |
---|
[7853] | 58 | """A postgraduate applicant. |
---|
| 59 | |
---|
[8521] | 60 | This interface defines the least common multiple of all fields |
---|
| 61 | in pg application forms. In customized forms, fields can be excluded by |
---|
| 62 | adding them to the PG_OMIT* tuples. |
---|
[7866] | 63 | """ |
---|
| 64 | |
---|
[8931] | 65 | class ICustomApplicant(ICustomUGApplicant, ICustomPGApplicant): |
---|
[8012] | 66 | """An interface for both types of applicants. |
---|
| 67 | |
---|
[8931] | 68 | Attention: The ICustomPGApplicant field seetings will be overwritten |
---|
| 69 | by ICustomPGApplicant field settings. If a field is defined |
---|
[8728] | 70 | in both interfaces zope.schema validates only against the |
---|
[8931] | 71 | constraints in ICustomUGApplicant. This does not affect the forms |
---|
| 72 | since they are build on either ICustomUGApplicant or ICustomPGApplicant. |
---|
[8012] | 73 | """ |
---|
| 74 | |
---|
[8746] | 75 | def writeLogMessage(view, comment): |
---|
[8053] | 76 | """Adds an INFO message to the log file |
---|
| 77 | """ |
---|
| 78 | |
---|
| 79 | def createStudent(): |
---|
| 80 | """Create a student object from applicatnt data |
---|
| 81 | and copy applicant object. |
---|
| 82 | """ |
---|
| 83 | |
---|
[8931] | 84 | class ICustomUGApplicantEdit(ICustomUGApplicant): |
---|
[8728] | 85 | """An undergraduate applicant interface for edit forms. |
---|
[8012] | 86 | |
---|
| 87 | Here we can repeat the fields from base data and set the |
---|
| 88 | `required` and `readonly` attributes to True to further restrict |
---|
| 89 | the data access. Or we can allow only certain certificates to be |
---|
| 90 | selected by choosing the appropriate source. |
---|
| 91 | |
---|
| 92 | We cannot omit fields here. This has to be done in the |
---|
| 93 | respective form page. |
---|
| 94 | """ |
---|
| 95 | |
---|
[8648] | 96 | email = schema.ASCIILine( |
---|
| 97 | title = _(u'Email Address'), |
---|
| 98 | required = True, |
---|
| 99 | constraint=validate_email, |
---|
| 100 | ) |
---|
| 101 | date_of_birth = FormattedDate( |
---|
| 102 | title = _(u'Date of Birth'), |
---|
| 103 | required = True, |
---|
| 104 | show_year = True, |
---|
| 105 | ) |
---|
| 106 | |
---|
[8931] | 107 | ICustomUGApplicantEdit[ |
---|
| 108 | 'date_of_birth'].order = ICustomUGApplicant['date_of_birth'].order |
---|
| 109 | ICustomUGApplicantEdit[ |
---|
| 110 | 'email'].order = ICustomUGApplicant['email'].order |
---|
[8648] | 111 | |
---|
[8931] | 112 | class ICustomPGApplicantEdit(ICustomPGApplicant): |
---|
[7866] | 113 | """A postgraduate applicant interface for editing. |
---|
| 114 | |
---|
| 115 | Here we can repeat the fields from base data and set the |
---|
| 116 | `required` and `readonly` attributes to True to further restrict |
---|
| 117 | the data access. Or we can allow only certain certificates to be |
---|
| 118 | selected by choosing the appropriate source. |
---|
| 119 | |
---|
| 120 | We cannot omit fields here. This has to be done in the |
---|
| 121 | respective form page. |
---|
[8017] | 122 | """ |
---|
[8455] | 123 | |
---|
[8648] | 124 | email = schema.ASCIILine( |
---|
| 125 | title = _(u'Email Address'), |
---|
| 126 | required = True, |
---|
| 127 | constraint=validate_email, |
---|
| 128 | ) |
---|
| 129 | date_of_birth = FormattedDate( |
---|
| 130 | title = _(u'Date of Birth'), |
---|
| 131 | required = True, |
---|
| 132 | show_year = True, |
---|
| 133 | ) |
---|
| 134 | |
---|
[8931] | 135 | ICustomPGApplicantEdit[ |
---|
| 136 | 'date_of_birth'].order = ICustomPGApplicant['date_of_birth'].order |
---|
| 137 | ICustomPGApplicantEdit[ |
---|
| 138 | 'email'].order = ICustomPGApplicant['email'].order |
---|
[8648] | 139 | |
---|
[8931] | 140 | class ICustomApplicantOnlinePayment(INigeriaApplicantOnlinePayment): |
---|
[8247] | 141 | """An applicant payment via payment gateways. |
---|
| 142 | |
---|
| 143 | """ |
---|
[8532] | 144 | |
---|
[8931] | 145 | class IPUTMEApplicantEdit(ICustomUGApplicant): |
---|
[8532] | 146 | """An undergraduate applicant interface for editing. |
---|
| 147 | |
---|
| 148 | Here we can repeat the fields from base data and set the |
---|
| 149 | `required` and `readonly` attributes to True to further restrict |
---|
| 150 | the data access. Or we can allow only certain certificates to be |
---|
| 151 | selected by choosing the appropriate source. |
---|
| 152 | |
---|
| 153 | We cannot omit fields here. This has to be done in the |
---|
| 154 | respective form page. |
---|
| 155 | """ |
---|
| 156 | email = schema.ASCIILine( |
---|
| 157 | title = _(u'Email Address'), |
---|
| 158 | required = True, |
---|
| 159 | constraint=validate_email, |
---|
| 160 | ) |
---|
[8567] | 161 | date_of_birth = FormattedDate( |
---|
| 162 | title = _(u'Date of Birth'), |
---|
| 163 | required = True, |
---|
| 164 | show_year = True, |
---|
| 165 | ) |
---|
[8532] | 166 | |
---|
| 167 | IPUTMEApplicantEdit[ |
---|
[8931] | 168 | 'date_of_birth'].order = ICustomUGApplicant['date_of_birth'].order |
---|
[8567] | 169 | IPUTMEApplicantEdit[ |
---|
[8931] | 170 | 'email'].order = ICustomUGApplicant['email'].order |
---|
[8583] | 171 | |
---|
| 172 | class ICustomApplicantUpdateByRegNo(ICustomApplicant): |
---|
| 173 | """Representation of an applicant. |
---|
| 174 | |
---|
| 175 | Skip regular reg_number validation if reg_number is used for finding |
---|
| 176 | the applicant object. |
---|
| 177 | """ |
---|
| 178 | reg_number = schema.TextLine( |
---|
| 179 | title = u'Registration Number', |
---|
| 180 | required = False, |
---|
| 181 | ) |
---|