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