| 1 | ## $Id: interfaces.py 18166 2025-09-03 07:38:18Z 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 | #from datetime import datetime |
|---|
| 19 | from zope.component import getUtility |
|---|
| 20 | from zope.interface import Attribute, Interface, invariant, Invalid |
|---|
| 21 | from zope import schema |
|---|
| 22 | from zc.sourcefactory.contextual import BasicContextualSourceFactory |
|---|
| 23 | from waeup.kofa.browser.interfaces import IStudentNavigationBase |
|---|
| 24 | from waeup.kofa.interfaces import ( |
|---|
| 25 | IKofaObject, academic_sessions_vocab, validate_email, ICSVExporter, |
|---|
| 26 | ContextualDictSourceFactoryBase, IKofaUtils) |
|---|
| 27 | from waeup.kofa.interfaces import MessageFactory as _ |
|---|
| 28 | from waeup.kofa.schema import TextLineChoice, FormattedDate, PhoneNumber |
|---|
| 29 | from waeup.kofa.students.vocabularies import ( |
|---|
| 30 | StudyLevelSource, contextual_reg_num_source, contextual_mat_num_source, |
|---|
| 31 | GenderSource, nats_vocab |
|---|
| 32 | ) |
|---|
| 33 | from waeup.kofa.payments.interfaces import ( |
|---|
| 34 | IPaymentsContainer, IOnlinePayment) |
|---|
| 35 | from waeup.kofa.university.vocabularies import ( |
|---|
| 36 | CourseSource, StudyModeSource, CertificateSource, |
|---|
| 37 | SemesterSource, CourseCategorySource |
|---|
| 38 | ) |
|---|
| 39 | |
|---|
| 40 | class PreviousPaymentCategorySource(ContextualDictSourceFactoryBase): |
|---|
| 41 | """A source that delivers all selectable categories of previous session |
|---|
| 42 | payments. |
|---|
| 43 | """ |
|---|
| 44 | #: name of dict to deliver from kofa utils. |
|---|
| 45 | DICT_NAME = 'PREVIOUS_PAYMENT_CATEGORIES' |
|---|
| 46 | |
|---|
| 47 | class BalancePaymentCategorySource(ContextualDictSourceFactoryBase): |
|---|
| 48 | """A source that delivers all selectable items of balance payments. |
|---|
| 49 | """ |
|---|
| 50 | #: name of dict to deliver from kofa utils. |
|---|
| 51 | DICT_NAME = 'BALANCE_PAYMENT_CATEGORIES' |
|---|
| 52 | |
|---|
| 53 | # VerdictSource can't be placed into the vocabularies module because it |
|---|
| 54 | # requires importing IStudentsUtils which then leads to circular imports. |
|---|
| 55 | class VerdictSource(BasicContextualSourceFactory): |
|---|
| 56 | """A verdicts source delivers all verdicts provided |
|---|
| 57 | in the portal. |
|---|
| 58 | """ |
|---|
| 59 | def getValues(self, context): |
|---|
| 60 | verdicts_dict = getUtility(IKofaUtils).VERDICTS_DICT |
|---|
| 61 | return sorted(verdicts_dict.keys()) |
|---|
| 62 | |
|---|
| 63 | def getToken(self, context, value): |
|---|
| 64 | return value |
|---|
| 65 | |
|---|
| 66 | def getTitle(self, context, value): |
|---|
| 67 | verdicts_dict = getUtility(IKofaUtils).VERDICTS_DICT |
|---|
| 68 | if value != '0': |
|---|
| 69 | return verdicts_dict[value] + ' (%s)' % value |
|---|
| 70 | return verdicts_dict[value] |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | class IStudentsUtils(Interface): |
|---|
| 74 | """A collection of methods which are subject to customization. |
|---|
| 75 | """ |
|---|
| 76 | def setReturningData(student): |
|---|
| 77 | """ This method defines what happens after school fee payment |
|---|
| 78 | depending on the student's senate verdict. |
|---|
| 79 | |
|---|
| 80 | In the base configuration current level is always increased |
|---|
| 81 | by 100 no matter which verdict has been assigned. |
|---|
| 82 | """ |
|---|
| 83 | |
|---|
| 84 | def setPaymentDetails(category, student, previous_session=None, |
|---|
| 85 | previous_level=None, combi=None): |
|---|
| 86 | """Create Payment object and set the payment data of a student for |
|---|
| 87 | the payment category specified. |
|---|
| 88 | """ |
|---|
| 89 | |
|---|
| 90 | def increaseMatricInteger(student): |
|---|
| 91 | """Increase counter for matric numbers. |
|---|
| 92 | |
|---|
| 93 | This counter can be a centrally stored attribute or an attribute of |
|---|
| 94 | faculties, departments or certificates. In the base package the counter |
|---|
| 95 | is as an attribute of the site configuration object. |
|---|
| 96 | """ |
|---|
| 97 | |
|---|
| 98 | def constructMatricNumber(student): |
|---|
| 99 | """Fetch the matric number counter which fits the student and |
|---|
| 100 | construct the new matric number of the student. |
|---|
| 101 | |
|---|
| 102 | In the base package the counter is returned which is as an attribute |
|---|
| 103 | of the site configuration object. |
|---|
| 104 | """ |
|---|
| 105 | |
|---|
| 106 | def allowPortraitChange(student): |
|---|
| 107 | """Check if student is allowed to change the portrait file. |
|---|
| 108 | """ |
|---|
| 109 | |
|---|
| 110 | def setMatricNumber(student): |
|---|
| 111 | """Set matriculation number of student. |
|---|
| 112 | |
|---|
| 113 | If the student's matric number is unset a new matric number is |
|---|
| 114 | constructed according to the matriculation number construction rules |
|---|
| 115 | defined in the constructMatricNumber method. The new matric number is |
|---|
| 116 | set, the students catalog updated. The corresponding matric number |
|---|
| 117 | counter is increased by one. |
|---|
| 118 | |
|---|
| 119 | This method is tested but not used in the base package. It can |
|---|
| 120 | be used in custom packages by adding respective views |
|---|
| 121 | and by customizing increaseMatricInteger and constructMatricNumber |
|---|
| 122 | according to the university's matriculation number construction rules. |
|---|
| 123 | |
|---|
| 124 | The method can be disabled by setting the counter to zero. |
|---|
| 125 | """ |
|---|
| 126 | |
|---|
| 127 | def getAccommodation_details(student): |
|---|
| 128 | """Determine the accommodation dates of a student. |
|---|
| 129 | """ |
|---|
| 130 | |
|---|
| 131 | def selectBed(available_beds): |
|---|
| 132 | """Select a bed from a list of available beds. |
|---|
| 133 | In the standard configuration we select the first bed found, |
|---|
| 134 | but can also randomize the selection if we like. |
|---|
| 135 | """ |
|---|
| 136 | |
|---|
| 137 | def getDegreeClassNumber(level_obj): |
|---|
| 138 | """Get degree class number (used for SessionResultsPresentation |
|---|
| 139 | reports). |
|---|
| 140 | """ |
|---|
| 141 | |
|---|
| 142 | def getPDFCreator(context): |
|---|
| 143 | """Get some IPDFCreator instance suitable for use with `context`. |
|---|
| 144 | """ |
|---|
| 145 | |
|---|
| 146 | def renderPDF(view, subject='', filename='slip.pdf',): |
|---|
| 147 | """Render pdf slips for various pages. |
|---|
| 148 | """ |
|---|
| 149 | |
|---|
| 150 | def renderPDFAdmissionLetter(view, student=None, omit_fields=(), |
|---|
| 151 | pre_text=None, post_text=None, |
|---|
| 152 | topMargin = None, |
|---|
| 153 | letterhead_path=None): |
|---|
| 154 | """Render pdf admission letter. |
|---|
| 155 | """ |
|---|
| 156 | |
|---|
| 157 | def renderPDFTranscript(view, filename, student, |
|---|
| 158 | studentview, note, signatures, sigs_in_footer, |
|---|
| 159 | show_scans, topMargin, omit_fields, |
|---|
| 160 | tableheader, no_passport): |
|---|
| 161 | """Render pdf slip of a transcripts. |
|---|
| 162 | """ |
|---|
| 163 | |
|---|
| 164 | def renderPDFCourseticketsOverview( |
|---|
| 165 | view, name, session, data, lecturers, orientation, |
|---|
| 166 | title_length, note): |
|---|
| 167 | """Render pdf slip of course tickets for a lecturer. |
|---|
| 168 | """ |
|---|
| 169 | |
|---|
| 170 | def warnCreditsOOR(studylevel, course=None): |
|---|
| 171 | """Return message if credits are out of range. In the base |
|---|
| 172 | package only maximum credits is set. |
|---|
| 173 | """ |
|---|
| 174 | |
|---|
| 175 | def getBedCoordinates(bedticket): |
|---|
| 176 | """Return descriptive bed coordinates. |
|---|
| 177 | This method can be used to customize the `display_coordinates` |
|---|
| 178 | property method in order to display a |
|---|
| 179 | customary description of the bed space. |
|---|
| 180 | """ |
|---|
| 181 | |
|---|
| 182 | def clearance_disabled_message(student): |
|---|
| 183 | """Render message if clearance is disabled. |
|---|
| 184 | """ |
|---|
| 185 | |
|---|
| 186 | def updateCourseTickets(course): |
|---|
| 187 | """Udate registered course tickets if course |
|---|
| 188 | attributes were changed. |
|---|
| 189 | """ |
|---|
| 190 | |
|---|
| 191 | class IStudentsContainer(IKofaObject): |
|---|
| 192 | """A students container contains university students. |
|---|
| 193 | """ |
|---|
| 194 | def addStudent(student): |
|---|
| 195 | """Add an IStudent object and subcontainers. |
|---|
| 196 | """ |
|---|
| 197 | |
|---|
| 198 | unique_student_id = Attribute('A unique student id') |
|---|
| 199 | |
|---|
| 200 | class IStudentNavigation(IStudentNavigationBase): |
|---|
| 201 | """Interface needed for navigation and logging. This interface is |
|---|
| 202 | implemented by all content classes in the students section. |
|---|
| 203 | """ |
|---|
| 204 | student = Attribute('Student object of context') |
|---|
| 205 | |
|---|
| 206 | def writeLogMessage(view, message): |
|---|
| 207 | """Add an INFO message to students.log. |
|---|
| 208 | """ |
|---|
| 209 | |
|---|
| 210 | class IStudentBase(IKofaObject): |
|---|
| 211 | """Representation of student base data. |
|---|
| 212 | """ |
|---|
| 213 | history = Attribute('Object history, a list of messages') |
|---|
| 214 | state = Attribute('Registration state') |
|---|
| 215 | translated_state = Attribute('Real name of the registration state') |
|---|
| 216 | certcode = Attribute('Certificate code of any chosen study course') |
|---|
| 217 | depcode = Attribute('Department code of any chosen study course') |
|---|
| 218 | faccode = Attribute('Faculty code of any chosen study course') |
|---|
| 219 | entry_session = Attribute('Entry session') |
|---|
| 220 | current_session = Attribute('Current session') |
|---|
| 221 | current_level = Attribute('Current level') |
|---|
| 222 | current_mode = Attribute('Current mode') |
|---|
| 223 | current_verdict = Attribute('Current verdict') |
|---|
| 224 | fullname = Attribute('All name parts separated by hyphens') |
|---|
| 225 | display_fullname = Attribute('Fullname as displayed on pages') |
|---|
| 226 | is_postgrad = Attribute('True if postgraduate student') |
|---|
| 227 | is_special_postgrad = Attribute('True if special postgraduate student') |
|---|
| 228 | is_fresh = Attribute('True if fresh student') |
|---|
| 229 | before_payment = Attribute('True if no previous payment has to be made') |
|---|
| 230 | personal_data_expired = Attribute('True if personal data expired') |
|---|
| 231 | transcript_enabled = Attribute('True if transcript processing is enabled') |
|---|
| 232 | clearance_locked = Attribute('True if clearance form is locked') |
|---|
| 233 | studycourse_locked = Attribute( |
|---|
| 234 | 'True if nobody is allowed to change studycourse, studylecel or ' |
|---|
| 235 | 'course ticket data, neither through the UI nor via import') |
|---|
| 236 | |
|---|
| 237 | password = Attribute('Encrypted password') |
|---|
| 238 | temp_password = Attribute('Dictionary with user name, timestamp and encrypted password') |
|---|
| 239 | parents_password = Attribute('Dictionary with student_id, timestamp and encrypted password') |
|---|
| 240 | password_expired = Attribute('Can be used to force students to request a new password') |
|---|
| 241 | |
|---|
| 242 | suspended = schema.Bool( |
|---|
| 243 | title = _(u'Account suspended'), |
|---|
| 244 | default = False, |
|---|
| 245 | required = False, |
|---|
| 246 | ) |
|---|
| 247 | |
|---|
| 248 | suspended_comment = schema.Text( |
|---|
| 249 | title = _(u"Reasons for Deactivation"), |
|---|
| 250 | required = False, |
|---|
| 251 | description = _( |
|---|
| 252 | u'This message will be shown if and only if deactivated ' |
|---|
| 253 | 'students try to login.'), |
|---|
| 254 | ) |
|---|
| 255 | |
|---|
| 256 | flash_notice = schema.TextLine( |
|---|
| 257 | title = _(u'Flash Notice'), |
|---|
| 258 | required = False, |
|---|
| 259 | readonly = False, |
|---|
| 260 | description = _( |
|---|
| 261 | u'This single-line message will be shown in a flash box.'), |
|---|
| 262 | ) |
|---|
| 263 | |
|---|
| 264 | student_id = schema.TextLine( |
|---|
| 265 | title = _(u'Student Id'), |
|---|
| 266 | required = False, |
|---|
| 267 | ) |
|---|
| 268 | |
|---|
| 269 | firstname = schema.TextLine( |
|---|
| 270 | title = _(u'First Name'), |
|---|
| 271 | required = True, |
|---|
| 272 | ) |
|---|
| 273 | |
|---|
| 274 | middlename = schema.TextLine( |
|---|
| 275 | title = _(u'Middle Name'), |
|---|
| 276 | required = False, |
|---|
| 277 | ) |
|---|
| 278 | |
|---|
| 279 | lastname = schema.TextLine( |
|---|
| 280 | title = _(u'Last Name (Surname)'), |
|---|
| 281 | required = True, |
|---|
| 282 | ) |
|---|
| 283 | |
|---|
| 284 | sex = schema.Choice( |
|---|
| 285 | title = _(u'Gender'), |
|---|
| 286 | source = GenderSource(), |
|---|
| 287 | required = True, |
|---|
| 288 | ) |
|---|
| 289 | |
|---|
| 290 | reg_number = TextLineChoice( |
|---|
| 291 | title = _(u'Registration Number'), |
|---|
| 292 | required = True, |
|---|
| 293 | readonly = False, |
|---|
| 294 | source = contextual_reg_num_source, |
|---|
| 295 | ) |
|---|
| 296 | |
|---|
| 297 | matric_number = TextLineChoice( |
|---|
| 298 | title = _(u'Matriculation Number'), |
|---|
| 299 | required = False, |
|---|
| 300 | readonly = False, |
|---|
| 301 | source = contextual_mat_num_source, |
|---|
| 302 | ) |
|---|
| 303 | |
|---|
| 304 | adm_code = schema.TextLine( |
|---|
| 305 | title = _(u'PWD Activation Code'), |
|---|
| 306 | required = False, |
|---|
| 307 | readonly = False, |
|---|
| 308 | ) |
|---|
| 309 | |
|---|
| 310 | email = schema.ASCIILine( |
|---|
| 311 | title = _(u'Email'), |
|---|
| 312 | required = False, |
|---|
| 313 | constraint=validate_email, |
|---|
| 314 | ) |
|---|
| 315 | |
|---|
| 316 | phone = PhoneNumber( |
|---|
| 317 | title = _(u'Phone'), |
|---|
| 318 | required = False, |
|---|
| 319 | ) |
|---|
| 320 | |
|---|
| 321 | parents_email = schema.ASCIILine( |
|---|
| 322 | title = _(u"Parents' Email"), |
|---|
| 323 | required = False, |
|---|
| 324 | constraint=validate_email, |
|---|
| 325 | ) |
|---|
| 326 | |
|---|
| 327 | password_updated = schema.Datetime( |
|---|
| 328 | title = _(u'Password updated'), |
|---|
| 329 | required = False, |
|---|
| 330 | readonly = False, |
|---|
| 331 | ) |
|---|
| 332 | |
|---|
| 333 | def setTempPassword(user, password): |
|---|
| 334 | """Set a temporary password (LDAP-compatible) SSHA encoded for |
|---|
| 335 | officers. |
|---|
| 336 | """ |
|---|
| 337 | |
|---|
| 338 | def getTempPassword(): |
|---|
| 339 | """Check if a temporary password has been set and if it |
|---|
| 340 | is not expired. Return the temporary password if valid, |
|---|
| 341 | None otherwise. Unset the temporary password if expired. |
|---|
| 342 | """ |
|---|
| 343 | |
|---|
| 344 | def setParentsPassword(password): |
|---|
| 345 | """Set a parents password (LDAP-compatible) SSHA encoded for |
|---|
| 346 | parents. |
|---|
| 347 | """ |
|---|
| 348 | |
|---|
| 349 | def getParentsPassword(): |
|---|
| 350 | """Check if a parents password has been set and if it |
|---|
| 351 | is not expired. |
|---|
| 352 | |
|---|
| 353 | Return the parents password if valid, |
|---|
| 354 | None otherwise. Unset the parents password if expired. |
|---|
| 355 | """ |
|---|
| 356 | |
|---|
| 357 | def transfer(certificate, current_session, |
|---|
| 358 | current_level, current_verdict): |
|---|
| 359 | """ Creates a new studycourse and backups the old one. |
|---|
| 360 | """ |
|---|
| 361 | |
|---|
| 362 | def revert_transfer(): |
|---|
| 363 | """ Revert previous transfer. |
|---|
| 364 | """ |
|---|
| 365 | |
|---|
| 366 | class IUGStudentClearance(IKofaObject): |
|---|
| 367 | """Representation of undergraduate student clearance data. |
|---|
| 368 | """ |
|---|
| 369 | officer_comment = schema.Text( |
|---|
| 370 | title = _(u"Officer's Comment"), |
|---|
| 371 | required = False, |
|---|
| 372 | ) |
|---|
| 373 | |
|---|
| 374 | clr_code = schema.TextLine( |
|---|
| 375 | title = _(u'CLR Activation Code'), |
|---|
| 376 | required = False, |
|---|
| 377 | readonly = False, |
|---|
| 378 | ) |
|---|
| 379 | |
|---|
| 380 | date_of_birth = FormattedDate( |
|---|
| 381 | title = _(u'Date of Birth'), |
|---|
| 382 | required = True, |
|---|
| 383 | show_year = True, |
|---|
| 384 | ) |
|---|
| 385 | |
|---|
| 386 | nationality = schema.Choice( |
|---|
| 387 | vocabulary = nats_vocab, |
|---|
| 388 | title = _(u'Nationality'), |
|---|
| 389 | required = False, |
|---|
| 390 | ) |
|---|
| 391 | |
|---|
| 392 | class IPGStudentClearance(IUGStudentClearance): |
|---|
| 393 | """Representation of postgraduate student clearance data. |
|---|
| 394 | """ |
|---|
| 395 | employer = schema.TextLine( |
|---|
| 396 | title = _(u'Employer'), |
|---|
| 397 | required = False, |
|---|
| 398 | readonly = False, |
|---|
| 399 | ) |
|---|
| 400 | |
|---|
| 401 | class IStudentPersonal(IKofaObject): |
|---|
| 402 | """Representation of student personal data. |
|---|
| 403 | """ |
|---|
| 404 | personal_updated = schema.Datetime( |
|---|
| 405 | title = _(u'Updated'), |
|---|
| 406 | required = False, |
|---|
| 407 | readonly = False, |
|---|
| 408 | ) |
|---|
| 409 | |
|---|
| 410 | perm_address = schema.Text( |
|---|
| 411 | title = _(u'Permanent Address'), |
|---|
| 412 | required = False, |
|---|
| 413 | ) |
|---|
| 414 | |
|---|
| 415 | class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance, |
|---|
| 416 | IStudentPersonal): |
|---|
| 417 | """Representation of a student. |
|---|
| 418 | """ |
|---|
| 419 | |
|---|
| 420 | class IStudentPersonalEdit(IStudentPersonal): |
|---|
| 421 | """Interface for editing personal data by students. |
|---|
| 422 | Here we can repeat the fields from IStudentPersonal and set the |
|---|
| 423 | `required` if necessary. |
|---|
| 424 | """ |
|---|
| 425 | |
|---|
| 426 | perm_address = schema.Text( |
|---|
| 427 | title = _(u'Permanent Address'), |
|---|
| 428 | required = True, |
|---|
| 429 | ) |
|---|
| 430 | |
|---|
| 431 | class IStudentUpdateByRegNo(IStudent): |
|---|
| 432 | """Representation of a student. Skip regular reg_number validation. |
|---|
| 433 | """ |
|---|
| 434 | reg_number = schema.TextLine( |
|---|
| 435 | title = _(u'Registration Number'), |
|---|
| 436 | required = False, |
|---|
| 437 | ) |
|---|
| 438 | |
|---|
| 439 | class IStudentUpdateByMatricNo(IStudent): |
|---|
| 440 | """Representation of a student. Skip regular matric_number validation. |
|---|
| 441 | """ |
|---|
| 442 | matric_number = schema.TextLine( |
|---|
| 443 | title = _(u'Matriculation Number'), |
|---|
| 444 | required = False, |
|---|
| 445 | ) |
|---|
| 446 | |
|---|
| 447 | class IStudentRequestPW(IStudent): |
|---|
| 448 | """Representation of a student for first-time password request. |
|---|
| 449 | This interface is used when students use the requestpw page to |
|---|
| 450 | login for the the first time. |
|---|
| 451 | """ |
|---|
| 452 | number = schema.TextLine( |
|---|
| 453 | title = _(u'Registr. or Matric. Number'), |
|---|
| 454 | required = True, |
|---|
| 455 | ) |
|---|
| 456 | |
|---|
| 457 | email = schema.ASCIILine( |
|---|
| 458 | title = _(u'Email Address'), |
|---|
| 459 | required = True, |
|---|
| 460 | constraint=validate_email, |
|---|
| 461 | ) |
|---|
| 462 | |
|---|
| 463 | class IStudentStudyCourse(IKofaObject): |
|---|
| 464 | """Representation of student study course data. |
|---|
| 465 | """ |
|---|
| 466 | next_session_allowed = Attribute('True if the student can proceed to next session') |
|---|
| 467 | is_postgrad = Attribute('True if student is postgraduate student') |
|---|
| 468 | is_current = Attribute('True if the study course is the current course of studies') |
|---|
| 469 | is_previous = Attribute('True if the study course is the previous course of studies') |
|---|
| 470 | |
|---|
| 471 | certificate = schema.Choice( |
|---|
| 472 | title = _(u'Certificate'), |
|---|
| 473 | source = CertificateSource(), |
|---|
| 474 | required = False, |
|---|
| 475 | ) |
|---|
| 476 | |
|---|
| 477 | entry_mode = schema.Choice( |
|---|
| 478 | title = _(u'Entry Mode'), |
|---|
| 479 | source = StudyModeSource(), |
|---|
| 480 | required = True, |
|---|
| 481 | readonly = False, |
|---|
| 482 | ) |
|---|
| 483 | |
|---|
| 484 | entry_session = schema.Choice( |
|---|
| 485 | title = _(u'Entry Session'), |
|---|
| 486 | source = academic_sessions_vocab, |
|---|
| 487 | #default = datetime.now().year, |
|---|
| 488 | required = True, |
|---|
| 489 | readonly = False, |
|---|
| 490 | ) |
|---|
| 491 | |
|---|
| 492 | current_session = schema.Choice( |
|---|
| 493 | title = _(u'Current Session'), |
|---|
| 494 | source = academic_sessions_vocab, |
|---|
| 495 | required = True, |
|---|
| 496 | readonly = False, |
|---|
| 497 | ) |
|---|
| 498 | |
|---|
| 499 | current_level = schema.Choice( |
|---|
| 500 | title = _(u'Current Level'), |
|---|
| 501 | source = StudyLevelSource(), |
|---|
| 502 | required = False, |
|---|
| 503 | readonly = False, |
|---|
| 504 | ) |
|---|
| 505 | |
|---|
| 506 | current_verdict = schema.Choice( |
|---|
| 507 | title = _(u'Current Verdict'), |
|---|
| 508 | source = VerdictSource(), |
|---|
| 509 | default = '0', |
|---|
| 510 | required = False, |
|---|
| 511 | ) |
|---|
| 512 | |
|---|
| 513 | previous_verdict = schema.Choice( |
|---|
| 514 | title = _(u'Previous Verdict'), |
|---|
| 515 | source = VerdictSource(), |
|---|
| 516 | default = '0', |
|---|
| 517 | required = False, |
|---|
| 518 | ) |
|---|
| 519 | |
|---|
| 520 | def addStudentStudyLevel(cert, studylevel): |
|---|
| 521 | """Add a study level object. |
|---|
| 522 | """ |
|---|
| 523 | |
|---|
| 524 | def getTranscriptData(): |
|---|
| 525 | """Get a sorted list of dicts with level and course ticket data. |
|---|
| 526 | This method is used for transcripts. |
|---|
| 527 | """ |
|---|
| 528 | |
|---|
| 529 | class IStudentStudyCourseTransfer(IStudentStudyCourse): |
|---|
| 530 | """An interface used for student transfers. |
|---|
| 531 | """ |
|---|
| 532 | certificate = schema.Choice( |
|---|
| 533 | title = _(u'Certificate'), |
|---|
| 534 | source = CertificateSource(), |
|---|
| 535 | required = True, |
|---|
| 536 | ) |
|---|
| 537 | |
|---|
| 538 | current_level = schema.Choice( |
|---|
| 539 | title = _(u'Current Level'), |
|---|
| 540 | source = StudyLevelSource(), |
|---|
| 541 | required = True, |
|---|
| 542 | readonly = False, |
|---|
| 543 | ) |
|---|
| 544 | |
|---|
| 545 | entry_session = schema.Choice( |
|---|
| 546 | title = _(u'Entry Session'), |
|---|
| 547 | source = academic_sessions_vocab, |
|---|
| 548 | #default = datetime.now().year, |
|---|
| 549 | required = False, |
|---|
| 550 | readonly = False, |
|---|
| 551 | ) |
|---|
| 552 | |
|---|
| 553 | |
|---|
| 554 | IStudentStudyCourseTransfer['certificate'].order = IStudentStudyCourse[ |
|---|
| 555 | 'certificate'].order |
|---|
| 556 | IStudentStudyCourseTransfer['current_level'].order = IStudentStudyCourse[ |
|---|
| 557 | 'current_level'].order |
|---|
| 558 | |
|---|
| 559 | class IStudentVerdictUpdate(IKofaObject): |
|---|
| 560 | """A interface for verdict imports. |
|---|
| 561 | """ |
|---|
| 562 | current_verdict = schema.Choice( |
|---|
| 563 | title = _(u'Current Verdict'), |
|---|
| 564 | source = VerdictSource(), |
|---|
| 565 | required = True, |
|---|
| 566 | ) |
|---|
| 567 | |
|---|
| 568 | current_session = schema.Choice( |
|---|
| 569 | title = _(u'Current Session'), |
|---|
| 570 | source = academic_sessions_vocab, |
|---|
| 571 | required = True, |
|---|
| 572 | ) |
|---|
| 573 | |
|---|
| 574 | current_level = schema.Choice( |
|---|
| 575 | title = _(u'Current Level'), |
|---|
| 576 | source = StudyLevelSource(), |
|---|
| 577 | required = True, |
|---|
| 578 | ) |
|---|
| 579 | |
|---|
| 580 | bypass_validation = schema.Bool( |
|---|
| 581 | title = _(u'Bypass validation'), |
|---|
| 582 | required = False, |
|---|
| 583 | ) |
|---|
| 584 | |
|---|
| 585 | validated_by = schema.TextLine( |
|---|
| 586 | title = _(u'Validated by'), |
|---|
| 587 | required = False, |
|---|
| 588 | ) |
|---|
| 589 | |
|---|
| 590 | class IStudentStudyLevel(IKofaObject): |
|---|
| 591 | """A representation of student study level data. |
|---|
| 592 | """ |
|---|
| 593 | certcode = Attribute('The certificate code of the study course') |
|---|
| 594 | is_current_level = Attribute('True if level is current level of the student') |
|---|
| 595 | level_title = Attribute('Level title from source') |
|---|
| 596 | getSessionString = Attribute('Session title from source') |
|---|
| 597 | number_of_tickets = Attribute('Number of tickets contained in this level') |
|---|
| 598 | passed_params = Attribute('Information about passed and failed courses') |
|---|
| 599 | gpa_params_rectified = Attribute('Corrected sessional GPA parameters') |
|---|
| 600 | gpa_params = Attribute('GPA parameters for this level.') |
|---|
| 601 | cumulative_params = Attribute( |
|---|
| 602 | 'Cumulative GPA and other cumulative parameters for this level') |
|---|
| 603 | course_registration_forbidden = Attribute( |
|---|
| 604 | 'Return error message if course registration is forbidden') |
|---|
| 605 | |
|---|
| 606 | level = schema.Choice( |
|---|
| 607 | title = _(u'Level'), |
|---|
| 608 | source = StudyLevelSource(), |
|---|
| 609 | required = True, |
|---|
| 610 | readonly = False, |
|---|
| 611 | ) |
|---|
| 612 | |
|---|
| 613 | level_session = schema.Choice( |
|---|
| 614 | title = _(u'Session'), |
|---|
| 615 | source = academic_sessions_vocab, |
|---|
| 616 | required = True, |
|---|
| 617 | ) |
|---|
| 618 | |
|---|
| 619 | level_verdict = schema.Choice( |
|---|
| 620 | title = _(u'Verdict'), |
|---|
| 621 | source = VerdictSource(), |
|---|
| 622 | default = '0', |
|---|
| 623 | required = False, |
|---|
| 624 | ) |
|---|
| 625 | |
|---|
| 626 | validated_by = schema.TextLine( |
|---|
| 627 | title = _(u'Validated by'), |
|---|
| 628 | default = None, |
|---|
| 629 | required = False, |
|---|
| 630 | ) |
|---|
| 631 | |
|---|
| 632 | validation_date = schema.Datetime( |
|---|
| 633 | title = _(u'Validation Date'), |
|---|
| 634 | required = False, |
|---|
| 635 | readonly = False, |
|---|
| 636 | ) |
|---|
| 637 | |
|---|
| 638 | total_credits = schema.Int( |
|---|
| 639 | title = _(u'Total Credits'), |
|---|
| 640 | required = False, |
|---|
| 641 | readonly = True, |
|---|
| 642 | ) |
|---|
| 643 | |
|---|
| 644 | gpa = schema.TextLine( |
|---|
| 645 | title = _(u'Unrectified GPA'), |
|---|
| 646 | required = False, |
|---|
| 647 | readonly = True, |
|---|
| 648 | ) |
|---|
| 649 | |
|---|
| 650 | transcript_remark = schema.Text( |
|---|
| 651 | title = _(u'Transcript Remark'), |
|---|
| 652 | required = False, |
|---|
| 653 | readonly = False, |
|---|
| 654 | ) |
|---|
| 655 | |
|---|
| 656 | def addCourseTicket(ticket, course): |
|---|
| 657 | """Add a course ticket object. |
|---|
| 658 | """ |
|---|
| 659 | |
|---|
| 660 | def addCertCourseTickets(cert): |
|---|
| 661 | """Collect all certificate courses and create course |
|---|
| 662 | tickets automatically. |
|---|
| 663 | """ |
|---|
| 664 | |
|---|
| 665 | def updateCourseTicket(ticket, course): |
|---|
| 666 | """Updates a course ticket object and return code |
|---|
| 667 | if ticket has been invalidated. |
|---|
| 668 | """ |
|---|
| 669 | |
|---|
| 670 | class ICourseTicket(IKofaObject): |
|---|
| 671 | """A representation of course ticket data. |
|---|
| 672 | """ |
|---|
| 673 | certcode = Attribute('Certificate code of the study course') |
|---|
| 674 | level_session = Attribute('Session of the study level the ticket has been added to') |
|---|
| 675 | level = Attribute('Level value of the study level the ticket has been added to') |
|---|
| 676 | total_score = Attribute('Score') |
|---|
| 677 | grade = Attribute('Grade calculated from total score') |
|---|
| 678 | weight = Attribute('Weight calculated from total score') |
|---|
| 679 | removable_by_student = Attribute('True if student is allowed to remove the ticket') |
|---|
| 680 | editable_by_lecturer = Attribute('True if lecturer is allowed to edit the ticket') |
|---|
| 681 | |
|---|
| 682 | code = Attribute('Code of the original course') |
|---|
| 683 | |
|---|
| 684 | title = schema.TextLine( |
|---|
| 685 | title = _(u'Title'), |
|---|
| 686 | required = False, |
|---|
| 687 | ) |
|---|
| 688 | |
|---|
| 689 | fcode = schema.TextLine( |
|---|
| 690 | title = _(u'Faculty Code'), |
|---|
| 691 | required = False, |
|---|
| 692 | ) |
|---|
| 693 | |
|---|
| 694 | dcode = schema.TextLine( |
|---|
| 695 | title = _(u'Department Code'), |
|---|
| 696 | required = False, |
|---|
| 697 | ) |
|---|
| 698 | |
|---|
| 699 | semester = schema.Choice( |
|---|
| 700 | title = _(u'Semester/Term'), |
|---|
| 701 | source = SemesterSource(), |
|---|
| 702 | required = False, |
|---|
| 703 | ) |
|---|
| 704 | |
|---|
| 705 | ticket_session = schema.Choice( |
|---|
| 706 | title = _(u'Imported Session'), |
|---|
| 707 | source = academic_sessions_vocab, |
|---|
| 708 | required = False, |
|---|
| 709 | ) |
|---|
| 710 | |
|---|
| 711 | passmark = schema.Int( |
|---|
| 712 | title = _(u'Passmark'), |
|---|
| 713 | required = False, |
|---|
| 714 | ) |
|---|
| 715 | |
|---|
| 716 | credits = schema.Int( |
|---|
| 717 | title = _(u'Credits'), |
|---|
| 718 | required = False, |
|---|
| 719 | ) |
|---|
| 720 | |
|---|
| 721 | mandatory = schema.Bool( |
|---|
| 722 | title = _(u'Required'), |
|---|
| 723 | default = False, |
|---|
| 724 | required = False, |
|---|
| 725 | ) |
|---|
| 726 | |
|---|
| 727 | outstanding = schema.Bool( |
|---|
| 728 | title = _(u'Outstanding Course'), |
|---|
| 729 | default = False, |
|---|
| 730 | required = False, |
|---|
| 731 | ) |
|---|
| 732 | |
|---|
| 733 | course_category = schema.Choice( |
|---|
| 734 | title = _(u'Course Category'), |
|---|
| 735 | source = CourseCategorySource(), |
|---|
| 736 | required = False, |
|---|
| 737 | ) |
|---|
| 738 | |
|---|
| 739 | score = schema.Int( |
|---|
| 740 | title = _(u'Score'), |
|---|
| 741 | default = None, |
|---|
| 742 | required = False, |
|---|
| 743 | missing_value = None, |
|---|
| 744 | ) |
|---|
| 745 | |
|---|
| 746 | carry_over = schema.Bool( |
|---|
| 747 | title = _(u'Carry-over Course'), |
|---|
| 748 | default = False, |
|---|
| 749 | required = False, |
|---|
| 750 | ) |
|---|
| 751 | |
|---|
| 752 | automatic = schema.Bool( |
|---|
| 753 | title = _(u'Automatical Creation'), |
|---|
| 754 | default = False, |
|---|
| 755 | required = False, |
|---|
| 756 | ) |
|---|
| 757 | |
|---|
| 758 | class ICourseTicketAdd(IKofaObject): |
|---|
| 759 | """An interface for adding course tickets. |
|---|
| 760 | """ |
|---|
| 761 | course = schema.Choice( |
|---|
| 762 | title = _(u'Course'), |
|---|
| 763 | source = CourseSource(), |
|---|
| 764 | readonly = False, |
|---|
| 765 | ) |
|---|
| 766 | |
|---|
| 767 | class ICourseTicketImport(ICourseTicket): |
|---|
| 768 | """An interface for importing course results and nothing more. |
|---|
| 769 | """ |
|---|
| 770 | score = schema.Int( |
|---|
| 771 | title = _(u'Score'), |
|---|
| 772 | required = False, |
|---|
| 773 | readonly = False, |
|---|
| 774 | ) |
|---|
| 775 | |
|---|
| 776 | level_session = schema.Choice( |
|---|
| 777 | title = _(u'Level Session'), |
|---|
| 778 | source = academic_sessions_vocab, |
|---|
| 779 | required = False, |
|---|
| 780 | readonly = False, |
|---|
| 781 | ) |
|---|
| 782 | |
|---|
| 783 | class IStudentAccommodation(IKofaObject): |
|---|
| 784 | """A container for student accommodation objects. |
|---|
| 785 | """ |
|---|
| 786 | |
|---|
| 787 | desired_hostel = schema.TextLine( |
|---|
| 788 | title = _(u'Desired Hostel'), |
|---|
| 789 | required = False, |
|---|
| 790 | ) |
|---|
| 791 | |
|---|
| 792 | def addBedTicket(bedticket): |
|---|
| 793 | """Add a bed ticket object. |
|---|
| 794 | """ |
|---|
| 795 | |
|---|
| 796 | |
|---|
| 797 | class IBedTicket(IKofaObject): |
|---|
| 798 | """A representation of accommodation booking data. |
|---|
| 799 | """ |
|---|
| 800 | bed = Attribute('The bed object') |
|---|
| 801 | maint_payment_made = Attribute('True if maintenance payment is made') |
|---|
| 802 | |
|---|
| 803 | display_coordinates = schema.TextLine( |
|---|
| 804 | title = _(u'Allocated Bed'), |
|---|
| 805 | required = False, |
|---|
| 806 | readonly = True, |
|---|
| 807 | ) |
|---|
| 808 | |
|---|
| 809 | bed_coordinates = schema.TextLine( |
|---|
| 810 | title = u'', |
|---|
| 811 | required = True, |
|---|
| 812 | readonly = False, |
|---|
| 813 | ) |
|---|
| 814 | |
|---|
| 815 | bed_type = schema.TextLine( |
|---|
| 816 | title = _(u'Requested Bed Type'), |
|---|
| 817 | required = True, |
|---|
| 818 | readonly = False, |
|---|
| 819 | ) |
|---|
| 820 | |
|---|
| 821 | booking_session = schema.Choice( |
|---|
| 822 | title = _(u'Session'), |
|---|
| 823 | source = academic_sessions_vocab, |
|---|
| 824 | required = True, |
|---|
| 825 | readonly = False |
|---|
| 826 | ) |
|---|
| 827 | |
|---|
| 828 | booking_date = schema.Datetime( |
|---|
| 829 | title = _(u'Booking Date'), |
|---|
| 830 | required = False, |
|---|
| 831 | readonly = False, |
|---|
| 832 | ) |
|---|
| 833 | |
|---|
| 834 | booking_code = schema.TextLine( |
|---|
| 835 | title = _(u'Booking Activation Code'), |
|---|
| 836 | required = False, |
|---|
| 837 | readonly = False, |
|---|
| 838 | ) |
|---|
| 839 | |
|---|
| 840 | def getSessionString(): |
|---|
| 841 | """Returns the title of academic_sessions_vocab term of the session |
|---|
| 842 | when the bed was booked. |
|---|
| 843 | """ |
|---|
| 844 | |
|---|
| 845 | class IStudentPaymentsContainer(IPaymentsContainer): |
|---|
| 846 | """A container for student payment objects. |
|---|
| 847 | """ |
|---|
| 848 | |
|---|
| 849 | certificate = Attribute('Certificate to determine the correct p_level value') |
|---|
| 850 | |
|---|
| 851 | class IStudentOnlinePayment(IOnlinePayment): |
|---|
| 852 | """A student payment via payment gateways. |
|---|
| 853 | """ |
|---|
| 854 | |
|---|
| 855 | certificate = Attribute('Certificate to determine the correct p_level value') |
|---|
| 856 | student = Attribute('Student') |
|---|
| 857 | |
|---|
| 858 | p_current = schema.Bool( |
|---|
| 859 | title = _(u'Current Session Payment'), |
|---|
| 860 | default = True, |
|---|
| 861 | required = False, |
|---|
| 862 | ) |
|---|
| 863 | |
|---|
| 864 | p_level = schema.Choice( |
|---|
| 865 | title = _(u'Payment Level'), |
|---|
| 866 | source = StudyLevelSource(), |
|---|
| 867 | required = False, |
|---|
| 868 | ) |
|---|
| 869 | |
|---|
| 870 | def redeemTicket(): |
|---|
| 871 | """Either create an appropriate access code or trigger an action |
|---|
| 872 | directly. |
|---|
| 873 | """ |
|---|
| 874 | |
|---|
| 875 | def doAfterStudentPayment(): |
|---|
| 876 | """Process student after payment was made. |
|---|
| 877 | """ |
|---|
| 878 | |
|---|
| 879 | def doAfterStudentPaymentApproval(): |
|---|
| 880 | """Process student after payment was approved. |
|---|
| 881 | """ |
|---|
| 882 | |
|---|
| 883 | def approveStudentPayment(): |
|---|
| 884 | """Approve payment and process student. |
|---|
| 885 | """ |
|---|
| 886 | |
|---|
| 887 | IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[ |
|---|
| 888 | 'p_session'].order |
|---|
| 889 | |
|---|
| 890 | class IStudentPreviousPayment(IKofaObject): |
|---|
| 891 | """An interface for adding previous session payments. |
|---|
| 892 | """ |
|---|
| 893 | |
|---|
| 894 | p_category = schema.Choice( |
|---|
| 895 | title = _(u'Payment Category'), |
|---|
| 896 | default = u'schoolfee', |
|---|
| 897 | source = PreviousPaymentCategorySource(), |
|---|
| 898 | required = True, |
|---|
| 899 | ) |
|---|
| 900 | |
|---|
| 901 | p_session = schema.Choice( |
|---|
| 902 | title = _(u'Payment Session'), |
|---|
| 903 | source = academic_sessions_vocab, |
|---|
| 904 | required = True, |
|---|
| 905 | ) |
|---|
| 906 | |
|---|
| 907 | p_level = schema.Choice( |
|---|
| 908 | title = _(u'Payment Level'), |
|---|
| 909 | source = StudyLevelSource(), |
|---|
| 910 | required = True, |
|---|
| 911 | ) |
|---|
| 912 | |
|---|
| 913 | class IStudentBalancePayment(IKofaObject): |
|---|
| 914 | """An interface for adding balances. |
|---|
| 915 | """ |
|---|
| 916 | |
|---|
| 917 | p_category = schema.Choice( |
|---|
| 918 | title = _(u'Payment Category'), |
|---|
| 919 | default = u'schoolfee', |
|---|
| 920 | required = True, |
|---|
| 921 | source = BalancePaymentCategorySource(), |
|---|
| 922 | ) |
|---|
| 923 | |
|---|
| 924 | balance_session = schema.Choice( |
|---|
| 925 | title = _(u'Payment Session'), |
|---|
| 926 | source = academic_sessions_vocab, |
|---|
| 927 | required = True, |
|---|
| 928 | ) |
|---|
| 929 | |
|---|
| 930 | balance_level = schema.Choice( |
|---|
| 931 | title = _(u'Payment Level'), |
|---|
| 932 | source = StudyLevelSource(), |
|---|
| 933 | required = True, |
|---|
| 934 | ) |
|---|
| 935 | |
|---|
| 936 | balance_amount = schema.Float( |
|---|
| 937 | title = _(u'Balance Amount'), |
|---|
| 938 | default = None, |
|---|
| 939 | required = True, |
|---|
| 940 | readonly = False, |
|---|
| 941 | #description = _( |
|---|
| 942 | # u'Balance in Naira '), |
|---|
| 943 | ) |
|---|
| 944 | |
|---|
| 945 | class ICSVStudentExporter(ICSVExporter): |
|---|
| 946 | """A regular ICSVExporter that additionally supports exporting |
|---|
| 947 | data from a given student object. |
|---|
| 948 | """ |
|---|
| 949 | def get_filtered(site, **kw): |
|---|
| 950 | """Get a filtered set of students. |
|---|
| 951 | """ |
|---|
| 952 | |
|---|
| 953 | def get_selected(site, selected): |
|---|
| 954 | """Get set of selected students. |
|---|
| 955 | """ |
|---|
| 956 | |
|---|
| 957 | def export_student(student, filepath=None): |
|---|
| 958 | """Export data for a given student. |
|---|
| 959 | """ |
|---|
| 960 | |
|---|
| 961 | def export_filtered(site, filepath=None, **kw): |
|---|
| 962 | """Export data for filtered set of students. |
|---|
| 963 | """ |
|---|
| 964 | |
|---|
| 965 | def export_selected(site, filepath=None, **kw): |
|---|
| 966 | """Export data for selected set of students. |
|---|
| 967 | """ |
|---|