[6621] | 1 | ## |
---|
| 2 | ## interfaces.py |
---|
[6788] | 3 | from zope.interface import Attribute, invariant |
---|
[6756] | 4 | from zope.interface.exceptions import Invalid |
---|
[6621] | 5 | from zope import schema |
---|
[6915] | 6 | from waeup.sirp.interfaces import IWAeUPObject, academic_sessions_vocab |
---|
[6788] | 7 | from waeup.sirp.schema import TextLineChoice |
---|
[6874] | 8 | from waeup.sirp.university.vocabularies import CourseSource, study_modes |
---|
[6648] | 9 | from waeup.sirp.students.vocabularies import ( |
---|
[6788] | 10 | CertificateSource, academic_sessions_vocab, verdicts, StudyLevelSource, |
---|
| 11 | contextual_reg_num_source, contextual_mat_num_source, |
---|
[6648] | 12 | ) |
---|
[6877] | 13 | from waeup.sirp.payments.interfaces import IPaymentsContainer, IOnlinePayment |
---|
[6621] | 14 | |
---|
[6692] | 15 | class IStudentsContainer(IWAeUPObject): |
---|
| 16 | """An students container contains university students. |
---|
| 17 | |
---|
| 18 | """ |
---|
| 19 | |
---|
| 20 | def addStudent(student): |
---|
| 21 | """Add an IStudent object and subcontainers. |
---|
| 22 | |
---|
| 23 | """ |
---|
| 24 | |
---|
| 25 | def archive(id=None): |
---|
| 26 | """Create on-dist archive of students. |
---|
| 27 | |
---|
| 28 | If id is `None`, all students are archived. |
---|
| 29 | |
---|
| 30 | If id contains a single id string, only the respective |
---|
| 31 | students are archived. |
---|
| 32 | |
---|
| 33 | If id contains a list of id strings all of the respective |
---|
| 34 | students types are saved to disk. |
---|
| 35 | """ |
---|
| 36 | |
---|
| 37 | def clear(id=None, archive=True): |
---|
| 38 | """Remove students of type given by 'id'. |
---|
| 39 | |
---|
| 40 | Optionally archive the students. |
---|
| 41 | |
---|
| 42 | If id is `None`, all students are archived. |
---|
| 43 | |
---|
| 44 | If id contains a single id string, only the respective |
---|
| 45 | students are archived. |
---|
| 46 | |
---|
| 47 | If id contains a list of id strings all of the respective |
---|
| 48 | student types are saved to disk. |
---|
| 49 | |
---|
| 50 | If `archive` is ``False`` none of the archive-handling is done |
---|
| 51 | and respective students are simply removed from the |
---|
| 52 | database. |
---|
| 53 | """ |
---|
| 54 | |
---|
[6642] | 55 | class IStudentNavigation(IWAeUPObject): |
---|
| 56 | """Interface needed for student navigation. |
---|
| 57 | """ |
---|
| 58 | |
---|
| 59 | def getStudent(): |
---|
| 60 | """Return student object. |
---|
| 61 | """ |
---|
| 62 | |
---|
[6756] | 63 | class IStudentPasswordSetting(IWAeUPObject): |
---|
| 64 | """Data needed for password setting. |
---|
| 65 | """ |
---|
| 66 | name = schema.TextLine( |
---|
| 67 | title = u'Full Name', |
---|
| 68 | default = u'Nobody', |
---|
| 69 | required = True, |
---|
[6764] | 70 | readonly = True |
---|
[6756] | 71 | ) |
---|
| 72 | |
---|
| 73 | password = schema.Password( |
---|
| 74 | title = u'New password', |
---|
| 75 | required = False, |
---|
| 76 | ) |
---|
| 77 | |
---|
| 78 | password_repeat = schema.Password( |
---|
| 79 | title = u'Retype new password', |
---|
| 80 | required = False, |
---|
| 81 | ) |
---|
| 82 | |
---|
| 83 | @invariant |
---|
| 84 | def passwords_match(obj): |
---|
| 85 | if obj.password == obj.password_repeat: |
---|
| 86 | return |
---|
| 87 | raise Invalid('passwords do not match') |
---|
| 88 | |
---|
[6631] | 89 | class IStudentBase(IWAeUPObject): |
---|
| 90 | """Representation of student base data. |
---|
[6621] | 91 | """ |
---|
[6637] | 92 | history = Attribute('Object history, a list of messages.') |
---|
| 93 | state = Attribute('Returns the registration state of a student') |
---|
[6699] | 94 | password = Attribute('Encrypted password of a student') |
---|
[6814] | 95 | certificate = Attribute('The certificate of any chosen study course') |
---|
[6637] | 96 | |
---|
| 97 | def loggerInfo(ob_class, comment): |
---|
| 98 | """Adds an INFO message to the log file |
---|
| 99 | """ |
---|
| 100 | |
---|
[6665] | 101 | student_id = schema.TextLine( |
---|
| 102 | title = u'Student ID', |
---|
[6849] | 103 | required = False, |
---|
[6665] | 104 | ) |
---|
| 105 | |
---|
[6818] | 106 | fullname = schema.TextLine( |
---|
[6631] | 107 | title = u'Full Name', |
---|
[6818] | 108 | default = None, |
---|
[6621] | 109 | required = True, |
---|
| 110 | ) |
---|
| 111 | |
---|
[6788] | 112 | reg_number = TextLineChoice( |
---|
[6696] | 113 | title = u'Registration Number', |
---|
[6818] | 114 | default = None, |
---|
[6696] | 115 | required = True, |
---|
| 116 | readonly = False, |
---|
[6788] | 117 | source = contextual_reg_num_source, |
---|
[6696] | 118 | ) |
---|
| 119 | |
---|
[6788] | 120 | matric_number = TextLineChoice( |
---|
[6750] | 121 | title = u'Matriculation Number', |
---|
[6788] | 122 | #default = u'', |
---|
[6750] | 123 | required = False, |
---|
| 124 | readonly = False, |
---|
[6788] | 125 | source = contextual_mat_num_source, |
---|
[6750] | 126 | ) |
---|
| 127 | |
---|
[6769] | 128 | adm_code = schema.TextLine( |
---|
[6771] | 129 | title = u'PWD Access Code', |
---|
[6769] | 130 | default = u'', |
---|
| 131 | required = False, |
---|
| 132 | readonly = True, |
---|
| 133 | ) |
---|
| 134 | |
---|
[6874] | 135 | entry_mode = schema.Choice( |
---|
[6896] | 136 | title = u'Entry Mode', |
---|
[6874] | 137 | vocabulary = study_modes, |
---|
| 138 | default = u'ug_ft', |
---|
| 139 | required = True, |
---|
| 140 | readonly = False, |
---|
| 141 | ) |
---|
| 142 | |
---|
[6631] | 143 | class IStudentClearance(IWAeUPObject): |
---|
| 144 | """Representation of student clearance data. |
---|
| 145 | """ |
---|
[6622] | 146 | |
---|
[6631] | 147 | date_of_birth = schema.Date( |
---|
| 148 | title = u'Date of Birth', |
---|
| 149 | required = True, |
---|
| 150 | ) |
---|
| 151 | |
---|
[6695] | 152 | clearance_locked = schema.Bool( |
---|
| 153 | title = u'Clearance form locked', |
---|
| 154 | default = False, |
---|
| 155 | ) |
---|
| 156 | |
---|
[6769] | 157 | clr_code = schema.TextLine( |
---|
[6771] | 158 | title = u'CLR Access Code', |
---|
[6769] | 159 | default = u'', |
---|
| 160 | required = False, |
---|
| 161 | readonly = True, |
---|
| 162 | ) |
---|
| 163 | |
---|
[6631] | 164 | class IStudentPersonal(IWAeUPObject): |
---|
| 165 | """Representation of student personal data. |
---|
| 166 | """ |
---|
| 167 | |
---|
[6651] | 168 | perm_address = schema.Text( |
---|
[6631] | 169 | title = u'Permanent Address', |
---|
| 170 | required = False, |
---|
| 171 | ) |
---|
| 172 | |
---|
| 173 | class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): |
---|
| 174 | """Representation of a student. |
---|
| 175 | """ |
---|
| 176 | |
---|
[6849] | 177 | class IStudentUpdateByRegNo(IStudent): |
---|
| 178 | """Representation of a student. Skip regular reg_number validation. |
---|
| 179 | """ |
---|
| 180 | |
---|
| 181 | reg_number = schema.TextLine( |
---|
| 182 | title = u'Registration Number', |
---|
| 183 | default = None, |
---|
| 184 | required = False, |
---|
| 185 | ) |
---|
| 186 | |
---|
| 187 | class IStudentUpdateByMatricNo(IStudent): |
---|
| 188 | """Representation of a student. Skip regular matric_number validation. |
---|
| 189 | """ |
---|
| 190 | |
---|
| 191 | matric_number = schema.TextLine( |
---|
| 192 | title = u'Matriculation Number', |
---|
| 193 | default = None, |
---|
| 194 | required = False, |
---|
| 195 | ) |
---|
| 196 | |
---|
[6633] | 197 | class IStudentStudyCourse(IWAeUPObject): |
---|
| 198 | """A container for student study levels. |
---|
| 199 | |
---|
| 200 | """ |
---|
| 201 | |
---|
[6648] | 202 | certificate = schema.Choice( |
---|
| 203 | title = u'Certificate', |
---|
| 204 | source = CertificateSource(), |
---|
| 205 | default = None, |
---|
[6633] | 206 | required = True, |
---|
| 207 | ) |
---|
[6635] | 208 | |
---|
[6724] | 209 | current_session = schema.Choice( |
---|
| 210 | title = u'Current Session', |
---|
[6744] | 211 | source = academic_sessions_vocab, |
---|
[6724] | 212 | default = None, |
---|
| 213 | required = True, |
---|
| 214 | ) |
---|
| 215 | |
---|
| 216 | current_level = schema.Choice( |
---|
| 217 | title = u'Current Level', |
---|
[6725] | 218 | source = StudyLevelSource(), |
---|
[6724] | 219 | default = None, |
---|
[6725] | 220 | required = False, |
---|
[6724] | 221 | ) |
---|
| 222 | |
---|
| 223 | current_verdict = schema.Choice( |
---|
| 224 | title = u'Current Verdict', |
---|
| 225 | source = verdicts, |
---|
[6804] | 226 | default = '0', |
---|
[6725] | 227 | required = False, |
---|
[6724] | 228 | ) |
---|
| 229 | |
---|
| 230 | previous_verdict = schema.Choice( |
---|
| 231 | title = u'Previous Verdict', |
---|
| 232 | source = verdicts, |
---|
[6805] | 233 | default = '0', |
---|
[6725] | 234 | required = False, |
---|
[6724] | 235 | ) |
---|
| 236 | |
---|
[6825] | 237 | class IStudentStudyCourseImport(IStudentStudyCourse): |
---|
| 238 | """A container for student study levels. |
---|
| 239 | |
---|
| 240 | """ |
---|
| 241 | |
---|
| 242 | current_level = schema.Int( |
---|
| 243 | title = u'Current Level', |
---|
| 244 | default = None, |
---|
| 245 | ) |
---|
| 246 | |
---|
[6774] | 247 | class IStudentStudyLevel(IWAeUPObject): |
---|
| 248 | """A container for course tickets. |
---|
| 249 | |
---|
| 250 | """ |
---|
| 251 | level = Attribute('The level code') |
---|
[6793] | 252 | validation_date = Attribute('The date of validation') |
---|
| 253 | validated_by = Attribute('User Id of course adviser') |
---|
[6774] | 254 | |
---|
[6793] | 255 | level_session = schema.Choice( |
---|
| 256 | title = u'Session', |
---|
| 257 | source = academic_sessions_vocab, |
---|
| 258 | default = None, |
---|
| 259 | required = True, |
---|
| 260 | ) |
---|
[6781] | 261 | |
---|
[6793] | 262 | level_verdict = schema.Choice( |
---|
| 263 | title = u'Verdict', |
---|
| 264 | source = verdicts, |
---|
[6805] | 265 | default = '0', |
---|
[6793] | 266 | required = False, |
---|
| 267 | ) |
---|
| 268 | |
---|
[6781] | 269 | class ICourseTicket(IWAeUPObject): |
---|
| 270 | """A course ticket. |
---|
| 271 | |
---|
| 272 | """ |
---|
[6783] | 273 | code = Attribute('code of the original course') |
---|
| 274 | title = Attribute('title of the original course') |
---|
| 275 | credits = Attribute('credits of the original course') |
---|
| 276 | passmark = Attribute('passmark of the original course') |
---|
| 277 | semester = Attribute('semester of the original course') |
---|
| 278 | faculty = Attribute('faculty of the original course') |
---|
| 279 | department = Attribute('department of the original course') |
---|
[6781] | 280 | |
---|
[6795] | 281 | core_or_elective = schema.Bool( |
---|
| 282 | title = u'Mandatory', |
---|
| 283 | default = False, |
---|
| 284 | required = False, |
---|
| 285 | readonly = False, |
---|
| 286 | ) |
---|
| 287 | |
---|
[6781] | 288 | score = schema.Int( |
---|
| 289 | title = u'Score', |
---|
| 290 | default = 0, |
---|
| 291 | required = False, |
---|
| 292 | readonly = False, |
---|
| 293 | ) |
---|
| 294 | |
---|
[6806] | 295 | automatic = schema.Bool( |
---|
| 296 | title = u'Automatical Creation', |
---|
| 297 | default = False, |
---|
| 298 | required = False, |
---|
| 299 | readonly = True, |
---|
| 300 | ) |
---|
| 301 | |
---|
[6795] | 302 | class ICourseTicketAdd(ICourseTicket): |
---|
| 303 | """An interface for adding course tickets |
---|
| 304 | |
---|
| 305 | """ |
---|
| 306 | course = schema.Choice( |
---|
| 307 | title = u'Course', |
---|
| 308 | source = CourseSource(), |
---|
| 309 | readonly = False, |
---|
| 310 | ) |
---|
| 311 | |
---|
[6635] | 312 | class IStudentAccommodation(IWAeUPObject): |
---|
| 313 | """A container for student accommodation objects. |
---|
| 314 | |
---|
| 315 | """ |
---|
| 316 | |
---|
[6860] | 317 | class IStudentPaymentsContainer(IPaymentsContainer): |
---|
[6635] | 318 | """A container for student payment objects. |
---|
| 319 | |
---|
| 320 | """ |
---|
| 321 | |
---|
[6877] | 322 | class IStudentOnlinePayment(IOnlinePayment): |
---|
| 323 | """A student payment via payment gateways. |
---|
| 324 | |
---|
| 325 | """ |
---|
| 326 | |
---|
| 327 | p_session = schema.Choice( |
---|
| 328 | title = u'Payment Session', |
---|
| 329 | source = academic_sessions_vocab, |
---|
| 330 | required = False, |
---|
| 331 | ) |
---|
| 332 | |
---|
| 333 | IStudentOnlinePayment['p_session'].order = IStudentOnlinePayment[ |
---|
| 334 | 'p_item'].order |
---|
| 335 | |
---|
[6694] | 336 | # Interfaces for students only |
---|
| 337 | |
---|
| 338 | class IStudentClearanceEdit(IStudentClearance): |
---|
| 339 | """Interface needed for restricted editing of student clearance data. |
---|
| 340 | """ |
---|
| 341 | |
---|
| 342 | class IStudentPersonalEdit(IStudentPersonal): |
---|
| 343 | """Interface needed for restricted editing of student personal data. |
---|
| 344 | """ |
---|