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