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