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