[7191] | 1 | ## $Id: interfaces.py 9182 2012-09-14 05:31:47Z 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') |
---|
[9182] | 157 | current_verdict = Attribute('The current verdict of the student') |
---|
[7364] | 158 | fullname = Attribute('All name parts separated by hyphens') |
---|
| 159 | display_fullname = Attribute('The fullname of an applicant') |
---|
[8969] | 160 | is_postgrad = Attribute('True if postgraduate student') |
---|
[6637] | 161 | |
---|
[8983] | 162 | suspended = schema.Bool( |
---|
| 163 | title = _(u'Account suspended'), |
---|
| 164 | default = False, |
---|
[9035] | 165 | required = False, |
---|
[8983] | 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, |
---|
[8977] | 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 | |
---|
[9131] | 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, |
---|
[9035] | 244 | required = False, |
---|
[6695] | 245 | ) |
---|
| 246 | |
---|
[6769] | 247 | clr_code = schema.TextLine( |
---|
[7723] | 248 | title = _(u'CLR Activation Code'), |
---|
[6769] | 249 | required = False, |
---|
[8977] | 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 | """ |
---|
[8854] | 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(), |
---|
[8820] | 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(), |
---|
[8820] | 373 | default = '0', |
---|
[6725] | 374 | required = False, |
---|
[6724] | 375 | ) |
---|
| 376 | |
---|
[9138] | 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, |
---|
[9167] | 433 | required = False, |
---|
[6793] | 434 | ) |
---|
[6781] | 435 | |
---|
[6793] | 436 | level_verdict = schema.Choice( |
---|
[7723] | 437 | title = _(u'Verdict'), |
---|
[7619] | 438 | source = VerdictSource(), |
---|
[8820] | 439 | default = '0', |
---|
[6793] | 440 | required = False, |
---|
| 441 | ) |
---|
| 442 | |
---|
[9161] | 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 | |
---|
[8920] | 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 | |
---|
[9148] | 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 | |
---|
[9148] | 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 | """ |
---|