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