[10765] | 1 | ## $Id: interfaces.py 16306 2020-11-10 07:20:03Z henrik $ |
---|
| 2 | ## |
---|
| 3 | ## Copyright (C) 2012 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 | |
---|
| 19 | from zope import schema |
---|
[16249] | 20 | from zope.interface import Attribute, invariant, Invalid |
---|
[13740] | 21 | from waeup.kofa.students.vocabularies import StudyLevelSource |
---|
[16249] | 22 | from waeup.kofa.interfaces import validate_email, SimpleKofaVocabulary |
---|
| 23 | from waeup.kofa.students.interfaces import IStudentPersonal |
---|
| 24 | from waeup.kofa.schema import FormattedDate, PhoneNumber |
---|
[10765] | 25 | from kofacustom.nigeria.students.interfaces import ( |
---|
| 26 | INigeriaStudentBase, INigeriaUGStudentClearance, INigeriaPGStudentClearance, |
---|
| 27 | INigeriaStudentPersonal, INigeriaStudentStudyLevel, |
---|
| 28 | INigeriaStudentStudyCourse, INigeriaCourseTicket, |
---|
| 29 | INigeriaStudentUpdateByRegNo, INigeriaStudentUpdateByMatricNo, |
---|
| 30 | ) |
---|
[15563] | 31 | from kofacustom.iuokada.payments.interfaces import ICustomOnlinePayment |
---|
[16273] | 32 | from kofacustom.iuokada.applicants.interfaces import sponsors_vocab |
---|
[15563] | 33 | from kofacustom.iuokada.interfaces import MessageFactory as _ |
---|
[10765] | 34 | |
---|
| 35 | class ICustomStudentBase(INigeriaStudentBase): |
---|
| 36 | """Representation of student base data. |
---|
| 37 | |
---|
| 38 | """ |
---|
| 39 | |
---|
[16272] | 40 | email2 = schema.ASCIILine( |
---|
| 41 | title = _(u'Second Email'), |
---|
| 42 | required = False, |
---|
| 43 | constraint=validate_email, |
---|
| 44 | ) |
---|
[15704] | 45 | |
---|
[15859] | 46 | library = schema.Bool( |
---|
| 47 | title = _(u'Library Id Card'), |
---|
| 48 | default = False, |
---|
| 49 | required = False, |
---|
| 50 | ) |
---|
[16273] | 51 | sponsor = schema.Choice( |
---|
| 52 | title = _(u'Sponsor'), |
---|
| 53 | vocabulary = sponsors_vocab, |
---|
| 54 | required = False, |
---|
| 55 | ) |
---|
[15859] | 56 | |
---|
[16272] | 57 | ICustomStudentBase['email2'].order = ICustomStudentBase[ |
---|
| 58 | 'phone'].order |
---|
[15704] | 59 | ICustomStudentBase['phone'].order = ICustomStudentBase[ |
---|
| 60 | 'email'].order |
---|
| 61 | |
---|
[16249] | 62 | class ICustomStudentPersonal(IStudentPersonal): |
---|
[16252] | 63 | """Student personal/bio data. |
---|
[10765] | 64 | |
---|
| 65 | """ |
---|
| 66 | |
---|
[16249] | 67 | is_foreigner = Attribute('True if student is non-Nigerian') |
---|
| 68 | |
---|
[16252] | 69 | # Duplicated fields from the ICustomStudentBase |
---|
| 70 | |
---|
| 71 | email = schema.ASCIILine( |
---|
| 72 | title = _(u'Email'), |
---|
| 73 | required = False, |
---|
| 74 | constraint=validate_email, |
---|
| 75 | ) |
---|
| 76 | |
---|
[16272] | 77 | email2 = schema.ASCIILine( |
---|
| 78 | title = _(u'Second Email'), |
---|
| 79 | required = False, |
---|
| 80 | constraint=validate_email, |
---|
| 81 | ) |
---|
[16252] | 82 | |
---|
| 83 | phone = PhoneNumber( |
---|
| 84 | title = _(u'Phone'), |
---|
| 85 | required = False, |
---|
| 86 | ) |
---|
| 87 | |
---|
| 88 | parents_email = schema.ASCIILine( |
---|
| 89 | title = _(u"Parents' Email"), |
---|
| 90 | required = False, |
---|
| 91 | constraint=validate_email, |
---|
| 92 | ) |
---|
| 93 | |
---|
[16306] | 94 | sponsor = schema.Choice( |
---|
| 95 | title = _(u'Sponsor'), |
---|
| 96 | vocabulary = sponsors_vocab, |
---|
| 97 | required = False, |
---|
| 98 | readonly = True, |
---|
| 99 | ) |
---|
| 100 | |
---|
[16252] | 101 | # New fields |
---|
| 102 | |
---|
[16249] | 103 | perm_address = schema.Text( |
---|
| 104 | title = _(u'Home Address'), |
---|
| 105 | required = False, |
---|
| 106 | ) |
---|
| 107 | |
---|
| 108 | postal_address = schema.Text( |
---|
| 109 | title = _(u'Postal Address'), |
---|
| 110 | required = False, |
---|
| 111 | ) |
---|
| 112 | |
---|
| 113 | hostel_address = schema.Text( |
---|
| 114 | title = _(u'Hostel Address'), |
---|
| 115 | required = False, |
---|
| 116 | ) |
---|
| 117 | |
---|
| 118 | father_address = schema.Text( |
---|
| 119 | title = _(u'Father\'s Address'), |
---|
| 120 | required = False, |
---|
| 121 | ) |
---|
| 122 | |
---|
| 123 | mother_address = schema.Text( |
---|
| 124 | title = _(u'Mother\'s Address'), |
---|
| 125 | required = False, |
---|
| 126 | ) |
---|
| 127 | |
---|
| 128 | guardian_address = schema.Text( |
---|
| 129 | title = _(u'Guardian/Sponsor\'s Address'), |
---|
| 130 | required = False, |
---|
| 131 | ) |
---|
| 132 | |
---|
| 133 | father_phone = PhoneNumber( |
---|
| 134 | title = _(u'Father\'s Mobile Phone Number'), |
---|
| 135 | description = u'', |
---|
| 136 | required = False, |
---|
| 137 | readonly = False, |
---|
| 138 | ) |
---|
| 139 | |
---|
| 140 | mother_phone = PhoneNumber( |
---|
| 141 | title = _(u'Mother\'s Mobile Phone Number'), |
---|
| 142 | description = u'', |
---|
| 143 | required = False, |
---|
| 144 | readonly = False, |
---|
| 145 | ) |
---|
| 146 | |
---|
| 147 | guardian_phone = PhoneNumber( |
---|
| 148 | title = _(u'Guardian\'s Mobile Phone Number'), |
---|
| 149 | description = u'', |
---|
| 150 | required = False, |
---|
| 151 | readonly = False, |
---|
| 152 | ) |
---|
| 153 | |
---|
| 154 | marit_stat = schema.Choice( |
---|
| 155 | title = u'Marital Status', |
---|
| 156 | default = 'unmarried', |
---|
| 157 | required = False, |
---|
| 158 | vocabulary = SimpleKofaVocabulary( |
---|
| 159 | (_('Unmarried'), 'unmarried'), |
---|
| 160 | (_('Married'), 'married'),) |
---|
| 161 | ) |
---|
| 162 | |
---|
| 163 | religion = schema.Choice( |
---|
| 164 | title = u'Religion', |
---|
| 165 | default = 'no_say', |
---|
| 166 | required = False, |
---|
| 167 | vocabulary = SimpleKofaVocabulary( |
---|
| 168 | (_('Muslim'), 'muslim'), |
---|
| 169 | (_('Christian'), 'christian'), |
---|
| 170 | (_('Others'), 'others'), |
---|
| 171 | (_('Prefer not to say'), 'no_say'),) |
---|
| 172 | ) |
---|
| 173 | |
---|
| 174 | disabled = schema.Bool( |
---|
| 175 | title = u'Disabled', |
---|
| 176 | default = False, |
---|
| 177 | required = False, |
---|
| 178 | ) |
---|
| 179 | |
---|
| 180 | class ICustomStudentPersonalEdit(ICustomStudentPersonal): |
---|
| 181 | """Interface for editing personal data by students. |
---|
| 182 | |
---|
| 183 | Here we can repeat the fields from IStudentPersonal and set the |
---|
| 184 | `required` if necessary. |
---|
| 185 | """ |
---|
| 186 | |
---|
[10765] | 187 | class ICustomUGStudentClearance(INigeriaUGStudentClearance): |
---|
| 188 | """Representation of ug student clearance data. |
---|
| 189 | |
---|
| 190 | """ |
---|
| 191 | |
---|
| 192 | class ICustomPGStudentClearance(INigeriaPGStudentClearance): |
---|
| 193 | """Representation of pg student clearance data. |
---|
| 194 | |
---|
| 195 | """ |
---|
| 196 | |
---|
| 197 | |
---|
| 198 | class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance, |
---|
[16249] | 199 | ICustomPGStudentClearance, ICustomStudentPersonal): |
---|
[10765] | 200 | """Representation of a student. |
---|
| 201 | |
---|
| 202 | """ |
---|
| 203 | |
---|
| 204 | class ICustomStudentStudyCourse(INigeriaStudentStudyCourse): |
---|
| 205 | """A container for student study levels. |
---|
| 206 | |
---|
| 207 | """ |
---|
| 208 | |
---|
| 209 | class ICustomStudentStudyLevel(INigeriaStudentStudyLevel): |
---|
| 210 | """A container for course tickets. |
---|
| 211 | |
---|
| 212 | """ |
---|
| 213 | |
---|
| 214 | class ICustomStudentOnlinePayment(ICustomOnlinePayment): |
---|
| 215 | """A student payment via payment gateways. |
---|
| 216 | |
---|
| 217 | This Interface does not inherit from IStudentOnlinePayment. |
---|
| 218 | Thus all fields from IStudentOnlinePayment have to be repeated here. |
---|
| 219 | """ |
---|
| 220 | |
---|
| 221 | p_current = schema.Bool( |
---|
| 222 | title = _(u'Current Session Payment'), |
---|
| 223 | default = True, |
---|
| 224 | required = False, |
---|
| 225 | ) |
---|
| 226 | |
---|
[13740] | 227 | p_level = schema.Choice( |
---|
[10765] | 228 | title = _(u'Payment Level'), |
---|
[13740] | 229 | source = StudyLevelSource(), |
---|
[10765] | 230 | required = False, |
---|
| 231 | ) |
---|
| 232 | |
---|
| 233 | ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[ |
---|
| 234 | 'p_session'].order |
---|
[16233] | 235 | ICustomStudentOnlinePayment['provider_amt'].order = ICustomStudentOnlinePayment[ |
---|
| 236 | 'net_amt'].order |
---|
[10765] | 237 | |
---|
| 238 | class ICustomCourseTicket(INigeriaCourseTicket): |
---|
| 239 | """A course ticket. |
---|
| 240 | |
---|
| 241 | """ |
---|
| 242 | |
---|
| 243 | class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo): |
---|
| 244 | """Representation of a student. Skip regular reg_number validation. |
---|
| 245 | |
---|
| 246 | """ |
---|
| 247 | |
---|
| 248 | class ICustomStudentUpdateByMatricNo(INigeriaStudentUpdateByMatricNo): |
---|
| 249 | """Representation of a student. Skip regular matric_number validation. |
---|
| 250 | |
---|
| 251 | """ |
---|