[7191] | 1 | ## $Id: interfaces.py 9563 2012-11-06 20:29:35Z 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 ( |
---|
[8409] | 25 | IKofaObject, academic_sessions_vocab, validate_email, ICSVExporter) |
---|
[7811] | 26 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
[8176] | 27 | from waeup.kofa.schema import TextLineChoice, FormattedDate, PhoneNumber |
---|
[7811] | 28 | from waeup.kofa.students.vocabularies import ( |
---|
[7915] | 29 | StudyLevelSource, contextual_reg_num_source, contextual_mat_num_source, |
---|
[9420] | 30 | GenderSource, nats_vocab |
---|
[7915] | 31 | ) |
---|
[8160] | 32 | from waeup.kofa.payments.interfaces import ( |
---|
[8174] | 33 | IPaymentsContainer, IOnlinePayment) |
---|
[7915] | 34 | from waeup.kofa.university.vocabularies import ( |
---|
[9420] | 35 | CourseSource, StudyModeSource, CertificateSource, SemesterSource) |
---|
[6621] | 36 | |
---|
[7620] | 37 | # VerdictSource can't be placed into the vocabularies module because it |
---|
| 38 | # requires importing IStudentsUtils which then leads to circular imports. |
---|
| 39 | class VerdictSource(BasicContextualSourceFactory): |
---|
| 40 | """A verdicts source delivers all verdicts provided |
---|
| 41 | in the portal. |
---|
| 42 | """ |
---|
| 43 | def getValues(self, context): |
---|
[7841] | 44 | verdicts_dict = getUtility(IStudentsUtils).VERDICTS_DICT |
---|
[8820] | 45 | return sorted(verdicts_dict.keys()) |
---|
[7620] | 46 | |
---|
| 47 | def getToken(self, context, value): |
---|
| 48 | return value |
---|
| 49 | |
---|
| 50 | def getTitle(self, context, value): |
---|
[7841] | 51 | verdicts_dict = getUtility(IStudentsUtils).VERDICTS_DICT |
---|
[8820] | 52 | if value != '0': |
---|
| 53 | return verdicts_dict[value] + ' (%s)' % value |
---|
[7688] | 54 | return verdicts_dict[value] |
---|
[7620] | 55 | |
---|
[7681] | 56 | |
---|
[7150] | 57 | class IStudentsUtils(Interface): |
---|
| 58 | """A collection of methods which are subject to customization. |
---|
| 59 | |
---|
| 60 | """ |
---|
[7841] | 61 | def setReturningData(student): |
---|
| 62 | """ This method defines what happens after school fee payment |
---|
| 63 | depending on the student's senate verdict. |
---|
| 64 | |
---|
| 65 | In the base configuration current level is always increased |
---|
| 66 | by 100 no matter which verdict has been assigned. |
---|
| 67 | """ |
---|
| 68 | |
---|
[9148] | 69 | def setPaymentDetails(category, student, previous_session=None, |
---|
| 70 | previous_level=None,): |
---|
[8595] | 71 | """Create Payment object and set the payment data of a student for |
---|
| 72 | the payment category specified. |
---|
[7150] | 73 | |
---|
| 74 | """ |
---|
| 75 | |
---|
[7186] | 76 | def getAccommodation_details(student): |
---|
[7150] | 77 | """Determine the accommodation dates of a student. |
---|
| 78 | |
---|
| 79 | """ |
---|
| 80 | |
---|
[7186] | 81 | def selectBed(available_beds): |
---|
[7150] | 82 | """Select a bed from a list of available beds. |
---|
| 83 | |
---|
| 84 | In the standard configuration we select the first bed found, |
---|
| 85 | but can also randomize the selection if we like. |
---|
| 86 | """ |
---|
| 87 | |
---|
[7186] | 88 | def renderPDF(view, subject='', filename='slip.pdf',): |
---|
[7150] | 89 | """Render pdf slips for various pages. |
---|
| 90 | |
---|
| 91 | """ |
---|
| 92 | |
---|
[7819] | 93 | class IStudentsContainer(IKofaObject): |
---|
[7096] | 94 | """A students container contains university students. |
---|
[6692] | 95 | |
---|
| 96 | """ |
---|
| 97 | def addStudent(student): |
---|
| 98 | """Add an IStudent object and subcontainers. |
---|
| 99 | |
---|
| 100 | """ |
---|
| 101 | |
---|
| 102 | def archive(id=None): |
---|
| 103 | """Create on-dist archive of students. |
---|
| 104 | |
---|
| 105 | If id is `None`, all students are archived. |
---|
| 106 | |
---|
| 107 | If id contains a single id string, only the respective |
---|
| 108 | students are archived. |
---|
| 109 | |
---|
| 110 | If id contains a list of id strings all of the respective |
---|
| 111 | students types are saved to disk. |
---|
| 112 | """ |
---|
| 113 | |
---|
| 114 | def clear(id=None, archive=True): |
---|
| 115 | """Remove students of type given by 'id'. |
---|
| 116 | |
---|
| 117 | Optionally archive the students. |
---|
| 118 | |
---|
| 119 | If id is `None`, all students are archived. |
---|
| 120 | |
---|
| 121 | If id contains a single id string, only the respective |
---|
| 122 | students are archived. |
---|
| 123 | |
---|
| 124 | If id contains a list of id strings all of the respective |
---|
| 125 | student types are saved to disk. |
---|
| 126 | |
---|
| 127 | If `archive` is ``False`` none of the archive-handling is done |
---|
| 128 | and respective students are simply removed from the |
---|
| 129 | database. |
---|
| 130 | """ |
---|
| 131 | |
---|
[8408] | 132 | unique_student_id = Attribute("""A unique student id.""") |
---|
| 133 | |
---|
[9217] | 134 | class IStudentNavigation(IStudentNavigationBase): |
---|
[8735] | 135 | """Interface needed for student navigation, logging, etc. |
---|
[7150] | 136 | |
---|
[6642] | 137 | """ |
---|
[8736] | 138 | student = Attribute('Student object of context.') |
---|
[7150] | 139 | |
---|
[8735] | 140 | def writeLogMessage(view, message): |
---|
| 141 | """Write a view specific log message into students.log. |
---|
| 142 | |
---|
| 143 | """ |
---|
| 144 | |
---|
[7819] | 145 | class IStudentBase(IKofaObject): |
---|
[6631] | 146 | """Representation of student base data. |
---|
[7150] | 147 | |
---|
[6621] | 148 | """ |
---|
[7062] | 149 | history = Attribute('Object history, a list of messages') |
---|
[6637] | 150 | state = Attribute('Returns the registration state of a student') |
---|
[6699] | 151 | password = Attribute('Encrypted password of a student') |
---|
[9334] | 152 | temp_password = Attribute( |
---|
| 153 | 'Dictionary with user name, timestamp and encrypted password') |
---|
[7203] | 154 | certcode = Attribute('The certificate code of any chosen study course') |
---|
| 155 | depcode = Attribute('The department code of any chosen study course') |
---|
| 156 | faccode = Attribute('The faculty code of any chosen study course') |
---|
[7062] | 157 | current_session = Attribute('The current session of the student') |
---|
[9142] | 158 | current_level = Attribute('The current level of the student') |
---|
[7641] | 159 | current_mode = Attribute('The current mode of the student') |
---|
[9182] | 160 | current_verdict = Attribute('The current verdict of the student') |
---|
[7364] | 161 | fullname = Attribute('All name parts separated by hyphens') |
---|
| 162 | display_fullname = Attribute('The fullname of an applicant') |
---|
[8969] | 163 | is_postgrad = Attribute('True if postgraduate student') |
---|
[6637] | 164 | |
---|
[8983] | 165 | suspended = schema.Bool( |
---|
| 166 | title = _(u'Account suspended'), |
---|
| 167 | default = False, |
---|
[9035] | 168 | required = False, |
---|
[8983] | 169 | ) |
---|
| 170 | |
---|
[6665] | 171 | student_id = schema.TextLine( |
---|
[7723] | 172 | title = _(u'Student Id'), |
---|
[6849] | 173 | required = False, |
---|
[6665] | 174 | ) |
---|
| 175 | |
---|
[7357] | 176 | firstname = schema.TextLine( |
---|
[7723] | 177 | title = _(u'First Name'), |
---|
[6621] | 178 | required = True, |
---|
| 179 | ) |
---|
| 180 | |
---|
[7357] | 181 | middlename = schema.TextLine( |
---|
[7723] | 182 | title = _(u'Middle Name'), |
---|
[7357] | 183 | required = False, |
---|
| 184 | ) |
---|
| 185 | |
---|
| 186 | lastname = schema.TextLine( |
---|
[7723] | 187 | title = _(u'Last Name (Surname)'), |
---|
[7357] | 188 | required = True, |
---|
| 189 | ) |
---|
| 190 | |
---|
[6996] | 191 | sex = schema.Choice( |
---|
[7723] | 192 | title = _(u'Sex'), |
---|
[6996] | 193 | source = GenderSource(), |
---|
| 194 | required = True, |
---|
| 195 | ) |
---|
| 196 | |
---|
[6788] | 197 | reg_number = TextLineChoice( |
---|
[7723] | 198 | title = _(u'Registration Number'), |
---|
[6696] | 199 | required = True, |
---|
| 200 | readonly = False, |
---|
[6788] | 201 | source = contextual_reg_num_source, |
---|
[6696] | 202 | ) |
---|
| 203 | |
---|
[6788] | 204 | matric_number = TextLineChoice( |
---|
[7723] | 205 | title = _(u'Matriculation Number'), |
---|
[6750] | 206 | required = False, |
---|
| 207 | readonly = False, |
---|
[6788] | 208 | source = contextual_mat_num_source, |
---|
[6750] | 209 | ) |
---|
| 210 | |
---|
[6769] | 211 | adm_code = schema.TextLine( |
---|
[7723] | 212 | title = _(u'PWD Activation Code'), |
---|
[6769] | 213 | required = False, |
---|
[8977] | 214 | readonly = False, |
---|
[6769] | 215 | ) |
---|
| 216 | |
---|
[7133] | 217 | email = schema.ASCIILine( |
---|
[7723] | 218 | title = _(u'Email'), |
---|
[7133] | 219 | required = False, |
---|
| 220 | constraint=validate_email, |
---|
| 221 | ) |
---|
[8176] | 222 | phone = PhoneNumber( |
---|
[7723] | 223 | title = _(u'Phone'), |
---|
[7331] | 224 | description = u'', |
---|
[7133] | 225 | required = False, |
---|
| 226 | ) |
---|
| 227 | |
---|
[9334] | 228 | def setTempPassword(user, password): |
---|
| 229 | """Set a temporary password (LDAP-compatible) SSHA encoded for |
---|
| 230 | officers. |
---|
| 231 | |
---|
| 232 | """ |
---|
| 233 | |
---|
| 234 | def getTempPassword(): |
---|
| 235 | """Check if a temporary password has been set and if it |
---|
| 236 | is not expired. |
---|
| 237 | |
---|
| 238 | Return the temporary password if valid, |
---|
| 239 | None otherwise. Unset the temporary password if expired. |
---|
| 240 | """ |
---|
| 241 | |
---|
[9131] | 242 | def transfer(certificate, current_session, |
---|
| 243 | current_level, current_verdict): |
---|
| 244 | """ Creates a new studycourse and backups the old one. |
---|
| 245 | |
---|
| 246 | """ |
---|
| 247 | |
---|
[7993] | 248 | class IUGStudentClearance(IKofaObject): |
---|
| 249 | """Representation of undergraduate student clearance data. |
---|
[7150] | 250 | |
---|
[6631] | 251 | """ |
---|
[9543] | 252 | officer_comment = schema.Text( |
---|
| 253 | title = _(u"Officer's Comment"), |
---|
| 254 | required = False, |
---|
[6631] | 255 | ) |
---|
| 256 | |
---|
[6695] | 257 | clearance_locked = schema.Bool( |
---|
[7723] | 258 | title = _(u'Clearance form locked'), |
---|
[6695] | 259 | default = False, |
---|
[9035] | 260 | required = False, |
---|
[6695] | 261 | ) |
---|
| 262 | |
---|
[6769] | 263 | clr_code = schema.TextLine( |
---|
[7723] | 264 | title = _(u'CLR Activation Code'), |
---|
[6769] | 265 | required = False, |
---|
[8977] | 266 | readonly = False, |
---|
[6769] | 267 | ) |
---|
| 268 | |
---|
[9543] | 269 | date_of_birth = FormattedDate( |
---|
| 270 | title = _(u'Date of Birth'), |
---|
| 271 | required = True, |
---|
| 272 | show_year = True, |
---|
| 273 | ) |
---|
| 274 | |
---|
[7523] | 275 | nationality = schema.Choice( |
---|
[8069] | 276 | vocabulary = nats_vocab, |
---|
[7723] | 277 | title = _(u'Nationality'), |
---|
[7983] | 278 | required = False, |
---|
[7523] | 279 | ) |
---|
| 280 | |
---|
[7993] | 281 | class IPGStudentClearance(IUGStudentClearance): |
---|
| 282 | """Representation of postgraduate student clearance data. |
---|
| 283 | |
---|
| 284 | """ |
---|
| 285 | employer = schema.TextLine( |
---|
| 286 | title = _(u'Employer'), |
---|
| 287 | required = False, |
---|
| 288 | readonly = False, |
---|
| 289 | ) |
---|
| 290 | |
---|
[7819] | 291 | class IStudentPersonal(IKofaObject): |
---|
[6631] | 292 | """Representation of student personal data. |
---|
[7150] | 293 | |
---|
[6631] | 294 | """ |
---|
[9543] | 295 | personal_updated = schema.Datetime( |
---|
| 296 | title = _(u'Updated'), |
---|
| 297 | required = False, |
---|
| 298 | readonly = False, |
---|
| 299 | ) |
---|
| 300 | |
---|
[6651] | 301 | perm_address = schema.Text( |
---|
[7723] | 302 | title = _(u'Permanent Address'), |
---|
[6631] | 303 | required = False, |
---|
| 304 | ) |
---|
| 305 | |
---|
[8008] | 306 | class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance, |
---|
| 307 | IStudentPersonal): |
---|
[6631] | 308 | """Representation of a student. |
---|
[7150] | 309 | |
---|
[6631] | 310 | """ |
---|
| 311 | |
---|
[9563] | 312 | class IStudentPersonalEdit(IStudentPersonal): |
---|
| 313 | """Interface for editing personal data by students. |
---|
| 314 | |
---|
| 315 | Here we can repeat the fields from IStudentPersonal and set the |
---|
| 316 | `required` if necessary. |
---|
| 317 | """ |
---|
| 318 | |
---|
| 319 | perm_address = schema.Text( |
---|
| 320 | title = _(u'Permanent Address'), |
---|
| 321 | required = True, |
---|
| 322 | ) |
---|
| 323 | |
---|
[6849] | 324 | class IStudentUpdateByRegNo(IStudent): |
---|
| 325 | """Representation of a student. Skip regular reg_number validation. |
---|
[7150] | 326 | |
---|
[6849] | 327 | """ |
---|
| 328 | reg_number = schema.TextLine( |
---|
[7723] | 329 | title = _(u'Registration Number'), |
---|
[6849] | 330 | required = False, |
---|
| 331 | ) |
---|
| 332 | |
---|
| 333 | class IStudentUpdateByMatricNo(IStudent): |
---|
| 334 | """Representation of a student. Skip regular matric_number validation. |
---|
[7150] | 335 | |
---|
[6849] | 336 | """ |
---|
| 337 | matric_number = schema.TextLine( |
---|
[7723] | 338 | title = _(u'Matriculation Number'), |
---|
[6849] | 339 | required = False, |
---|
| 340 | ) |
---|
| 341 | |
---|
[8779] | 342 | class IStudentRequestPW(IStudent): |
---|
| 343 | """Representation of an student for first-time password request. |
---|
| 344 | |
---|
| 345 | This interface is used when students use the requestpw page to |
---|
| 346 | login for the the first time. |
---|
| 347 | """ |
---|
[8854] | 348 | number = schema.TextLine( |
---|
| 349 | title = _(u'Registr. or Matric. Number'), |
---|
[8779] | 350 | required = True, |
---|
| 351 | ) |
---|
| 352 | |
---|
| 353 | firstname = schema.TextLine( |
---|
| 354 | title = _(u'First Name'), |
---|
| 355 | required = True, |
---|
| 356 | ) |
---|
| 357 | |
---|
| 358 | email = schema.ASCIILine( |
---|
| 359 | title = _(u'Email Address'), |
---|
| 360 | required = True, |
---|
| 361 | constraint=validate_email, |
---|
| 362 | ) |
---|
| 363 | |
---|
[7819] | 364 | class IStudentStudyCourse(IKofaObject): |
---|
[6633] | 365 | """A container for student study levels. |
---|
| 366 | |
---|
| 367 | """ |
---|
[6648] | 368 | certificate = schema.Choice( |
---|
[7723] | 369 | title = _(u'Certificate'), |
---|
[6648] | 370 | source = CertificateSource(), |
---|
[7209] | 371 | required = False, |
---|
[6633] | 372 | ) |
---|
[6635] | 373 | |
---|
[6996] | 374 | entry_mode = schema.Choice( |
---|
[7723] | 375 | title = _(u'Entry Mode'), |
---|
[7681] | 376 | source = StudyModeSource(), |
---|
[6996] | 377 | required = True, |
---|
| 378 | readonly = False, |
---|
| 379 | ) |
---|
| 380 | |
---|
| 381 | entry_session = schema.Choice( |
---|
[7723] | 382 | title = _(u'Entry Session'), |
---|
[6996] | 383 | source = academic_sessions_vocab, |
---|
[7425] | 384 | #default = datetime.now().year, |
---|
[6996] | 385 | required = True, |
---|
| 386 | readonly = False, |
---|
| 387 | ) |
---|
| 388 | |
---|
[6724] | 389 | current_session = schema.Choice( |
---|
[7723] | 390 | title = _(u'Current Session'), |
---|
[6744] | 391 | source = academic_sessions_vocab, |
---|
[6724] | 392 | required = True, |
---|
[6996] | 393 | readonly = False, |
---|
[6724] | 394 | ) |
---|
| 395 | |
---|
| 396 | current_level = schema.Choice( |
---|
[7723] | 397 | title = _(u'Current Level'), |
---|
[6725] | 398 | source = StudyLevelSource(), |
---|
| 399 | required = False, |
---|
[6996] | 400 | readonly = False, |
---|
[6724] | 401 | ) |
---|
| 402 | |
---|
| 403 | current_verdict = schema.Choice( |
---|
[7723] | 404 | title = _(u'Current Verdict'), |
---|
[7619] | 405 | source = VerdictSource(), |
---|
[8820] | 406 | default = '0', |
---|
[6725] | 407 | required = False, |
---|
[6724] | 408 | ) |
---|
| 409 | |
---|
| 410 | previous_verdict = schema.Choice( |
---|
[7723] | 411 | title = _(u'Previous Verdict'), |
---|
[7619] | 412 | source = VerdictSource(), |
---|
[8820] | 413 | default = '0', |
---|
[6725] | 414 | required = False, |
---|
[6724] | 415 | ) |
---|
| 416 | |
---|
[9138] | 417 | class IStudentStudyCourseTransfer(IStudentStudyCourse): |
---|
| 418 | """An student transfers. |
---|
| 419 | |
---|
| 420 | """ |
---|
| 421 | |
---|
| 422 | certificate = schema.Choice( |
---|
| 423 | title = _(u'Certificate'), |
---|
| 424 | source = CertificateSource(), |
---|
| 425 | required = True, |
---|
| 426 | ) |
---|
| 427 | |
---|
| 428 | current_level = schema.Choice( |
---|
| 429 | title = _(u'Current Level'), |
---|
| 430 | source = StudyLevelSource(), |
---|
| 431 | required = True, |
---|
| 432 | readonly = False, |
---|
| 433 | ) |
---|
| 434 | |
---|
| 435 | |
---|
| 436 | IStudentStudyCourseTransfer['certificate'].order = IStudentStudyCourse[ |
---|
| 437 | 'certificate'].order |
---|
| 438 | IStudentStudyCourseTransfer['current_level'].order = IStudentStudyCourse[ |
---|
| 439 | 'current_level'].order |
---|
| 440 | |
---|
[7951] | 441 | class IStudentVerdictUpdate(IKofaObject): |
---|
| 442 | """A interface for verdict imports. |
---|
| 443 | |
---|
| 444 | """ |
---|
| 445 | |
---|
| 446 | current_verdict = schema.Choice( |
---|
| 447 | title = _(u'Current Verdict'), |
---|
| 448 | source = VerdictSource(), |
---|
| 449 | required = True, |
---|
| 450 | ) |
---|
| 451 | |
---|
| 452 | current_session = schema.Choice( |
---|
| 453 | title = _(u'Current Session'), |
---|
| 454 | source = academic_sessions_vocab, |
---|
| 455 | required = True, |
---|
| 456 | ) |
---|
| 457 | |
---|
| 458 | current_level = schema.Choice( |
---|
| 459 | title = _(u'Current Level'), |
---|
| 460 | source = StudyLevelSource(), |
---|
| 461 | required = True, |
---|
| 462 | ) |
---|
| 463 | |
---|
[9296] | 464 | bypass_validation = schema.Bool( |
---|
| 465 | title = _(u'Bypass validation'), |
---|
| 466 | required = False, |
---|
| 467 | ) |
---|
| 468 | |
---|
| 469 | validated_by = schema.TextLine( |
---|
| 470 | title = _(u'Validated by'), |
---|
| 471 | required = False, |
---|
| 472 | ) |
---|
| 473 | |
---|
[7819] | 474 | class IStudentStudyLevel(IKofaObject): |
---|
[6774] | 475 | """A container for course tickets. |
---|
| 476 | |
---|
| 477 | """ |
---|
| 478 | level = Attribute('The level code') |
---|
[9235] | 479 | number_of_tickets = Attribute('Number of tickets contained in this level') |
---|
[9253] | 480 | certcode = Attribute('The certificate code of the study course') |
---|
[9257] | 481 | is_current_level = Attribute('Is this level the current level of the student?') |
---|
[9532] | 482 | total_credits = Attribute('Total of all ticket credits in this study level.') |
---|
[6774] | 483 | |
---|
[6793] | 484 | level_session = schema.Choice( |
---|
[7723] | 485 | title = _(u'Session'), |
---|
[6793] | 486 | source = academic_sessions_vocab, |
---|
[9437] | 487 | required = True, |
---|
[6793] | 488 | ) |
---|
[6781] | 489 | |
---|
[6793] | 490 | level_verdict = schema.Choice( |
---|
[7723] | 491 | title = _(u'Verdict'), |
---|
[7619] | 492 | source = VerdictSource(), |
---|
[8820] | 493 | default = '0', |
---|
[6793] | 494 | required = False, |
---|
| 495 | ) |
---|
| 496 | |
---|
[9161] | 497 | validated_by = schema.TextLine( |
---|
| 498 | title = _(u'Validated by'), |
---|
| 499 | default = None, |
---|
| 500 | required = False, |
---|
| 501 | ) |
---|
| 502 | |
---|
| 503 | validation_date = schema.Datetime( |
---|
| 504 | title = _(u'Validation Date'), |
---|
| 505 | required = False, |
---|
| 506 | readonly = False, |
---|
| 507 | ) |
---|
| 508 | |
---|
[8920] | 509 | def addCourseTicket(ticket, course): |
---|
[8182] | 510 | """Add a course ticket object. |
---|
| 511 | """ |
---|
| 512 | |
---|
[9501] | 513 | def addCertCourseTickets(cert): |
---|
| 514 | """Collect all certificate courses and create course |
---|
| 515 | tickets automatically. |
---|
| 516 | """ |
---|
| 517 | |
---|
[7819] | 518 | class ICourseTicket(IKofaObject): |
---|
[9420] | 519 | """An interface for course tickets. |
---|
[6781] | 520 | |
---|
| 521 | """ |
---|
[6783] | 522 | code = Attribute('code of the original course') |
---|
[9253] | 523 | certcode = Attribute('certificate code of the study course') |
---|
[6781] | 524 | |
---|
[9420] | 525 | title = schema.TextLine( |
---|
| 526 | title = _(u'Title'), |
---|
| 527 | required = False, |
---|
| 528 | ) |
---|
| 529 | |
---|
| 530 | fcode = schema.TextLine( |
---|
| 531 | title = _(u'Faculty Code'), |
---|
| 532 | required = False, |
---|
| 533 | ) |
---|
| 534 | |
---|
| 535 | dcode = schema.TextLine( |
---|
| 536 | title = _(u'Department Code'), |
---|
| 537 | required = False, |
---|
| 538 | ) |
---|
| 539 | |
---|
| 540 | semester = schema.Choice( |
---|
| 541 | title = _(u'Semester/Term'), |
---|
| 542 | source = SemesterSource(), |
---|
| 543 | required = False, |
---|
| 544 | ) |
---|
| 545 | |
---|
| 546 | passmark = schema.Int( |
---|
| 547 | title = _(u'Passmark'), |
---|
| 548 | required = False, |
---|
| 549 | ) |
---|
| 550 | |
---|
| 551 | credits = schema.Int( |
---|
| 552 | title = _(u'Credits'), |
---|
| 553 | required = False, |
---|
| 554 | ) |
---|
| 555 | |
---|
[7665] | 556 | mandatory = schema.Bool( |
---|
[9320] | 557 | title = _(u'Required'), |
---|
[6795] | 558 | default = False, |
---|
| 559 | required = False, |
---|
| 560 | ) |
---|
| 561 | |
---|
[6781] | 562 | score = schema.Int( |
---|
[7723] | 563 | title = _(u'Score'), |
---|
[6781] | 564 | default = 0, |
---|
| 565 | required = False, |
---|
| 566 | ) |
---|
| 567 | |
---|
[7661] | 568 | carry_over = schema.Bool( |
---|
[7723] | 569 | title = _(u'Carry-over Course'), |
---|
[7661] | 570 | default = False, |
---|
| 571 | required = False, |
---|
| 572 | ) |
---|
| 573 | |
---|
[9420] | 574 | automatic = schema.Bool( |
---|
| 575 | title = _(u'Automatical Creation'), |
---|
| 576 | default = False, |
---|
[9316] | 577 | required = False, |
---|
| 578 | ) |
---|
| 579 | |
---|
| 580 | |
---|
[7633] | 581 | def getLevel(): |
---|
| 582 | """Returns the id of the level the ticket has been added to. |
---|
| 583 | """ |
---|
| 584 | |
---|
| 585 | def getLevelSession(): |
---|
| 586 | """Returns the session of the level the ticket has been added to. |
---|
| 587 | """ |
---|
| 588 | |
---|
[9420] | 589 | class ICourseTicketAdd(IKofaObject): |
---|
[7150] | 590 | """An interface for adding course tickets. |
---|
[6795] | 591 | |
---|
| 592 | """ |
---|
| 593 | course = schema.Choice( |
---|
[7723] | 594 | title = _(u'Course'), |
---|
[6795] | 595 | source = CourseSource(), |
---|
| 596 | readonly = False, |
---|
| 597 | ) |
---|
| 598 | |
---|
[9420] | 599 | class ICourseTicketImport(ICourseTicket): |
---|
| 600 | """An interface for importing course results and nothing more. |
---|
| 601 | |
---|
| 602 | """ |
---|
| 603 | score = schema.Int( |
---|
| 604 | title = _(u'Score'), |
---|
| 605 | required = False, |
---|
| 606 | readonly = False, |
---|
| 607 | ) |
---|
| 608 | |
---|
| 609 | level_session = schema.Choice( |
---|
| 610 | title = _(u'Level Session'), |
---|
| 611 | source = academic_sessions_vocab, |
---|
| 612 | required = False, |
---|
| 613 | readonly = False, |
---|
| 614 | ) |
---|
| 615 | |
---|
[7819] | 616 | class IStudentAccommodation(IKofaObject): |
---|
[6635] | 617 | """A container for student accommodation objects. |
---|
| 618 | |
---|
| 619 | """ |
---|
| 620 | |
---|
[9423] | 621 | def addBedTicket(bedticket): |
---|
| 622 | """Add a bed ticket object. |
---|
| 623 | """ |
---|
| 624 | |
---|
| 625 | |
---|
[7819] | 626 | class IBedTicket(IKofaObject): |
---|
[6989] | 627 | """A ticket for accommodation booking. |
---|
| 628 | |
---|
| 629 | """ |
---|
[6996] | 630 | bed = Attribute('The bed object.') |
---|
| 631 | |
---|
| 632 | bed_coordinates = schema.TextLine( |
---|
[9424] | 633 | title = _(u'Allocated Bed'), |
---|
[9423] | 634 | required = True, |
---|
[7014] | 635 | readonly = False, |
---|
[6992] | 636 | ) |
---|
| 637 | |
---|
[6996] | 638 | bed_type = schema.TextLine( |
---|
[9424] | 639 | title = _(u'Requested Bed Type'), |
---|
[9423] | 640 | required = True, |
---|
[7014] | 641 | readonly = False, |
---|
[6996] | 642 | ) |
---|
| 643 | |
---|
[6992] | 644 | booking_session = schema.Choice( |
---|
[7723] | 645 | title = _(u'Session'), |
---|
[6992] | 646 | source = academic_sessions_vocab, |
---|
| 647 | required = True, |
---|
[7014] | 648 | readonly = True, |
---|
[6992] | 649 | ) |
---|
| 650 | |
---|
[8170] | 651 | booking_date = schema.Datetime( |
---|
[7723] | 652 | title = _(u'Booking Date'), |
---|
[6992] | 653 | required = False, |
---|
[7014] | 654 | readonly = True, |
---|
[6992] | 655 | ) |
---|
| 656 | |
---|
| 657 | booking_code = schema.TextLine( |
---|
[7723] | 658 | title = _(u'Booking Activation Code'), |
---|
[6992] | 659 | required = False, |
---|
[7014] | 660 | readonly = True, |
---|
[6992] | 661 | ) |
---|
| 662 | |
---|
[6994] | 663 | def getSessionString(): |
---|
[7633] | 664 | """Returns the title of academic_sessions_vocab term. |
---|
[7150] | 665 | |
---|
[6994] | 666 | """ |
---|
[6992] | 667 | |
---|
[6860] | 668 | class IStudentPaymentsContainer(IPaymentsContainer): |
---|
[6635] | 669 | """A container for student payment objects. |
---|
| 670 | |
---|
| 671 | """ |
---|
| 672 | |
---|
[6877] | 673 | class IStudentOnlinePayment(IOnlinePayment): |
---|
| 674 | """A student payment via payment gateways. |
---|
| 675 | |
---|
| 676 | """ |
---|
| 677 | |
---|
[9148] | 678 | p_current = schema.Bool( |
---|
| 679 | title = _(u'Current Session Payment'), |
---|
| 680 | default = True, |
---|
| 681 | required = False, |
---|
| 682 | ) |
---|
| 683 | |
---|
[8268] | 684 | p_level = schema.Int( |
---|
| 685 | title = _(u'Payment Level'), |
---|
| 686 | required = False, |
---|
| 687 | ) |
---|
[6877] | 688 | |
---|
[8422] | 689 | def doAfterStudentPayment(): |
---|
| 690 | """Process student after payment was made. |
---|
| 691 | |
---|
| 692 | """ |
---|
| 693 | |
---|
[8453] | 694 | def doAfterStudentPaymentApproval(): |
---|
| 695 | """Process student after payment was approved. |
---|
| 696 | |
---|
| 697 | """ |
---|
| 698 | |
---|
[8420] | 699 | def approveStudentPayment(): |
---|
[8422] | 700 | """Approve payment and process student. |
---|
[8420] | 701 | |
---|
| 702 | """ |
---|
| 703 | |
---|
[8268] | 704 | IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[ |
---|
| 705 | 'p_session'].order |
---|
[8408] | 706 | |
---|
[9148] | 707 | class IStudentPreviousPayment(IOnlinePayment): |
---|
| 708 | """An interface for adding previous session payments. |
---|
| 709 | |
---|
| 710 | """ |
---|
| 711 | |
---|
| 712 | p_session = schema.Choice( |
---|
| 713 | title = _(u'Payment Session'), |
---|
| 714 | source = academic_sessions_vocab, |
---|
| 715 | required = True, |
---|
| 716 | ) |
---|
| 717 | |
---|
| 718 | p_level = schema.Choice( |
---|
| 719 | title = _(u'Payment Level'), |
---|
| 720 | source = StudyLevelSource(), |
---|
| 721 | required = True, |
---|
| 722 | ) |
---|
| 723 | |
---|
[8408] | 724 | class ICSVStudentExporter(ICSVExporter): |
---|
| 725 | """A regular ICSVExporter that additionally supports exporting |
---|
| 726 | data from a given student object. |
---|
| 727 | """ |
---|
| 728 | |
---|
| 729 | def export_student(student, filepath=None): |
---|
| 730 | """Export data for a given student. |
---|
| 731 | """ |
---|