[7191] | 1 | ## $Id: interfaces.py 9702 2012-11-21 15:18:31Z 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 | |
---|
[9702] | 171 | suspended_comment = schema.Text( |
---|
| 172 | title = _(u"Reasons for Deactivation"), |
---|
| 173 | required = False, |
---|
| 174 | description = _( |
---|
| 175 | u'This message will be shown if and only if deactivated ' |
---|
| 176 | 'students try to login.'), |
---|
| 177 | ) |
---|
| 178 | |
---|
[6665] | 179 | student_id = schema.TextLine( |
---|
[7723] | 180 | title = _(u'Student Id'), |
---|
[6849] | 181 | required = False, |
---|
[6665] | 182 | ) |
---|
| 183 | |
---|
[7357] | 184 | firstname = schema.TextLine( |
---|
[7723] | 185 | title = _(u'First Name'), |
---|
[6621] | 186 | required = True, |
---|
| 187 | ) |
---|
| 188 | |
---|
[7357] | 189 | middlename = schema.TextLine( |
---|
[7723] | 190 | title = _(u'Middle Name'), |
---|
[7357] | 191 | required = False, |
---|
| 192 | ) |
---|
| 193 | |
---|
| 194 | lastname = schema.TextLine( |
---|
[7723] | 195 | title = _(u'Last Name (Surname)'), |
---|
[7357] | 196 | required = True, |
---|
| 197 | ) |
---|
| 198 | |
---|
[6996] | 199 | sex = schema.Choice( |
---|
[7723] | 200 | title = _(u'Sex'), |
---|
[6996] | 201 | source = GenderSource(), |
---|
| 202 | required = True, |
---|
| 203 | ) |
---|
| 204 | |
---|
[6788] | 205 | reg_number = TextLineChoice( |
---|
[7723] | 206 | title = _(u'Registration Number'), |
---|
[6696] | 207 | required = True, |
---|
| 208 | readonly = False, |
---|
[6788] | 209 | source = contextual_reg_num_source, |
---|
[6696] | 210 | ) |
---|
| 211 | |
---|
[6788] | 212 | matric_number = TextLineChoice( |
---|
[7723] | 213 | title = _(u'Matriculation Number'), |
---|
[6750] | 214 | required = False, |
---|
| 215 | readonly = False, |
---|
[6788] | 216 | source = contextual_mat_num_source, |
---|
[6750] | 217 | ) |
---|
| 218 | |
---|
[6769] | 219 | adm_code = schema.TextLine( |
---|
[7723] | 220 | title = _(u'PWD Activation Code'), |
---|
[6769] | 221 | required = False, |
---|
[8977] | 222 | readonly = False, |
---|
[6769] | 223 | ) |
---|
| 224 | |
---|
[7133] | 225 | email = schema.ASCIILine( |
---|
[7723] | 226 | title = _(u'Email'), |
---|
[7133] | 227 | required = False, |
---|
| 228 | constraint=validate_email, |
---|
| 229 | ) |
---|
[8176] | 230 | phone = PhoneNumber( |
---|
[7723] | 231 | title = _(u'Phone'), |
---|
[7331] | 232 | description = u'', |
---|
[7133] | 233 | required = False, |
---|
| 234 | ) |
---|
| 235 | |
---|
[9334] | 236 | def setTempPassword(user, password): |
---|
| 237 | """Set a temporary password (LDAP-compatible) SSHA encoded for |
---|
| 238 | officers. |
---|
| 239 | |
---|
| 240 | """ |
---|
| 241 | |
---|
| 242 | def getTempPassword(): |
---|
| 243 | """Check if a temporary password has been set and if it |
---|
| 244 | is not expired. |
---|
| 245 | |
---|
| 246 | Return the temporary password if valid, |
---|
| 247 | None otherwise. Unset the temporary password if expired. |
---|
| 248 | """ |
---|
| 249 | |
---|
[9131] | 250 | def transfer(certificate, current_session, |
---|
| 251 | current_level, current_verdict): |
---|
| 252 | """ Creates a new studycourse and backups the old one. |
---|
| 253 | |
---|
| 254 | """ |
---|
| 255 | |
---|
[7993] | 256 | class IUGStudentClearance(IKofaObject): |
---|
| 257 | """Representation of undergraduate student clearance data. |
---|
[7150] | 258 | |
---|
[6631] | 259 | """ |
---|
[9543] | 260 | officer_comment = schema.Text( |
---|
| 261 | title = _(u"Officer's Comment"), |
---|
| 262 | required = False, |
---|
[6631] | 263 | ) |
---|
| 264 | |
---|
[6695] | 265 | clearance_locked = schema.Bool( |
---|
[7723] | 266 | title = _(u'Clearance form locked'), |
---|
[6695] | 267 | default = False, |
---|
[9035] | 268 | required = False, |
---|
[6695] | 269 | ) |
---|
| 270 | |
---|
[6769] | 271 | clr_code = schema.TextLine( |
---|
[7723] | 272 | title = _(u'CLR Activation Code'), |
---|
[6769] | 273 | required = False, |
---|
[8977] | 274 | readonly = False, |
---|
[6769] | 275 | ) |
---|
| 276 | |
---|
[9543] | 277 | date_of_birth = FormattedDate( |
---|
| 278 | title = _(u'Date of Birth'), |
---|
| 279 | required = True, |
---|
| 280 | show_year = True, |
---|
| 281 | ) |
---|
| 282 | |
---|
[7523] | 283 | nationality = schema.Choice( |
---|
[8069] | 284 | vocabulary = nats_vocab, |
---|
[7723] | 285 | title = _(u'Nationality'), |
---|
[7983] | 286 | required = False, |
---|
[7523] | 287 | ) |
---|
| 288 | |
---|
[7993] | 289 | class IPGStudentClearance(IUGStudentClearance): |
---|
| 290 | """Representation of postgraduate student clearance data. |
---|
| 291 | |
---|
| 292 | """ |
---|
| 293 | employer = schema.TextLine( |
---|
| 294 | title = _(u'Employer'), |
---|
| 295 | required = False, |
---|
| 296 | readonly = False, |
---|
| 297 | ) |
---|
| 298 | |
---|
[7819] | 299 | class IStudentPersonal(IKofaObject): |
---|
[6631] | 300 | """Representation of student personal data. |
---|
[7150] | 301 | |
---|
[6631] | 302 | """ |
---|
[9543] | 303 | personal_updated = schema.Datetime( |
---|
| 304 | title = _(u'Updated'), |
---|
| 305 | required = False, |
---|
| 306 | readonly = False, |
---|
| 307 | ) |
---|
| 308 | |
---|
[6651] | 309 | perm_address = schema.Text( |
---|
[7723] | 310 | title = _(u'Permanent Address'), |
---|
[6631] | 311 | required = False, |
---|
| 312 | ) |
---|
| 313 | |
---|
[8008] | 314 | class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance, |
---|
| 315 | IStudentPersonal): |
---|
[6631] | 316 | """Representation of a student. |
---|
[7150] | 317 | |
---|
[6631] | 318 | """ |
---|
| 319 | |
---|
[9563] | 320 | class IStudentPersonalEdit(IStudentPersonal): |
---|
| 321 | """Interface for editing personal data by students. |
---|
| 322 | |
---|
| 323 | Here we can repeat the fields from IStudentPersonal and set the |
---|
| 324 | `required` if necessary. |
---|
| 325 | """ |
---|
| 326 | |
---|
| 327 | perm_address = schema.Text( |
---|
| 328 | title = _(u'Permanent Address'), |
---|
| 329 | required = True, |
---|
| 330 | ) |
---|
| 331 | |
---|
[6849] | 332 | class IStudentUpdateByRegNo(IStudent): |
---|
| 333 | """Representation of a student. Skip regular reg_number validation. |
---|
[7150] | 334 | |
---|
[6849] | 335 | """ |
---|
| 336 | reg_number = schema.TextLine( |
---|
[7723] | 337 | title = _(u'Registration Number'), |
---|
[6849] | 338 | required = False, |
---|
| 339 | ) |
---|
| 340 | |
---|
| 341 | class IStudentUpdateByMatricNo(IStudent): |
---|
| 342 | """Representation of a student. Skip regular matric_number validation. |
---|
[7150] | 343 | |
---|
[6849] | 344 | """ |
---|
| 345 | matric_number = schema.TextLine( |
---|
[7723] | 346 | title = _(u'Matriculation Number'), |
---|
[6849] | 347 | required = False, |
---|
| 348 | ) |
---|
| 349 | |
---|
[8779] | 350 | class IStudentRequestPW(IStudent): |
---|
| 351 | """Representation of an student for first-time password request. |
---|
| 352 | |
---|
| 353 | This interface is used when students use the requestpw page to |
---|
| 354 | login for the the first time. |
---|
| 355 | """ |
---|
[8854] | 356 | number = schema.TextLine( |
---|
| 357 | title = _(u'Registr. or Matric. Number'), |
---|
[8779] | 358 | required = True, |
---|
| 359 | ) |
---|
| 360 | |
---|
| 361 | firstname = schema.TextLine( |
---|
| 362 | title = _(u'First Name'), |
---|
| 363 | required = True, |
---|
| 364 | ) |
---|
| 365 | |
---|
| 366 | email = schema.ASCIILine( |
---|
| 367 | title = _(u'Email Address'), |
---|
| 368 | required = True, |
---|
| 369 | constraint=validate_email, |
---|
| 370 | ) |
---|
| 371 | |
---|
[7819] | 372 | class IStudentStudyCourse(IKofaObject): |
---|
[6633] | 373 | """A container for student study levels. |
---|
| 374 | |
---|
| 375 | """ |
---|
[6648] | 376 | certificate = schema.Choice( |
---|
[7723] | 377 | title = _(u'Certificate'), |
---|
[6648] | 378 | source = CertificateSource(), |
---|
[7209] | 379 | required = False, |
---|
[6633] | 380 | ) |
---|
[6635] | 381 | |
---|
[6996] | 382 | entry_mode = schema.Choice( |
---|
[7723] | 383 | title = _(u'Entry Mode'), |
---|
[7681] | 384 | source = StudyModeSource(), |
---|
[6996] | 385 | required = True, |
---|
| 386 | readonly = False, |
---|
| 387 | ) |
---|
| 388 | |
---|
| 389 | entry_session = schema.Choice( |
---|
[7723] | 390 | title = _(u'Entry Session'), |
---|
[6996] | 391 | source = academic_sessions_vocab, |
---|
[7425] | 392 | #default = datetime.now().year, |
---|
[6996] | 393 | required = True, |
---|
| 394 | readonly = False, |
---|
| 395 | ) |
---|
| 396 | |
---|
[6724] | 397 | current_session = schema.Choice( |
---|
[7723] | 398 | title = _(u'Current Session'), |
---|
[6744] | 399 | source = academic_sessions_vocab, |
---|
[6724] | 400 | required = True, |
---|
[6996] | 401 | readonly = False, |
---|
[6724] | 402 | ) |
---|
| 403 | |
---|
| 404 | current_level = schema.Choice( |
---|
[7723] | 405 | title = _(u'Current Level'), |
---|
[6725] | 406 | source = StudyLevelSource(), |
---|
| 407 | required = False, |
---|
[6996] | 408 | readonly = False, |
---|
[6724] | 409 | ) |
---|
| 410 | |
---|
| 411 | current_verdict = schema.Choice( |
---|
[7723] | 412 | title = _(u'Current Verdict'), |
---|
[7619] | 413 | source = VerdictSource(), |
---|
[8820] | 414 | default = '0', |
---|
[6725] | 415 | required = False, |
---|
[6724] | 416 | ) |
---|
| 417 | |
---|
| 418 | previous_verdict = schema.Choice( |
---|
[7723] | 419 | title = _(u'Previous Verdict'), |
---|
[7619] | 420 | source = VerdictSource(), |
---|
[8820] | 421 | default = '0', |
---|
[6725] | 422 | required = False, |
---|
[6724] | 423 | ) |
---|
| 424 | |
---|
[9138] | 425 | class IStudentStudyCourseTransfer(IStudentStudyCourse): |
---|
| 426 | """An student transfers. |
---|
| 427 | |
---|
| 428 | """ |
---|
| 429 | |
---|
| 430 | certificate = schema.Choice( |
---|
| 431 | title = _(u'Certificate'), |
---|
| 432 | source = CertificateSource(), |
---|
| 433 | required = True, |
---|
| 434 | ) |
---|
| 435 | |
---|
| 436 | current_level = schema.Choice( |
---|
| 437 | title = _(u'Current Level'), |
---|
| 438 | source = StudyLevelSource(), |
---|
| 439 | required = True, |
---|
| 440 | readonly = False, |
---|
| 441 | ) |
---|
| 442 | |
---|
| 443 | |
---|
| 444 | IStudentStudyCourseTransfer['certificate'].order = IStudentStudyCourse[ |
---|
| 445 | 'certificate'].order |
---|
| 446 | IStudentStudyCourseTransfer['current_level'].order = IStudentStudyCourse[ |
---|
| 447 | 'current_level'].order |
---|
| 448 | |
---|
[7951] | 449 | class IStudentVerdictUpdate(IKofaObject): |
---|
| 450 | """A interface for verdict imports. |
---|
| 451 | |
---|
| 452 | """ |
---|
| 453 | |
---|
| 454 | current_verdict = schema.Choice( |
---|
| 455 | title = _(u'Current Verdict'), |
---|
| 456 | source = VerdictSource(), |
---|
| 457 | required = True, |
---|
| 458 | ) |
---|
| 459 | |
---|
| 460 | current_session = schema.Choice( |
---|
| 461 | title = _(u'Current Session'), |
---|
| 462 | source = academic_sessions_vocab, |
---|
| 463 | required = True, |
---|
| 464 | ) |
---|
| 465 | |
---|
| 466 | current_level = schema.Choice( |
---|
| 467 | title = _(u'Current Level'), |
---|
| 468 | source = StudyLevelSource(), |
---|
| 469 | required = True, |
---|
| 470 | ) |
---|
| 471 | |
---|
[9296] | 472 | bypass_validation = schema.Bool( |
---|
| 473 | title = _(u'Bypass validation'), |
---|
| 474 | required = False, |
---|
| 475 | ) |
---|
| 476 | |
---|
| 477 | validated_by = schema.TextLine( |
---|
| 478 | title = _(u'Validated by'), |
---|
| 479 | required = False, |
---|
| 480 | ) |
---|
| 481 | |
---|
[7819] | 482 | class IStudentStudyLevel(IKofaObject): |
---|
[6774] | 483 | """A container for course tickets. |
---|
| 484 | |
---|
| 485 | """ |
---|
| 486 | level = Attribute('The level code') |
---|
[9235] | 487 | number_of_tickets = Attribute('Number of tickets contained in this level') |
---|
[9253] | 488 | certcode = Attribute('The certificate code of the study course') |
---|
[9257] | 489 | is_current_level = Attribute('Is this level the current level of the student?') |
---|
[6774] | 490 | |
---|
[6793] | 491 | level_session = schema.Choice( |
---|
[7723] | 492 | title = _(u'Session'), |
---|
[6793] | 493 | source = academic_sessions_vocab, |
---|
[9437] | 494 | required = True, |
---|
[6793] | 495 | ) |
---|
[6781] | 496 | |
---|
[6793] | 497 | level_verdict = schema.Choice( |
---|
[7723] | 498 | title = _(u'Verdict'), |
---|
[7619] | 499 | source = VerdictSource(), |
---|
[8820] | 500 | default = '0', |
---|
[6793] | 501 | required = False, |
---|
| 502 | ) |
---|
| 503 | |
---|
[9161] | 504 | validated_by = schema.TextLine( |
---|
| 505 | title = _(u'Validated by'), |
---|
| 506 | default = None, |
---|
| 507 | required = False, |
---|
| 508 | ) |
---|
| 509 | |
---|
| 510 | validation_date = schema.Datetime( |
---|
| 511 | title = _(u'Validation Date'), |
---|
| 512 | required = False, |
---|
| 513 | readonly = False, |
---|
| 514 | ) |
---|
| 515 | |
---|
[9690] | 516 | total_credits = schema.Int( |
---|
| 517 | title = _(u'Total Credits'), |
---|
| 518 | required = False, |
---|
| 519 | readonly = True, |
---|
| 520 | ) |
---|
| 521 | |
---|
| 522 | gpa = schema.Int( |
---|
| 523 | title = _(u'GPA'), |
---|
| 524 | required = False, |
---|
| 525 | readonly = True, |
---|
| 526 | ) |
---|
| 527 | |
---|
[8920] | 528 | def addCourseTicket(ticket, course): |
---|
[8182] | 529 | """Add a course ticket object. |
---|
| 530 | """ |
---|
| 531 | |
---|
[9501] | 532 | def addCertCourseTickets(cert): |
---|
| 533 | """Collect all certificate courses and create course |
---|
| 534 | tickets automatically. |
---|
| 535 | """ |
---|
| 536 | |
---|
[7819] | 537 | class ICourseTicket(IKofaObject): |
---|
[9420] | 538 | """An interface for course tickets. |
---|
[6781] | 539 | |
---|
| 540 | """ |
---|
[6783] | 541 | code = Attribute('code of the original course') |
---|
[9253] | 542 | certcode = Attribute('certificate code of the study course') |
---|
[9684] | 543 | grade = Attribute('grade calculated from score') |
---|
| 544 | weight = Attribute('weight calculated from score') |
---|
[9698] | 545 | removable_by_student = Attribute('Is student allowed to remove the ticket?') |
---|
[6781] | 546 | |
---|
[9420] | 547 | title = schema.TextLine( |
---|
| 548 | title = _(u'Title'), |
---|
| 549 | required = False, |
---|
| 550 | ) |
---|
| 551 | |
---|
| 552 | fcode = schema.TextLine( |
---|
| 553 | title = _(u'Faculty Code'), |
---|
| 554 | required = False, |
---|
| 555 | ) |
---|
| 556 | |
---|
| 557 | dcode = schema.TextLine( |
---|
| 558 | title = _(u'Department Code'), |
---|
| 559 | required = False, |
---|
| 560 | ) |
---|
| 561 | |
---|
| 562 | semester = schema.Choice( |
---|
| 563 | title = _(u'Semester/Term'), |
---|
| 564 | source = SemesterSource(), |
---|
| 565 | required = False, |
---|
| 566 | ) |
---|
| 567 | |
---|
| 568 | passmark = schema.Int( |
---|
| 569 | title = _(u'Passmark'), |
---|
| 570 | required = False, |
---|
| 571 | ) |
---|
| 572 | |
---|
| 573 | credits = schema.Int( |
---|
| 574 | title = _(u'Credits'), |
---|
| 575 | required = False, |
---|
| 576 | ) |
---|
| 577 | |
---|
[7665] | 578 | mandatory = schema.Bool( |
---|
[9320] | 579 | title = _(u'Required'), |
---|
[6795] | 580 | default = False, |
---|
| 581 | required = False, |
---|
| 582 | ) |
---|
| 583 | |
---|
[6781] | 584 | score = schema.Int( |
---|
[7723] | 585 | title = _(u'Score'), |
---|
[9684] | 586 | default = None, |
---|
[6781] | 587 | required = False, |
---|
| 588 | ) |
---|
| 589 | |
---|
[7661] | 590 | carry_over = schema.Bool( |
---|
[7723] | 591 | title = _(u'Carry-over Course'), |
---|
[7661] | 592 | default = False, |
---|
| 593 | required = False, |
---|
| 594 | ) |
---|
| 595 | |
---|
[9420] | 596 | automatic = schema.Bool( |
---|
| 597 | title = _(u'Automatical Creation'), |
---|
| 598 | default = False, |
---|
[9316] | 599 | required = False, |
---|
| 600 | ) |
---|
| 601 | |
---|
[7633] | 602 | def getLevel(): |
---|
| 603 | """Returns the id of the level the ticket has been added to. |
---|
| 604 | """ |
---|
| 605 | |
---|
| 606 | def getLevelSession(): |
---|
| 607 | """Returns the session of the level the ticket has been added to. |
---|
| 608 | """ |
---|
| 609 | |
---|
[9420] | 610 | class ICourseTicketAdd(IKofaObject): |
---|
[7150] | 611 | """An interface for adding course tickets. |
---|
[6795] | 612 | |
---|
| 613 | """ |
---|
| 614 | course = schema.Choice( |
---|
[7723] | 615 | title = _(u'Course'), |
---|
[6795] | 616 | source = CourseSource(), |
---|
| 617 | readonly = False, |
---|
| 618 | ) |
---|
| 619 | |
---|
[9420] | 620 | class ICourseTicketImport(ICourseTicket): |
---|
| 621 | """An interface for importing course results and nothing more. |
---|
| 622 | |
---|
| 623 | """ |
---|
| 624 | score = schema.Int( |
---|
| 625 | title = _(u'Score'), |
---|
| 626 | required = False, |
---|
| 627 | readonly = False, |
---|
| 628 | ) |
---|
| 629 | |
---|
| 630 | level_session = schema.Choice( |
---|
| 631 | title = _(u'Level Session'), |
---|
| 632 | source = academic_sessions_vocab, |
---|
| 633 | required = False, |
---|
| 634 | readonly = False, |
---|
| 635 | ) |
---|
| 636 | |
---|
[7819] | 637 | class IStudentAccommodation(IKofaObject): |
---|
[6635] | 638 | """A container for student accommodation objects. |
---|
| 639 | |
---|
| 640 | """ |
---|
| 641 | |
---|
[9423] | 642 | def addBedTicket(bedticket): |
---|
| 643 | """Add a bed ticket object. |
---|
| 644 | """ |
---|
| 645 | |
---|
| 646 | |
---|
[7819] | 647 | class IBedTicket(IKofaObject): |
---|
[6989] | 648 | """A ticket for accommodation booking. |
---|
| 649 | |
---|
| 650 | """ |
---|
[6996] | 651 | bed = Attribute('The bed object.') |
---|
| 652 | |
---|
| 653 | bed_coordinates = schema.TextLine( |
---|
[9424] | 654 | title = _(u'Allocated Bed'), |
---|
[9423] | 655 | required = True, |
---|
[7014] | 656 | readonly = False, |
---|
[6992] | 657 | ) |
---|
| 658 | |
---|
[6996] | 659 | bed_type = schema.TextLine( |
---|
[9424] | 660 | title = _(u'Requested Bed Type'), |
---|
[9423] | 661 | required = True, |
---|
[7014] | 662 | readonly = False, |
---|
[6996] | 663 | ) |
---|
| 664 | |
---|
[6992] | 665 | booking_session = schema.Choice( |
---|
[7723] | 666 | title = _(u'Session'), |
---|
[6992] | 667 | source = academic_sessions_vocab, |
---|
| 668 | required = True, |
---|
[7014] | 669 | readonly = True, |
---|
[6992] | 670 | ) |
---|
| 671 | |
---|
[8170] | 672 | booking_date = schema.Datetime( |
---|
[7723] | 673 | title = _(u'Booking Date'), |
---|
[6992] | 674 | required = False, |
---|
[7014] | 675 | readonly = True, |
---|
[6992] | 676 | ) |
---|
| 677 | |
---|
| 678 | booking_code = schema.TextLine( |
---|
[7723] | 679 | title = _(u'Booking Activation Code'), |
---|
[6992] | 680 | required = False, |
---|
[7014] | 681 | readonly = True, |
---|
[6992] | 682 | ) |
---|
| 683 | |
---|
[6994] | 684 | def getSessionString(): |
---|
[7633] | 685 | """Returns the title of academic_sessions_vocab term. |
---|
[7150] | 686 | |
---|
[6994] | 687 | """ |
---|
[6992] | 688 | |
---|
[6860] | 689 | class IStudentPaymentsContainer(IPaymentsContainer): |
---|
[6635] | 690 | """A container for student payment objects. |
---|
| 691 | |
---|
| 692 | """ |
---|
| 693 | |
---|
[6877] | 694 | class IStudentOnlinePayment(IOnlinePayment): |
---|
| 695 | """A student payment via payment gateways. |
---|
| 696 | |
---|
| 697 | """ |
---|
| 698 | |
---|
[9148] | 699 | p_current = schema.Bool( |
---|
| 700 | title = _(u'Current Session Payment'), |
---|
| 701 | default = True, |
---|
| 702 | required = False, |
---|
| 703 | ) |
---|
| 704 | |
---|
[8268] | 705 | p_level = schema.Int( |
---|
| 706 | title = _(u'Payment Level'), |
---|
| 707 | required = False, |
---|
| 708 | ) |
---|
[6877] | 709 | |
---|
[8422] | 710 | def doAfterStudentPayment(): |
---|
| 711 | """Process student after payment was made. |
---|
| 712 | |
---|
| 713 | """ |
---|
| 714 | |
---|
[8453] | 715 | def doAfterStudentPaymentApproval(): |
---|
| 716 | """Process student after payment was approved. |
---|
| 717 | |
---|
| 718 | """ |
---|
| 719 | |
---|
[8420] | 720 | def approveStudentPayment(): |
---|
[8422] | 721 | """Approve payment and process student. |
---|
[8420] | 722 | |
---|
| 723 | """ |
---|
| 724 | |
---|
[8268] | 725 | IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[ |
---|
| 726 | 'p_session'].order |
---|
[8408] | 727 | |
---|
[9148] | 728 | class IStudentPreviousPayment(IOnlinePayment): |
---|
| 729 | """An interface for adding previous session payments. |
---|
| 730 | |
---|
| 731 | """ |
---|
| 732 | |
---|
| 733 | p_session = schema.Choice( |
---|
| 734 | title = _(u'Payment Session'), |
---|
| 735 | source = academic_sessions_vocab, |
---|
| 736 | required = True, |
---|
| 737 | ) |
---|
| 738 | |
---|
| 739 | p_level = schema.Choice( |
---|
| 740 | title = _(u'Payment Level'), |
---|
| 741 | source = StudyLevelSource(), |
---|
| 742 | required = True, |
---|
| 743 | ) |
---|
| 744 | |
---|
[8408] | 745 | class ICSVStudentExporter(ICSVExporter): |
---|
| 746 | """A regular ICSVExporter that additionally supports exporting |
---|
| 747 | data from a given student object. |
---|
| 748 | """ |
---|
| 749 | |
---|
| 750 | def export_student(student, filepath=None): |
---|
| 751 | """Export data for a given student. |
---|
| 752 | """ |
---|