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