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