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