[6621] | 1 | ## |
---|
| 2 | ## interfaces.py |
---|
[6996] | 3 | from datetime import datetime |
---|
[6788] | 4 | from zope.interface import Attribute, invariant |
---|
[6756] | 5 | from zope.interface.exceptions import Invalid |
---|
[6621] | 6 | from zope import schema |
---|
[6915] | 7 | from waeup.sirp.interfaces import IWAeUPObject, academic_sessions_vocab |
---|
[6788] | 8 | from waeup.sirp.schema import TextLineChoice |
---|
[6874] | 9 | from waeup.sirp.university.vocabularies import CourseSource, study_modes |
---|
[6648] | 10 | from waeup.sirp.students.vocabularies import ( |
---|
[6788] | 11 | CertificateSource, academic_sessions_vocab, verdicts, StudyLevelSource, |
---|
[6996] | 12 | contextual_reg_num_source, contextual_mat_num_source, GenderSource, |
---|
[6648] | 13 | ) |
---|
[6877] | 14 | from waeup.sirp.payments.interfaces import IPaymentsContainer, IOnlinePayment |
---|
[6621] | 15 | |
---|
[6692] | 16 | class IStudentsContainer(IWAeUPObject): |
---|
| 17 | """An students container contains university students. |
---|
| 18 | |
---|
| 19 | """ |
---|
| 20 | |
---|
| 21 | def addStudent(student): |
---|
| 22 | """Add an IStudent object and subcontainers. |
---|
| 23 | |
---|
| 24 | """ |
---|
| 25 | |
---|
| 26 | def archive(id=None): |
---|
| 27 | """Create on-dist archive of students. |
---|
| 28 | |
---|
| 29 | If id is `None`, all students are archived. |
---|
| 30 | |
---|
| 31 | If id contains a single id string, only the respective |
---|
| 32 | students are archived. |
---|
| 33 | |
---|
| 34 | If id contains a list of id strings all of the respective |
---|
| 35 | students types are saved to disk. |
---|
| 36 | """ |
---|
| 37 | |
---|
| 38 | def clear(id=None, archive=True): |
---|
| 39 | """Remove students of type given by 'id'. |
---|
| 40 | |
---|
| 41 | Optionally archive the students. |
---|
| 42 | |
---|
| 43 | If id is `None`, all students are archived. |
---|
| 44 | |
---|
| 45 | If id contains a single id string, only the respective |
---|
| 46 | students are archived. |
---|
| 47 | |
---|
| 48 | If id contains a list of id strings all of the respective |
---|
| 49 | student types are saved to disk. |
---|
| 50 | |
---|
| 51 | If `archive` is ``False`` none of the archive-handling is done |
---|
| 52 | and respective students are simply removed from the |
---|
| 53 | database. |
---|
| 54 | """ |
---|
| 55 | |
---|
[6642] | 56 | class IStudentNavigation(IWAeUPObject): |
---|
| 57 | """Interface needed for student navigation. |
---|
| 58 | """ |
---|
| 59 | |
---|
| 60 | def getStudent(): |
---|
| 61 | """Return student object. |
---|
| 62 | """ |
---|
| 63 | |
---|
[6756] | 64 | class IStudentPasswordSetting(IWAeUPObject): |
---|
| 65 | """Data needed for password setting. |
---|
| 66 | """ |
---|
| 67 | name = schema.TextLine( |
---|
| 68 | title = u'Full Name', |
---|
| 69 | default = u'Nobody', |
---|
| 70 | required = True, |
---|
[6764] | 71 | readonly = True |
---|
[6756] | 72 | ) |
---|
| 73 | |
---|
| 74 | password = schema.Password( |
---|
| 75 | title = u'New password', |
---|
| 76 | required = False, |
---|
| 77 | ) |
---|
| 78 | |
---|
| 79 | password_repeat = schema.Password( |
---|
| 80 | title = u'Retype new password', |
---|
| 81 | required = False, |
---|
| 82 | ) |
---|
| 83 | |
---|
| 84 | @invariant |
---|
| 85 | def passwords_match(obj): |
---|
| 86 | if obj.password == obj.password_repeat: |
---|
| 87 | return |
---|
| 88 | raise Invalid('passwords do not match') |
---|
| 89 | |
---|
[6631] | 90 | class IStudentBase(IWAeUPObject): |
---|
| 91 | """Representation of student base data. |
---|
[6621] | 92 | """ |
---|
[6637] | 93 | history = Attribute('Object history, a list of messages.') |
---|
| 94 | state = Attribute('Returns the registration state of a student') |
---|
[6699] | 95 | password = Attribute('Encrypted password of a student') |
---|
[6814] | 96 | certificate = Attribute('The certificate of any chosen study course') |
---|
[6637] | 97 | |
---|
| 98 | def loggerInfo(ob_class, comment): |
---|
| 99 | """Adds an INFO message to the log file |
---|
| 100 | """ |
---|
| 101 | |
---|
[6665] | 102 | student_id = schema.TextLine( |
---|
| 103 | title = u'Student ID', |
---|
[6849] | 104 | required = False, |
---|
[6665] | 105 | ) |
---|
| 106 | |
---|
[6818] | 107 | fullname = schema.TextLine( |
---|
[6631] | 108 | title = u'Full Name', |
---|
[6818] | 109 | default = None, |
---|
[6621] | 110 | required = True, |
---|
| 111 | ) |
---|
| 112 | |
---|
[6996] | 113 | sex = schema.Choice( |
---|
| 114 | title = u'Sex', |
---|
| 115 | source = GenderSource(), |
---|
| 116 | default = u'm', |
---|
| 117 | required = True, |
---|
| 118 | ) |
---|
| 119 | |
---|
[6788] | 120 | reg_number = TextLineChoice( |
---|
[6696] | 121 | title = u'Registration Number', |
---|
[6818] | 122 | default = None, |
---|
[6696] | 123 | required = True, |
---|
| 124 | readonly = False, |
---|
[6788] | 125 | source = contextual_reg_num_source, |
---|
[6696] | 126 | ) |
---|
| 127 | |
---|
[6788] | 128 | matric_number = TextLineChoice( |
---|
[6750] | 129 | title = u'Matriculation Number', |
---|
[6788] | 130 | #default = u'', |
---|
[6750] | 131 | required = False, |
---|
| 132 | readonly = False, |
---|
[6788] | 133 | source = contextual_mat_num_source, |
---|
[6750] | 134 | ) |
---|
| 135 | |
---|
[6769] | 136 | adm_code = schema.TextLine( |
---|
[6935] | 137 | title = u'PWD Activation Code', |
---|
[6769] | 138 | default = u'', |
---|
| 139 | required = False, |
---|
| 140 | readonly = True, |
---|
| 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( |
---|
[6935] | 158 | title = u'CLR Activation 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 | |
---|
[6996] | 209 | |
---|
| 210 | entry_mode = schema.Choice( |
---|
| 211 | title = u'Entry Mode', |
---|
| 212 | vocabulary = study_modes, |
---|
| 213 | default = u'ug_ft', |
---|
| 214 | required = True, |
---|
| 215 | readonly = False, |
---|
| 216 | ) |
---|
| 217 | |
---|
| 218 | entry_session = schema.Choice( |
---|
| 219 | title = u'Entry Session', |
---|
| 220 | source = academic_sessions_vocab, |
---|
| 221 | default = datetime.now().year, |
---|
| 222 | required = True, |
---|
| 223 | readonly = False, |
---|
| 224 | ) |
---|
| 225 | |
---|
[6724] | 226 | current_session = schema.Choice( |
---|
| 227 | title = u'Current Session', |
---|
[6744] | 228 | source = academic_sessions_vocab, |
---|
[6724] | 229 | default = None, |
---|
| 230 | required = True, |
---|
[6996] | 231 | readonly = False, |
---|
[6724] | 232 | ) |
---|
| 233 | |
---|
| 234 | current_level = schema.Choice( |
---|
| 235 | title = u'Current Level', |
---|
[6725] | 236 | source = StudyLevelSource(), |
---|
[6724] | 237 | default = None, |
---|
[6725] | 238 | required = False, |
---|
[6996] | 239 | readonly = False, |
---|
[6724] | 240 | ) |
---|
| 241 | |
---|
| 242 | current_verdict = schema.Choice( |
---|
| 243 | title = u'Current Verdict', |
---|
| 244 | source = verdicts, |
---|
[6804] | 245 | default = '0', |
---|
[6725] | 246 | required = False, |
---|
[6724] | 247 | ) |
---|
| 248 | |
---|
| 249 | previous_verdict = schema.Choice( |
---|
| 250 | title = u'Previous Verdict', |
---|
| 251 | source = verdicts, |
---|
[6805] | 252 | default = '0', |
---|
[6725] | 253 | required = False, |
---|
[6724] | 254 | ) |
---|
| 255 | |
---|
[6825] | 256 | class IStudentStudyCourseImport(IStudentStudyCourse): |
---|
| 257 | """A container for student study levels. |
---|
| 258 | |
---|
| 259 | """ |
---|
| 260 | |
---|
| 261 | current_level = schema.Int( |
---|
| 262 | title = u'Current Level', |
---|
| 263 | default = None, |
---|
| 264 | ) |
---|
| 265 | |
---|
[6774] | 266 | class IStudentStudyLevel(IWAeUPObject): |
---|
| 267 | """A container for course tickets. |
---|
| 268 | |
---|
| 269 | """ |
---|
| 270 | level = Attribute('The level code') |
---|
[6793] | 271 | validation_date = Attribute('The date of validation') |
---|
| 272 | validated_by = Attribute('User Id of course adviser') |
---|
[6774] | 273 | |
---|
[6793] | 274 | level_session = schema.Choice( |
---|
| 275 | title = u'Session', |
---|
| 276 | source = academic_sessions_vocab, |
---|
| 277 | default = None, |
---|
| 278 | required = True, |
---|
| 279 | ) |
---|
[6781] | 280 | |
---|
[6793] | 281 | level_verdict = schema.Choice( |
---|
| 282 | title = u'Verdict', |
---|
| 283 | source = verdicts, |
---|
[6805] | 284 | default = '0', |
---|
[6793] | 285 | required = False, |
---|
| 286 | ) |
---|
| 287 | |
---|
[6781] | 288 | class ICourseTicket(IWAeUPObject): |
---|
| 289 | """A course ticket. |
---|
| 290 | |
---|
| 291 | """ |
---|
[6783] | 292 | code = Attribute('code of the original course') |
---|
| 293 | title = Attribute('title of the original course') |
---|
| 294 | credits = Attribute('credits of the original course') |
---|
| 295 | passmark = Attribute('passmark of the original course') |
---|
| 296 | semester = Attribute('semester of the original course') |
---|
| 297 | faculty = Attribute('faculty of the original course') |
---|
| 298 | department = Attribute('department of the original course') |
---|
[6781] | 299 | |
---|
[6795] | 300 | core_or_elective = schema.Bool( |
---|
| 301 | title = u'Mandatory', |
---|
| 302 | default = False, |
---|
| 303 | required = False, |
---|
| 304 | readonly = False, |
---|
| 305 | ) |
---|
| 306 | |
---|
[6781] | 307 | score = schema.Int( |
---|
| 308 | title = u'Score', |
---|
| 309 | default = 0, |
---|
| 310 | required = False, |
---|
| 311 | readonly = False, |
---|
| 312 | ) |
---|
| 313 | |
---|
[6806] | 314 | automatic = schema.Bool( |
---|
| 315 | title = u'Automatical Creation', |
---|
| 316 | default = False, |
---|
| 317 | required = False, |
---|
| 318 | readonly = True, |
---|
| 319 | ) |
---|
| 320 | |
---|
[6795] | 321 | class ICourseTicketAdd(ICourseTicket): |
---|
| 322 | """An interface for adding course tickets |
---|
| 323 | |
---|
| 324 | """ |
---|
| 325 | course = schema.Choice( |
---|
| 326 | title = u'Course', |
---|
| 327 | source = CourseSource(), |
---|
| 328 | readonly = False, |
---|
| 329 | ) |
---|
| 330 | |
---|
[6635] | 331 | class IStudentAccommodation(IWAeUPObject): |
---|
| 332 | """A container for student accommodation objects. |
---|
| 333 | |
---|
| 334 | """ |
---|
| 335 | |
---|
[6989] | 336 | class IBedTicket(IWAeUPObject): |
---|
| 337 | """A ticket for accommodation booking. |
---|
| 338 | |
---|
| 339 | """ |
---|
| 340 | |
---|
[6996] | 341 | bed = Attribute('The bed object.') |
---|
| 342 | |
---|
| 343 | bed_coordinates = schema.TextLine( |
---|
| 344 | title = u'Bed Coordinates', |
---|
[6992] | 345 | default = None, |
---|
| 346 | required = False, |
---|
[7014] | 347 | readonly = False, |
---|
[6992] | 348 | ) |
---|
| 349 | |
---|
[6996] | 350 | bed_type = schema.TextLine( |
---|
| 351 | title = u'Bed Type', |
---|
| 352 | default = None, |
---|
| 353 | required = False, |
---|
[7014] | 354 | readonly = False, |
---|
[6996] | 355 | ) |
---|
| 356 | |
---|
[6992] | 357 | booking_session = schema.Choice( |
---|
| 358 | title = u'Session', |
---|
| 359 | source = academic_sessions_vocab, |
---|
| 360 | default = None, |
---|
| 361 | required = True, |
---|
[7014] | 362 | readonly = True, |
---|
[6992] | 363 | ) |
---|
| 364 | |
---|
| 365 | booking_date = schema.Datetime( |
---|
| 366 | title = u'Booking Date', |
---|
| 367 | required = False, |
---|
[7014] | 368 | readonly = True, |
---|
[6992] | 369 | ) |
---|
| 370 | |
---|
| 371 | booking_code = schema.TextLine( |
---|
| 372 | title = u'Booking Activation Code', |
---|
| 373 | default = u'', |
---|
| 374 | required = False, |
---|
[7014] | 375 | readonly = True, |
---|
[6992] | 376 | ) |
---|
| 377 | |
---|
[6994] | 378 | def getSessionString(): |
---|
| 379 | """Returns the the title of academic_sessions_vocab term |
---|
| 380 | """ |
---|
[6992] | 381 | |
---|
[6860] | 382 | class IStudentPaymentsContainer(IPaymentsContainer): |
---|
[6635] | 383 | """A container for student payment objects. |
---|
| 384 | |
---|
| 385 | """ |
---|
| 386 | |
---|
[6877] | 387 | class IStudentOnlinePayment(IOnlinePayment): |
---|
| 388 | """A student payment via payment gateways. |
---|
| 389 | |
---|
| 390 | """ |
---|
| 391 | |
---|
| 392 | p_session = schema.Choice( |
---|
| 393 | title = u'Payment Session', |
---|
| 394 | source = academic_sessions_vocab, |
---|
| 395 | required = False, |
---|
| 396 | ) |
---|
| 397 | |
---|
| 398 | IStudentOnlinePayment['p_session'].order = IStudentOnlinePayment[ |
---|
| 399 | 'p_item'].order |
---|
| 400 | |
---|
[6694] | 401 | # Interfaces for students only |
---|
| 402 | |
---|
| 403 | class IStudentClearanceEdit(IStudentClearance): |
---|
| 404 | """Interface needed for restricted editing of student clearance data. |
---|
| 405 | """ |
---|
| 406 | |
---|
| 407 | class IStudentPersonalEdit(IStudentPersonal): |
---|
| 408 | """Interface needed for restricted editing of student personal data. |
---|
| 409 | """ |
---|