[7191] | 1 | ## $Id: interfaces.py 9235 2012-09-26 14:59:20Z 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, |
---|
| 30 | GenderSource, nats_vocab, |
---|
| 31 | ) |
---|
[8160] | 32 | from waeup.kofa.payments.interfaces import ( |
---|
[8174] | 33 | IPaymentsContainer, IOnlinePayment) |
---|
[7915] | 34 | from waeup.kofa.university.vocabularies import ( |
---|
| 35 | CourseSource, StudyModeSource, CertificateSource) |
---|
[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') |
---|
[7203] | 152 | certcode = Attribute('The certificate code of any chosen study course') |
---|
| 153 | depcode = Attribute('The department code of any chosen study course') |
---|
| 154 | faccode = Attribute('The faculty code of any chosen study course') |
---|
[7062] | 155 | current_session = Attribute('The current session of the student') |
---|
[9142] | 156 | current_level = Attribute('The current level of the student') |
---|
[7641] | 157 | current_mode = Attribute('The current mode of the student') |
---|
[9182] | 158 | current_verdict = Attribute('The current verdict of the student') |
---|
[7364] | 159 | fullname = Attribute('All name parts separated by hyphens') |
---|
| 160 | display_fullname = Attribute('The fullname of an applicant') |
---|
[8969] | 161 | is_postgrad = Attribute('True if postgraduate student') |
---|
[6637] | 162 | |
---|
[8983] | 163 | suspended = schema.Bool( |
---|
| 164 | title = _(u'Account suspended'), |
---|
| 165 | default = False, |
---|
[9035] | 166 | required = False, |
---|
[8983] | 167 | ) |
---|
| 168 | |
---|
[6665] | 169 | student_id = schema.TextLine( |
---|
[7723] | 170 | title = _(u'Student Id'), |
---|
[6849] | 171 | required = False, |
---|
[6665] | 172 | ) |
---|
| 173 | |
---|
[7357] | 174 | firstname = schema.TextLine( |
---|
[7723] | 175 | title = _(u'First Name'), |
---|
[6621] | 176 | required = True, |
---|
| 177 | ) |
---|
| 178 | |
---|
[7357] | 179 | middlename = schema.TextLine( |
---|
[7723] | 180 | title = _(u'Middle Name'), |
---|
[7357] | 181 | required = False, |
---|
| 182 | ) |
---|
| 183 | |
---|
| 184 | lastname = schema.TextLine( |
---|
[7723] | 185 | title = _(u'Last Name (Surname)'), |
---|
[7357] | 186 | required = True, |
---|
| 187 | ) |
---|
| 188 | |
---|
[6996] | 189 | sex = schema.Choice( |
---|
[7723] | 190 | title = _(u'Sex'), |
---|
[6996] | 191 | source = GenderSource(), |
---|
| 192 | required = True, |
---|
| 193 | ) |
---|
| 194 | |
---|
[6788] | 195 | reg_number = TextLineChoice( |
---|
[7723] | 196 | title = _(u'Registration Number'), |
---|
[6696] | 197 | required = True, |
---|
| 198 | readonly = False, |
---|
[6788] | 199 | source = contextual_reg_num_source, |
---|
[6696] | 200 | ) |
---|
| 201 | |
---|
[6788] | 202 | matric_number = TextLineChoice( |
---|
[7723] | 203 | title = _(u'Matriculation Number'), |
---|
[6750] | 204 | required = False, |
---|
| 205 | readonly = False, |
---|
[6788] | 206 | source = contextual_mat_num_source, |
---|
[6750] | 207 | ) |
---|
| 208 | |
---|
[6769] | 209 | adm_code = schema.TextLine( |
---|
[7723] | 210 | title = _(u'PWD Activation Code'), |
---|
[6769] | 211 | required = False, |
---|
[8977] | 212 | readonly = False, |
---|
[6769] | 213 | ) |
---|
| 214 | |
---|
[7133] | 215 | email = schema.ASCIILine( |
---|
[7723] | 216 | title = _(u'Email'), |
---|
[7133] | 217 | required = False, |
---|
| 218 | constraint=validate_email, |
---|
| 219 | ) |
---|
[8176] | 220 | phone = PhoneNumber( |
---|
[7723] | 221 | title = _(u'Phone'), |
---|
[7331] | 222 | description = u'', |
---|
[7133] | 223 | required = False, |
---|
| 224 | ) |
---|
| 225 | |
---|
[9131] | 226 | def transfer(certificate, current_session, |
---|
| 227 | current_level, current_verdict): |
---|
| 228 | """ Creates a new studycourse and backups the old one. |
---|
| 229 | |
---|
| 230 | """ |
---|
| 231 | |
---|
[7993] | 232 | class IUGStudentClearance(IKofaObject): |
---|
| 233 | """Representation of undergraduate student clearance data. |
---|
[7150] | 234 | |
---|
[6631] | 235 | """ |
---|
[8160] | 236 | date_of_birth = FormattedDate( |
---|
[7723] | 237 | title = _(u'Date of Birth'), |
---|
[6631] | 238 | required = True, |
---|
[8160] | 239 | show_year = True, |
---|
[6631] | 240 | ) |
---|
| 241 | |
---|
[6695] | 242 | clearance_locked = schema.Bool( |
---|
[7723] | 243 | title = _(u'Clearance form locked'), |
---|
[6695] | 244 | default = False, |
---|
[9035] | 245 | required = False, |
---|
[6695] | 246 | ) |
---|
| 247 | |
---|
[6769] | 248 | clr_code = schema.TextLine( |
---|
[7723] | 249 | title = _(u'CLR Activation Code'), |
---|
[6769] | 250 | required = False, |
---|
[8977] | 251 | readonly = False, |
---|
[6769] | 252 | ) |
---|
| 253 | |
---|
[7523] | 254 | nationality = schema.Choice( |
---|
[8069] | 255 | vocabulary = nats_vocab, |
---|
[7723] | 256 | title = _(u'Nationality'), |
---|
[7983] | 257 | required = False, |
---|
[7523] | 258 | ) |
---|
| 259 | |
---|
[7993] | 260 | class IPGStudentClearance(IUGStudentClearance): |
---|
| 261 | """Representation of postgraduate student clearance data. |
---|
| 262 | |
---|
| 263 | """ |
---|
| 264 | employer = schema.TextLine( |
---|
| 265 | title = _(u'Employer'), |
---|
| 266 | required = False, |
---|
| 267 | readonly = False, |
---|
| 268 | ) |
---|
| 269 | |
---|
[7819] | 270 | class IStudentPersonal(IKofaObject): |
---|
[6631] | 271 | """Representation of student personal data. |
---|
[7150] | 272 | |
---|
[6631] | 273 | """ |
---|
[6651] | 274 | perm_address = schema.Text( |
---|
[7723] | 275 | title = _(u'Permanent Address'), |
---|
[6631] | 276 | required = False, |
---|
| 277 | ) |
---|
| 278 | |
---|
[8008] | 279 | class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance, |
---|
| 280 | IStudentPersonal): |
---|
[6631] | 281 | """Representation of a student. |
---|
[7150] | 282 | |
---|
[6631] | 283 | """ |
---|
| 284 | |
---|
[6849] | 285 | class IStudentUpdateByRegNo(IStudent): |
---|
| 286 | """Representation of a student. Skip regular reg_number validation. |
---|
[7150] | 287 | |
---|
[6849] | 288 | """ |
---|
| 289 | reg_number = schema.TextLine( |
---|
[7723] | 290 | title = _(u'Registration Number'), |
---|
[6849] | 291 | required = False, |
---|
| 292 | ) |
---|
| 293 | |
---|
| 294 | class IStudentUpdateByMatricNo(IStudent): |
---|
| 295 | """Representation of a student. Skip regular matric_number validation. |
---|
[7150] | 296 | |
---|
[6849] | 297 | """ |
---|
| 298 | matric_number = schema.TextLine( |
---|
[7723] | 299 | title = _(u'Matriculation Number'), |
---|
[6849] | 300 | required = False, |
---|
| 301 | ) |
---|
| 302 | |
---|
[8779] | 303 | class IStudentRequestPW(IStudent): |
---|
| 304 | """Representation of an student for first-time password request. |
---|
| 305 | |
---|
| 306 | This interface is used when students use the requestpw page to |
---|
| 307 | login for the the first time. |
---|
| 308 | """ |
---|
[8854] | 309 | number = schema.TextLine( |
---|
| 310 | title = _(u'Registr. or Matric. Number'), |
---|
[8779] | 311 | required = True, |
---|
| 312 | ) |
---|
| 313 | |
---|
| 314 | firstname = schema.TextLine( |
---|
| 315 | title = _(u'First Name'), |
---|
| 316 | required = True, |
---|
| 317 | ) |
---|
| 318 | |
---|
| 319 | email = schema.ASCIILine( |
---|
| 320 | title = _(u'Email Address'), |
---|
| 321 | required = True, |
---|
| 322 | constraint=validate_email, |
---|
| 323 | ) |
---|
| 324 | |
---|
[7819] | 325 | class IStudentStudyCourse(IKofaObject): |
---|
[6633] | 326 | """A container for student study levels. |
---|
| 327 | |
---|
| 328 | """ |
---|
[6648] | 329 | certificate = schema.Choice( |
---|
[7723] | 330 | title = _(u'Certificate'), |
---|
[6648] | 331 | source = CertificateSource(), |
---|
[7209] | 332 | required = False, |
---|
[6633] | 333 | ) |
---|
[6635] | 334 | |
---|
[6996] | 335 | entry_mode = schema.Choice( |
---|
[7723] | 336 | title = _(u'Entry Mode'), |
---|
[7681] | 337 | source = StudyModeSource(), |
---|
[6996] | 338 | required = True, |
---|
| 339 | readonly = False, |
---|
| 340 | ) |
---|
| 341 | |
---|
| 342 | entry_session = schema.Choice( |
---|
[7723] | 343 | title = _(u'Entry Session'), |
---|
[6996] | 344 | source = academic_sessions_vocab, |
---|
[7425] | 345 | #default = datetime.now().year, |
---|
[6996] | 346 | required = True, |
---|
| 347 | readonly = False, |
---|
| 348 | ) |
---|
| 349 | |
---|
[6724] | 350 | current_session = schema.Choice( |
---|
[7723] | 351 | title = _(u'Current Session'), |
---|
[6744] | 352 | source = academic_sessions_vocab, |
---|
[6724] | 353 | required = True, |
---|
[6996] | 354 | readonly = False, |
---|
[6724] | 355 | ) |
---|
| 356 | |
---|
| 357 | current_level = schema.Choice( |
---|
[7723] | 358 | title = _(u'Current Level'), |
---|
[6725] | 359 | source = StudyLevelSource(), |
---|
| 360 | required = False, |
---|
[6996] | 361 | readonly = False, |
---|
[6724] | 362 | ) |
---|
| 363 | |
---|
| 364 | current_verdict = schema.Choice( |
---|
[7723] | 365 | title = _(u'Current Verdict'), |
---|
[7619] | 366 | source = VerdictSource(), |
---|
[8820] | 367 | default = '0', |
---|
[6725] | 368 | required = False, |
---|
[6724] | 369 | ) |
---|
| 370 | |
---|
| 371 | previous_verdict = schema.Choice( |
---|
[7723] | 372 | title = _(u'Previous Verdict'), |
---|
[7619] | 373 | source = VerdictSource(), |
---|
[8820] | 374 | default = '0', |
---|
[6725] | 375 | required = False, |
---|
[6724] | 376 | ) |
---|
| 377 | |
---|
[9138] | 378 | class IStudentStudyCourseTransfer(IStudentStudyCourse): |
---|
| 379 | """An student transfers. |
---|
| 380 | |
---|
| 381 | """ |
---|
| 382 | |
---|
| 383 | certificate = schema.Choice( |
---|
| 384 | title = _(u'Certificate'), |
---|
| 385 | source = CertificateSource(), |
---|
| 386 | required = True, |
---|
| 387 | ) |
---|
| 388 | |
---|
| 389 | current_level = schema.Choice( |
---|
| 390 | title = _(u'Current Level'), |
---|
| 391 | source = StudyLevelSource(), |
---|
| 392 | required = True, |
---|
| 393 | readonly = False, |
---|
| 394 | ) |
---|
| 395 | |
---|
| 396 | |
---|
| 397 | IStudentStudyCourseTransfer['certificate'].order = IStudentStudyCourse[ |
---|
| 398 | 'certificate'].order |
---|
| 399 | IStudentStudyCourseTransfer['current_level'].order = IStudentStudyCourse[ |
---|
| 400 | 'current_level'].order |
---|
| 401 | |
---|
[7951] | 402 | class IStudentVerdictUpdate(IKofaObject): |
---|
| 403 | """A interface for verdict imports. |
---|
| 404 | |
---|
| 405 | """ |
---|
| 406 | |
---|
| 407 | current_verdict = schema.Choice( |
---|
| 408 | title = _(u'Current Verdict'), |
---|
| 409 | source = VerdictSource(), |
---|
| 410 | required = True, |
---|
| 411 | ) |
---|
| 412 | |
---|
| 413 | current_session = schema.Choice( |
---|
| 414 | title = _(u'Current Session'), |
---|
| 415 | source = academic_sessions_vocab, |
---|
| 416 | required = True, |
---|
| 417 | ) |
---|
| 418 | |
---|
| 419 | current_level = schema.Choice( |
---|
| 420 | title = _(u'Current Level'), |
---|
| 421 | source = StudyLevelSource(), |
---|
| 422 | required = True, |
---|
| 423 | ) |
---|
| 424 | |
---|
[7819] | 425 | class IStudentStudyLevel(IKofaObject): |
---|
[6774] | 426 | """A container for course tickets. |
---|
| 427 | |
---|
| 428 | """ |
---|
| 429 | level = Attribute('The level code') |
---|
[9235] | 430 | number_of_tickets = Attribute('Number of tickets contained in this level') |
---|
[6774] | 431 | |
---|
[6793] | 432 | level_session = schema.Choice( |
---|
[7723] | 433 | title = _(u'Session'), |
---|
[6793] | 434 | source = academic_sessions_vocab, |
---|
[9167] | 435 | required = False, |
---|
[6793] | 436 | ) |
---|
[6781] | 437 | |
---|
[6793] | 438 | level_verdict = schema.Choice( |
---|
[7723] | 439 | title = _(u'Verdict'), |
---|
[7619] | 440 | source = VerdictSource(), |
---|
[8820] | 441 | default = '0', |
---|
[6793] | 442 | required = False, |
---|
| 443 | ) |
---|
| 444 | |
---|
[9161] | 445 | validated_by = schema.TextLine( |
---|
| 446 | title = _(u'Validated by'), |
---|
| 447 | default = None, |
---|
| 448 | required = False, |
---|
| 449 | ) |
---|
| 450 | |
---|
| 451 | validation_date = schema.Datetime( |
---|
| 452 | title = _(u'Validation Date'), |
---|
| 453 | required = False, |
---|
| 454 | readonly = False, |
---|
| 455 | ) |
---|
| 456 | |
---|
[8920] | 457 | def addCourseTicket(ticket, course): |
---|
[8182] | 458 | """Add a course ticket object. |
---|
| 459 | """ |
---|
| 460 | |
---|
[7819] | 461 | class ICourseTicket(IKofaObject): |
---|
[6781] | 462 | """A course ticket. |
---|
| 463 | |
---|
| 464 | """ |
---|
[6783] | 465 | code = Attribute('code of the original course') |
---|
| 466 | title = Attribute('title of the original course') |
---|
| 467 | credits = Attribute('credits of the original course') |
---|
| 468 | passmark = Attribute('passmark of the original course') |
---|
| 469 | semester = Attribute('semester of the original course') |
---|
[7304] | 470 | fcode = Attribute('faculty code of the original course') |
---|
| 471 | dcode = Attribute('department code of the original course') |
---|
[6781] | 472 | |
---|
[7665] | 473 | mandatory = schema.Bool( |
---|
[7723] | 474 | title = _(u'Mandatory'), |
---|
[6795] | 475 | default = False, |
---|
| 476 | required = False, |
---|
| 477 | readonly = False, |
---|
| 478 | ) |
---|
| 479 | |
---|
[6781] | 480 | score = schema.Int( |
---|
[7723] | 481 | title = _(u'Score'), |
---|
[6781] | 482 | default = 0, |
---|
| 483 | required = False, |
---|
| 484 | readonly = False, |
---|
| 485 | ) |
---|
| 486 | |
---|
[6806] | 487 | automatic = schema.Bool( |
---|
[7723] | 488 | title = _(u'Automatical Creation'), |
---|
[6806] | 489 | default = False, |
---|
| 490 | required = False, |
---|
| 491 | readonly = True, |
---|
| 492 | ) |
---|
| 493 | |
---|
[7661] | 494 | carry_over = schema.Bool( |
---|
[7723] | 495 | title = _(u'Carry-over Course'), |
---|
[7661] | 496 | default = False, |
---|
| 497 | required = False, |
---|
| 498 | readonly = False, |
---|
| 499 | ) |
---|
| 500 | |
---|
[7633] | 501 | def getLevel(): |
---|
| 502 | """Returns the id of the level the ticket has been added to. |
---|
| 503 | """ |
---|
| 504 | |
---|
| 505 | def getLevelSession(): |
---|
| 506 | """Returns the session of the level the ticket has been added to. |
---|
| 507 | """ |
---|
| 508 | |
---|
[6795] | 509 | class ICourseTicketAdd(ICourseTicket): |
---|
[7150] | 510 | """An interface for adding course tickets. |
---|
[6795] | 511 | |
---|
| 512 | """ |
---|
| 513 | course = schema.Choice( |
---|
[7723] | 514 | title = _(u'Course'), |
---|
[6795] | 515 | source = CourseSource(), |
---|
| 516 | readonly = False, |
---|
| 517 | ) |
---|
| 518 | |
---|
[7819] | 519 | class IStudentAccommodation(IKofaObject): |
---|
[6635] | 520 | """A container for student accommodation objects. |
---|
| 521 | |
---|
| 522 | """ |
---|
| 523 | |
---|
[7819] | 524 | class IBedTicket(IKofaObject): |
---|
[6989] | 525 | """A ticket for accommodation booking. |
---|
| 526 | |
---|
| 527 | """ |
---|
[6996] | 528 | bed = Attribute('The bed object.') |
---|
| 529 | |
---|
| 530 | bed_coordinates = schema.TextLine( |
---|
[7723] | 531 | title = _(u'Bed Coordinates'), |
---|
[6992] | 532 | required = False, |
---|
[7014] | 533 | readonly = False, |
---|
[6992] | 534 | ) |
---|
| 535 | |
---|
[6996] | 536 | bed_type = schema.TextLine( |
---|
[7723] | 537 | title = _(u'Bed Type'), |
---|
[6996] | 538 | required = False, |
---|
[7014] | 539 | readonly = False, |
---|
[6996] | 540 | ) |
---|
| 541 | |
---|
[6992] | 542 | booking_session = schema.Choice( |
---|
[7723] | 543 | title = _(u'Session'), |
---|
[6992] | 544 | source = academic_sessions_vocab, |
---|
| 545 | required = True, |
---|
[7014] | 546 | readonly = True, |
---|
[6992] | 547 | ) |
---|
| 548 | |
---|
[8170] | 549 | booking_date = schema.Datetime( |
---|
[7723] | 550 | title = _(u'Booking Date'), |
---|
[6992] | 551 | required = False, |
---|
[7014] | 552 | readonly = True, |
---|
[6992] | 553 | ) |
---|
| 554 | |
---|
| 555 | booking_code = schema.TextLine( |
---|
[7723] | 556 | title = _(u'Booking Activation Code'), |
---|
[6992] | 557 | required = False, |
---|
[7014] | 558 | readonly = True, |
---|
[6992] | 559 | ) |
---|
| 560 | |
---|
[6994] | 561 | def getSessionString(): |
---|
[7633] | 562 | """Returns the title of academic_sessions_vocab term. |
---|
[7150] | 563 | |
---|
[6994] | 564 | """ |
---|
[6992] | 565 | |
---|
[6860] | 566 | class IStudentPaymentsContainer(IPaymentsContainer): |
---|
[6635] | 567 | """A container for student payment objects. |
---|
| 568 | |
---|
| 569 | """ |
---|
| 570 | |
---|
[6877] | 571 | class IStudentOnlinePayment(IOnlinePayment): |
---|
| 572 | """A student payment via payment gateways. |
---|
| 573 | |
---|
| 574 | """ |
---|
| 575 | |
---|
[9148] | 576 | p_current = schema.Bool( |
---|
| 577 | title = _(u'Current Session Payment'), |
---|
| 578 | default = True, |
---|
| 579 | required = False, |
---|
| 580 | ) |
---|
| 581 | |
---|
[8268] | 582 | p_level = schema.Int( |
---|
| 583 | title = _(u'Payment Level'), |
---|
| 584 | required = False, |
---|
| 585 | readonly = True, |
---|
| 586 | ) |
---|
[6877] | 587 | |
---|
[8422] | 588 | def doAfterStudentPayment(): |
---|
| 589 | """Process student after payment was made. |
---|
| 590 | |
---|
| 591 | """ |
---|
| 592 | |
---|
[8453] | 593 | def doAfterStudentPaymentApproval(): |
---|
| 594 | """Process student after payment was approved. |
---|
| 595 | |
---|
| 596 | """ |
---|
| 597 | |
---|
[8420] | 598 | def approveStudentPayment(): |
---|
[8422] | 599 | """Approve payment and process student. |
---|
[8420] | 600 | |
---|
| 601 | """ |
---|
| 602 | |
---|
[8268] | 603 | IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[ |
---|
| 604 | 'p_session'].order |
---|
[8408] | 605 | |
---|
[9148] | 606 | class IStudentPreviousPayment(IOnlinePayment): |
---|
| 607 | """An interface for adding previous session payments. |
---|
| 608 | |
---|
| 609 | """ |
---|
| 610 | |
---|
| 611 | p_session = schema.Choice( |
---|
| 612 | title = _(u'Payment Session'), |
---|
| 613 | source = academic_sessions_vocab, |
---|
| 614 | required = True, |
---|
| 615 | ) |
---|
| 616 | |
---|
| 617 | p_level = schema.Choice( |
---|
| 618 | title = _(u'Payment Level'), |
---|
| 619 | source = StudyLevelSource(), |
---|
| 620 | required = True, |
---|
| 621 | ) |
---|
| 622 | |
---|
[8408] | 623 | class ICSVStudentExporter(ICSVExporter): |
---|
| 624 | """A regular ICSVExporter that additionally supports exporting |
---|
| 625 | data from a given student object. |
---|
| 626 | """ |
---|
| 627 | |
---|
| 628 | def export_student(student, filepath=None): |
---|
| 629 | """Export data for a given student. |
---|
| 630 | """ |
---|