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