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