[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 | """ |
---|
[7062] | 93 | history = Attribute('Object history, a list of messages') |
---|
[6637] | 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') |
---|
[7062] | 97 | current_session = Attribute('The current session of the student') |
---|
[6637] | 98 | |
---|
| 99 | def loggerInfo(ob_class, comment): |
---|
| 100 | """Adds an INFO message to the log file |
---|
| 101 | """ |
---|
| 102 | |
---|
[6665] | 103 | student_id = schema.TextLine( |
---|
| 104 | title = u'Student ID', |
---|
[6849] | 105 | required = False, |
---|
[6665] | 106 | ) |
---|
| 107 | |
---|
[6818] | 108 | fullname = schema.TextLine( |
---|
[6631] | 109 | title = u'Full Name', |
---|
[6818] | 110 | default = None, |
---|
[6621] | 111 | required = True, |
---|
| 112 | ) |
---|
| 113 | |
---|
[6996] | 114 | sex = schema.Choice( |
---|
| 115 | title = u'Sex', |
---|
| 116 | source = GenderSource(), |
---|
| 117 | default = u'm', |
---|
| 118 | required = True, |
---|
| 119 | ) |
---|
| 120 | |
---|
[6788] | 121 | reg_number = TextLineChoice( |
---|
[6696] | 122 | title = u'Registration Number', |
---|
[6818] | 123 | default = None, |
---|
[6696] | 124 | required = True, |
---|
| 125 | readonly = False, |
---|
[6788] | 126 | source = contextual_reg_num_source, |
---|
[6696] | 127 | ) |
---|
| 128 | |
---|
[6788] | 129 | matric_number = TextLineChoice( |
---|
[6750] | 130 | title = u'Matriculation Number', |
---|
[6788] | 131 | #default = u'', |
---|
[6750] | 132 | required = False, |
---|
| 133 | readonly = False, |
---|
[6788] | 134 | source = contextual_mat_num_source, |
---|
[6750] | 135 | ) |
---|
| 136 | |
---|
[6769] | 137 | adm_code = schema.TextLine( |
---|
[6935] | 138 | title = u'PWD Activation Code', |
---|
[6769] | 139 | default = u'', |
---|
| 140 | required = False, |
---|
| 141 | readonly = True, |
---|
| 142 | ) |
---|
| 143 | |
---|
[6631] | 144 | class IStudentClearance(IWAeUPObject): |
---|
| 145 | """Representation of student clearance data. |
---|
| 146 | """ |
---|
[6622] | 147 | |
---|
[6631] | 148 | date_of_birth = schema.Date( |
---|
| 149 | title = u'Date of Birth', |
---|
| 150 | required = True, |
---|
| 151 | ) |
---|
| 152 | |
---|
[6695] | 153 | clearance_locked = schema.Bool( |
---|
| 154 | title = u'Clearance form locked', |
---|
| 155 | default = False, |
---|
| 156 | ) |
---|
| 157 | |
---|
[6769] | 158 | clr_code = schema.TextLine( |
---|
[6935] | 159 | title = u'CLR Activation Code', |
---|
[6769] | 160 | default = u'', |
---|
| 161 | required = False, |
---|
| 162 | readonly = True, |
---|
| 163 | ) |
---|
| 164 | |
---|
[6631] | 165 | class IStudentPersonal(IWAeUPObject): |
---|
| 166 | """Representation of student personal data. |
---|
| 167 | """ |
---|
| 168 | |
---|
[6651] | 169 | perm_address = schema.Text( |
---|
[6631] | 170 | title = u'Permanent Address', |
---|
| 171 | required = False, |
---|
| 172 | ) |
---|
| 173 | |
---|
| 174 | class IStudent(IStudentBase,IStudentClearance,IStudentPersonal): |
---|
| 175 | """Representation of a student. |
---|
| 176 | """ |
---|
| 177 | |
---|
[6849] | 178 | class IStudentUpdateByRegNo(IStudent): |
---|
| 179 | """Representation of a student. Skip regular reg_number validation. |
---|
| 180 | """ |
---|
| 181 | |
---|
| 182 | reg_number = schema.TextLine( |
---|
| 183 | title = u'Registration Number', |
---|
| 184 | default = None, |
---|
| 185 | required = False, |
---|
| 186 | ) |
---|
| 187 | |
---|
| 188 | class IStudentUpdateByMatricNo(IStudent): |
---|
| 189 | """Representation of a student. Skip regular matric_number validation. |
---|
| 190 | """ |
---|
| 191 | |
---|
| 192 | matric_number = schema.TextLine( |
---|
| 193 | title = u'Matriculation Number', |
---|
| 194 | default = None, |
---|
| 195 | required = False, |
---|
| 196 | ) |
---|
| 197 | |
---|
[6633] | 198 | class IStudentStudyCourse(IWAeUPObject): |
---|
| 199 | """A container for student study levels. |
---|
| 200 | |
---|
| 201 | """ |
---|
| 202 | |
---|
[6648] | 203 | certificate = schema.Choice( |
---|
| 204 | title = u'Certificate', |
---|
| 205 | source = CertificateSource(), |
---|
| 206 | default = None, |
---|
[6633] | 207 | required = True, |
---|
| 208 | ) |
---|
[6635] | 209 | |
---|
[6996] | 210 | |
---|
| 211 | entry_mode = schema.Choice( |
---|
| 212 | title = u'Entry Mode', |
---|
| 213 | vocabulary = study_modes, |
---|
| 214 | default = u'ug_ft', |
---|
| 215 | required = True, |
---|
| 216 | readonly = False, |
---|
| 217 | ) |
---|
| 218 | |
---|
| 219 | entry_session = schema.Choice( |
---|
| 220 | title = u'Entry Session', |
---|
| 221 | source = academic_sessions_vocab, |
---|
| 222 | default = datetime.now().year, |
---|
| 223 | required = True, |
---|
| 224 | readonly = False, |
---|
| 225 | ) |
---|
| 226 | |
---|
[6724] | 227 | current_session = schema.Choice( |
---|
| 228 | title = u'Current Session', |
---|
[6744] | 229 | source = academic_sessions_vocab, |
---|
[6724] | 230 | default = None, |
---|
| 231 | required = True, |
---|
[6996] | 232 | readonly = False, |
---|
[6724] | 233 | ) |
---|
| 234 | |
---|
| 235 | current_level = schema.Choice( |
---|
| 236 | title = u'Current Level', |
---|
[6725] | 237 | source = StudyLevelSource(), |
---|
[6724] | 238 | default = None, |
---|
[6725] | 239 | required = False, |
---|
[6996] | 240 | readonly = False, |
---|
[6724] | 241 | ) |
---|
| 242 | |
---|
| 243 | current_verdict = schema.Choice( |
---|
| 244 | title = u'Current Verdict', |
---|
| 245 | source = verdicts, |
---|
[6804] | 246 | default = '0', |
---|
[6725] | 247 | required = False, |
---|
[6724] | 248 | ) |
---|
| 249 | |
---|
| 250 | previous_verdict = schema.Choice( |
---|
| 251 | title = u'Previous Verdict', |
---|
| 252 | source = verdicts, |
---|
[6805] | 253 | default = '0', |
---|
[6725] | 254 | required = False, |
---|
[6724] | 255 | ) |
---|
| 256 | |
---|
[6825] | 257 | class IStudentStudyCourseImport(IStudentStudyCourse): |
---|
| 258 | """A container for student study levels. |
---|
| 259 | |
---|
| 260 | """ |
---|
| 261 | |
---|
| 262 | current_level = schema.Int( |
---|
| 263 | title = u'Current Level', |
---|
| 264 | default = None, |
---|
| 265 | ) |
---|
| 266 | |
---|
[6774] | 267 | class IStudentStudyLevel(IWAeUPObject): |
---|
| 268 | """A container for course tickets. |
---|
| 269 | |
---|
| 270 | """ |
---|
| 271 | level = Attribute('The level code') |
---|
[6793] | 272 | validation_date = Attribute('The date of validation') |
---|
| 273 | validated_by = Attribute('User Id of course adviser') |
---|
[6774] | 274 | |
---|
[6793] | 275 | level_session = schema.Choice( |
---|
| 276 | title = u'Session', |
---|
| 277 | source = academic_sessions_vocab, |
---|
| 278 | default = None, |
---|
| 279 | required = True, |
---|
| 280 | ) |
---|
[6781] | 281 | |
---|
[6793] | 282 | level_verdict = schema.Choice( |
---|
| 283 | title = u'Verdict', |
---|
| 284 | source = verdicts, |
---|
[6805] | 285 | default = '0', |
---|
[6793] | 286 | required = False, |
---|
| 287 | ) |
---|
| 288 | |
---|
[6781] | 289 | class ICourseTicket(IWAeUPObject): |
---|
| 290 | """A course ticket. |
---|
| 291 | |
---|
| 292 | """ |
---|
[6783] | 293 | code = Attribute('code of the original course') |
---|
| 294 | title = Attribute('title of the original course') |
---|
| 295 | credits = Attribute('credits of the original course') |
---|
| 296 | passmark = Attribute('passmark of the original course') |
---|
| 297 | semester = Attribute('semester of the original course') |
---|
| 298 | faculty = Attribute('faculty of the original course') |
---|
| 299 | department = Attribute('department of the original course') |
---|
[6781] | 300 | |
---|
[6795] | 301 | core_or_elective = schema.Bool( |
---|
| 302 | title = u'Mandatory', |
---|
| 303 | default = False, |
---|
| 304 | required = False, |
---|
| 305 | readonly = False, |
---|
| 306 | ) |
---|
| 307 | |
---|
[6781] | 308 | score = schema.Int( |
---|
| 309 | title = u'Score', |
---|
| 310 | default = 0, |
---|
| 311 | required = False, |
---|
| 312 | readonly = False, |
---|
| 313 | ) |
---|
| 314 | |
---|
[6806] | 315 | automatic = schema.Bool( |
---|
| 316 | title = u'Automatical Creation', |
---|
| 317 | default = False, |
---|
| 318 | required = False, |
---|
| 319 | readonly = True, |
---|
| 320 | ) |
---|
| 321 | |
---|
[6795] | 322 | class ICourseTicketAdd(ICourseTicket): |
---|
| 323 | """An interface for adding course tickets |
---|
| 324 | |
---|
| 325 | """ |
---|
| 326 | course = schema.Choice( |
---|
| 327 | title = u'Course', |
---|
| 328 | source = CourseSource(), |
---|
| 329 | readonly = False, |
---|
| 330 | ) |
---|
| 331 | |
---|
[6635] | 332 | class IStudentAccommodation(IWAeUPObject): |
---|
| 333 | """A container for student accommodation objects. |
---|
| 334 | |
---|
| 335 | """ |
---|
| 336 | |
---|
[6989] | 337 | class IBedTicket(IWAeUPObject): |
---|
| 338 | """A ticket for accommodation booking. |
---|
| 339 | |
---|
| 340 | """ |
---|
| 341 | |
---|
[6996] | 342 | bed = Attribute('The bed object.') |
---|
| 343 | |
---|
| 344 | bed_coordinates = schema.TextLine( |
---|
| 345 | title = u'Bed Coordinates', |
---|
[6992] | 346 | default = None, |
---|
| 347 | required = False, |
---|
[7014] | 348 | readonly = False, |
---|
[6992] | 349 | ) |
---|
| 350 | |
---|
[6996] | 351 | bed_type = schema.TextLine( |
---|
| 352 | title = u'Bed Type', |
---|
| 353 | default = None, |
---|
| 354 | required = False, |
---|
[7014] | 355 | readonly = False, |
---|
[6996] | 356 | ) |
---|
| 357 | |
---|
[6992] | 358 | booking_session = schema.Choice( |
---|
| 359 | title = u'Session', |
---|
| 360 | source = academic_sessions_vocab, |
---|
| 361 | default = None, |
---|
| 362 | required = True, |
---|
[7014] | 363 | readonly = True, |
---|
[6992] | 364 | ) |
---|
| 365 | |
---|
| 366 | booking_date = schema.Datetime( |
---|
| 367 | title = u'Booking Date', |
---|
| 368 | required = False, |
---|
[7014] | 369 | readonly = True, |
---|
[6992] | 370 | ) |
---|
| 371 | |
---|
| 372 | booking_code = schema.TextLine( |
---|
| 373 | title = u'Booking Activation Code', |
---|
| 374 | default = u'', |
---|
| 375 | required = False, |
---|
[7014] | 376 | readonly = True, |
---|
[6992] | 377 | ) |
---|
| 378 | |
---|
[6994] | 379 | def getSessionString(): |
---|
| 380 | """Returns the the title of academic_sessions_vocab term |
---|
| 381 | """ |
---|
[6992] | 382 | |
---|
[6860] | 383 | class IStudentPaymentsContainer(IPaymentsContainer): |
---|
[6635] | 384 | """A container for student payment objects. |
---|
| 385 | |
---|
| 386 | """ |
---|
| 387 | |
---|
[6877] | 388 | class IStudentOnlinePayment(IOnlinePayment): |
---|
| 389 | """A student payment via payment gateways. |
---|
| 390 | |
---|
| 391 | """ |
---|
| 392 | |
---|
| 393 | p_session = schema.Choice( |
---|
| 394 | title = u'Payment Session', |
---|
| 395 | source = academic_sessions_vocab, |
---|
| 396 | required = False, |
---|
| 397 | ) |
---|
| 398 | |
---|
| 399 | IStudentOnlinePayment['p_session'].order = IStudentOnlinePayment[ |
---|
| 400 | 'p_item'].order |
---|
| 401 | |
---|
[6694] | 402 | # Interfaces for students only |
---|
| 403 | |
---|
| 404 | class IStudentClearanceEdit(IStudentClearance): |
---|
| 405 | """Interface needed for restricted editing of student clearance data. |
---|
| 406 | """ |
---|
| 407 | |
---|
| 408 | class IStudentPersonalEdit(IStudentPersonal): |
---|
| 409 | """Interface needed for restricted editing of student personal data. |
---|
| 410 | """ |
---|