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