source: main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py @ 8341

Last change on this file since 8341 was 8268, checked in by Henrik Bettermann, 13 years ago

Store payment level in student payments.

For school fee paments p_session and p_level are calculated as defined
in w.k.students.utils

  • Property svn:keywords set to Id
File size: 13.9 KB
RevLine 
[7191]1## $Id: interfaces.py 8268 2012-04-25 06:02:54Z 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##
[6996]18from datetime import datetime
[7620]19from zope.component import getUtility
[7256]20from zope.interface import Attribute, Interface
[6621]21from zope import schema
[7620]22from zc.sourcefactory.contextual import BasicContextualSourceFactory
[7811]23from waeup.kofa.interfaces import (
[7819]24    IKofaObject, academic_sessions_vocab, validate_email, IKofaUtils)
[7811]25from waeup.kofa.interfaces import MessageFactory as _
[8176]26from waeup.kofa.schema import TextLineChoice, FormattedDate, PhoneNumber
[7811]27from waeup.kofa.students.vocabularies import (
[7915]28    StudyLevelSource, contextual_reg_num_source, contextual_mat_num_source,
29    GenderSource, nats_vocab,
30    )
[8160]31from waeup.kofa.payments.interfaces import (
[8174]32    IPaymentsContainer, IOnlinePayment)
[7915]33from waeup.kofa.university.vocabularies import (
34    CourseSource, StudyModeSource, CertificateSource)
[6621]35
[7620]36# VerdictSource can't be placed into the vocabularies module because it
37# requires importing IStudentsUtils which then leads to circular imports.
38class VerdictSource(BasicContextualSourceFactory):
39    """A verdicts source delivers all verdicts provided
40    in the portal.
41    """
42    def getValues(self, context):
[7841]43        verdicts_dict = getUtility(IStudentsUtils).VERDICTS_DICT
[7688]44        return verdicts_dict.keys()
[7620]45
46    def getToken(self, context, value):
47        return value
48
49    def getTitle(self, context, value):
[7841]50        verdicts_dict = getUtility(IStudentsUtils).VERDICTS_DICT
[7688]51        return verdicts_dict[value]
[7620]52
[7681]53
[7150]54class IStudentsUtils(Interface):
55    """A collection of methods which are subject to customization.
56
57    """
[7841]58    def setReturningData(student):
59        """ This method defines what happens after school fee payment
60        depending on the student's senate verdict.
61
62        In the base configuration current level is always increased
63        by 100 no matter which verdict has been assigned.
64        """
65
[7186]66    def getPaymentDetails(category, student):
[7150]67        """Get the payment dates of a student for the payment category
68        specified.
69
70        """
71
[7186]72    def getAccommodation_details(student):
[7150]73        """Determine the accommodation dates of a student.
74
75        """
76
[7186]77    def selectBed(available_beds):
[7150]78        """Select a bed from a list of available beds.
79
80        In the standard configuration we select the first bed found,
81        but can also randomize the selection if we like.
82        """
83
[7186]84    def renderPDF(view, subject='', filename='slip.pdf',):
[7150]85        """Render pdf slips for various pages.
86
87        """
88
[7819]89class IStudentsContainer(IKofaObject):
[7096]90    """A students container contains university students.
[6692]91
92    """
93    def addStudent(student):
94        """Add an IStudent object and subcontainers.
95
96        """
97
98    def archive(id=None):
99        """Create on-dist archive of students.
100
101        If id is `None`, all students are archived.
102
103        If id contains a single id string, only the respective
104        students are archived.
105
106        If id contains a list of id strings all of the respective
107        students types are saved to disk.
108        """
109
110    def clear(id=None, archive=True):
111        """Remove students of type given by 'id'.
112
113        Optionally archive the students.
114
115        If id is `None`, all students are archived.
116
117        If id contains a single id string, only the respective
118        students are archived.
119
120        If id contains a list of id strings all of the respective
121        student types are saved to disk.
122
123        If `archive` is ``False`` none of the archive-handling is done
124        and respective students are simply removed from the
125        database.
126        """
127
[7819]128class IStudentNavigation(IKofaObject):
[6642]129    """Interface needed for student navigation.
[7150]130
[6642]131    """
132    def getStudent():
133        """Return student object.
[7150]134
[6642]135        """
136
[7819]137class IStudentBase(IKofaObject):
[6631]138    """Representation of student base data.
[7150]139
[6621]140    """
[7062]141    history = Attribute('Object history, a list of messages')
[6637]142    state = Attribute('Returns the registration state of a student')
[6699]143    password = Attribute('Encrypted password of a student')
[7203]144    certcode = Attribute('The certificate code of any chosen study course')
145    depcode = Attribute('The department code of any chosen study course')
146    faccode = Attribute('The faculty code of any chosen study course')
[7062]147    current_session = Attribute('The current session of the student')
[7641]148    current_mode = Attribute('The current mode of the student')
[7364]149    fullname = Attribute('All name parts separated by hyphens')
150    display_fullname = Attribute('The fullname of an applicant')
[6637]151
152    def loggerInfo(ob_class, comment):
[7150]153        """Adds an INFO message to the log file.
154
[6637]155        """
156
[6665]157    student_id = schema.TextLine(
[7723]158        title = _(u'Student Id'),
[6849]159        required = False,
[6665]160        )
161
[7357]162    firstname = schema.TextLine(
[7723]163        title = _(u'First Name'),
[6621]164        required = True,
165        )
166
[7357]167    middlename = schema.TextLine(
[7723]168        title = _(u'Middle Name'),
[7357]169        required = False,
170        )
171
172    lastname = schema.TextLine(
[7723]173        title = _(u'Last Name (Surname)'),
[7357]174        required = True,
175        )
176
[6996]177    sex = schema.Choice(
[7723]178        title = _(u'Sex'),
[6996]179        source = GenderSource(),
180        required = True,
181        )
182
[6788]183    reg_number = TextLineChoice(
[7723]184        title = _(u'Registration Number'),
[6696]185        required = True,
186        readonly = False,
[6788]187        source = contextual_reg_num_source,
[6696]188        )
189
[6788]190    matric_number = TextLineChoice(
[7723]191        title = _(u'Matriculation Number'),
[6750]192        required = False,
193        readonly = False,
[6788]194        source = contextual_mat_num_source,
[6750]195        )
196
[6769]197    adm_code = schema.TextLine(
[7723]198        title = _(u'PWD Activation Code'),
[6769]199        required = False,
200        readonly = True,
201        )
202
[7133]203    email = schema.ASCIILine(
[7723]204        title = _(u'Email'),
[7133]205        required = False,
206        constraint=validate_email,
207        )
[8176]208    phone = PhoneNumber(
[7723]209        title = _(u'Phone'),
[7331]210        description = u'',
[7133]211        required = False,
212        )
213
[7993]214class IUGStudentClearance(IKofaObject):
215    """Representation of undergraduate student clearance data.
[7150]216
[6631]217    """
[8160]218    date_of_birth = FormattedDate(
[7723]219        title = _(u'Date of Birth'),
[6631]220        required = True,
[8160]221        show_year = True,
[6631]222        )
223
[6695]224    clearance_locked = schema.Bool(
[7723]225        title = _(u'Clearance form locked'),
[6695]226        default = False,
227        )
228
[6769]229    clr_code = schema.TextLine(
[7723]230        title = _(u'CLR Activation Code'),
[6769]231        required = False,
232        readonly = True,
233        )
234
[7523]235    nationality = schema.Choice(
[8069]236        vocabulary = nats_vocab,
[7723]237        title = _(u'Nationality'),
[7983]238        required = False,
[7523]239        )
240
[7993]241class IPGStudentClearance(IUGStudentClearance):
242    """Representation of postgraduate student clearance data.
243
244    """
245    employer = schema.TextLine(
246        title = _(u'Employer'),
247        required = False,
248        readonly = False,
249        )
250
[7819]251class IStudentPersonal(IKofaObject):
[6631]252    """Representation of student personal data.
[7150]253
[6631]254    """
[6651]255    perm_address = schema.Text(
[7723]256        title = _(u'Permanent Address'),
[6631]257        required = False,
258        )
259
[8008]260class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance,
261    IStudentPersonal):
[6631]262    """Representation of a student.
[7150]263
[6631]264    """
265
[6849]266class IStudentUpdateByRegNo(IStudent):
267    """Representation of a student. Skip regular reg_number validation.
[7150]268
[6849]269    """
270    reg_number = schema.TextLine(
[7723]271        title = _(u'Registration Number'),
[6849]272        required = False,
273        )
274
275class IStudentUpdateByMatricNo(IStudent):
276    """Representation of a student. Skip regular matric_number validation.
[7150]277
[6849]278    """
279    matric_number = schema.TextLine(
[7723]280        title = _(u'Matriculation Number'),
[6849]281        required = False,
282        )
283
[7819]284class IStudentStudyCourse(IKofaObject):
[6633]285    """A container for student study levels.
286
287    """
[6648]288    certificate = schema.Choice(
[7723]289        title = _(u'Certificate'),
[6648]290        source = CertificateSource(),
[7209]291        required = False,
[6633]292        )
[6635]293
[6996]294    entry_mode = schema.Choice(
[7723]295        title = _(u'Entry Mode'),
[7681]296        source = StudyModeSource(),
[6996]297        required = True,
298        readonly = False,
299        )
300
301    entry_session = schema.Choice(
[7723]302        title = _(u'Entry Session'),
[6996]303        source = academic_sessions_vocab,
[7425]304        #default = datetime.now().year,
[6996]305        required = True,
306        readonly = False,
307        )
308
[6724]309    current_session = schema.Choice(
[7723]310        title = _(u'Current Session'),
[6744]311        source = academic_sessions_vocab,
[6724]312        required = True,
[6996]313        readonly = False,
[6724]314        )
315
316    current_level = schema.Choice(
[7723]317        title = _(u'Current Level'),
[6725]318        source = StudyLevelSource(),
319        required = False,
[6996]320        readonly = False,
[6724]321        )
322
323    current_verdict = schema.Choice(
[7723]324        title = _(u'Current Verdict'),
[7619]325        source = VerdictSource(),
[6804]326        default = '0',
[6725]327        required = False,
[6724]328        )
329
330    previous_verdict = schema.Choice(
[7723]331        title = _(u'Previous Verdict'),
[7619]332        source = VerdictSource(),
[6805]333        default = '0',
[6725]334        required = False,
[6724]335        )
336
[7951]337class IStudentVerdictUpdate(IKofaObject):
338    """A interface for verdict imports.
339
340    """
341
342    current_verdict = schema.Choice(
343        title = _(u'Current Verdict'),
344        source = VerdictSource(),
345        required = True,
346        )
347
348    current_session = schema.Choice(
349        title = _(u'Current Session'),
350        source = academic_sessions_vocab,
351        required = True,
352        )
353
354    current_level = schema.Choice(
355        title = _(u'Current Level'),
356        source = StudyLevelSource(),
357        required = True,
358        )
359
[7819]360class IStudentStudyLevel(IKofaObject):
[6774]361    """A container for course tickets.
362
363    """
364    level = Attribute('The level code')
[6793]365    validation_date = Attribute('The date of validation')
366    validated_by = Attribute('User Id of course adviser')
[6774]367
[6793]368    level_session = schema.Choice(
[7723]369        title = _(u'Session'),
[6793]370        source = academic_sessions_vocab,
371        required = True,
372        )
[6781]373
[6793]374    level_verdict = schema.Choice(
[7723]375        title = _(u'Verdict'),
[7619]376        source = VerdictSource(),
[6805]377        default = '0',
[6793]378        required = False,
379        )
380
[8182]381    def addCourseTicket(courseticket):
382        """Add a course ticket object.
383        """
384
385    def getStudent():
386        """Return student
387        """
388
[7819]389class ICourseTicket(IKofaObject):
[6781]390    """A course ticket.
391
392    """
[6783]393    code = Attribute('code of the original course')
394    title = Attribute('title of the original course')
395    credits = Attribute('credits of the original course')
396    passmark = Attribute('passmark of the original course')
397    semester = Attribute('semester of the original course')
[7304]398    fcode = Attribute('faculty code of the original course')
399    dcode = Attribute('department code of the original course')
[6781]400
[7665]401    mandatory = schema.Bool(
[7723]402        title = _(u'Mandatory'),
[6795]403        default = False,
404        required = False,
405        readonly = False,
406        )
407
[6781]408    score = schema.Int(
[7723]409        title = _(u'Score'),
[6781]410        default = 0,
411        required = False,
412        readonly = False,
413        )
414
[6806]415    automatic = schema.Bool(
[7723]416        title = _(u'Automatical Creation'),
[6806]417        default = False,
418        required = False,
419        readonly = True,
420        )
421
[7661]422    carry_over = schema.Bool(
[7723]423        title = _(u'Carry-over Course'),
[7661]424        default = False,
425        required = False,
426        readonly = False,
427        )
428
[7633]429    def getLevel():
430        """Returns the id of the level the ticket has been added to.
431        """
432
433    def getLevelSession():
434        """Returns the session of the level the ticket has been added to.
435        """
436
[6795]437class ICourseTicketAdd(ICourseTicket):
[7150]438    """An interface for adding course tickets.
[6795]439
440    """
441    course = schema.Choice(
[7723]442        title = _(u'Course'),
[6795]443        source = CourseSource(),
444        readonly = False,
445        )
446
[7819]447class IStudentAccommodation(IKofaObject):
[6635]448    """A container for student accommodation objects.
449
450    """
451
[7819]452class IBedTicket(IKofaObject):
[6989]453    """A ticket for accommodation booking.
454
455    """
[6996]456    bed = Attribute('The bed object.')
457
458    bed_coordinates = schema.TextLine(
[7723]459        title = _(u'Bed Coordinates'),
[6992]460        required = False,
[7014]461        readonly = False,
[6992]462        )
463
[6996]464    bed_type = schema.TextLine(
[7723]465        title = _(u'Bed Type'),
[6996]466        required = False,
[7014]467        readonly = False,
[6996]468        )
469
[6992]470    booking_session = schema.Choice(
[7723]471        title = _(u'Session'),
[6992]472        source = academic_sessions_vocab,
473        required = True,
[7014]474        readonly = True,
[6992]475        )
476
[8170]477    booking_date = schema.Datetime(
[7723]478        title = _(u'Booking Date'),
[6992]479        required = False,
[7014]480        readonly = True,
[6992]481        )
482
483    booking_code = schema.TextLine(
[7723]484        title = _(u'Booking Activation Code'),
[6992]485        required = False,
[7014]486        readonly = True,
[6992]487        )
488
[6994]489    def getSessionString():
[7633]490        """Returns the title of academic_sessions_vocab term.
[7150]491
[6994]492        """
[6992]493
[6860]494class IStudentPaymentsContainer(IPaymentsContainer):
[6635]495    """A container for student payment objects.
496
497    """
498
[6877]499class IStudentOnlinePayment(IOnlinePayment):
500    """A student payment via payment gateways.
501
502    """
503
[8268]504    p_level = schema.Int(
505        title = _(u'Payment Level'),
506        required = False,
507        readonly = True,
508        )
[6877]509
[8268]510IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[
511    'p_session'].order
[8160]512
[8268]513
[7819]514class IStudentChangePassword(IKofaObject):
[7369]515    """Interface needed for change pasword page.
516
517    """
518    reg_number = schema.TextLine(
[7723]519        title = _(u'Registration Number'),
[7369]520        required = True,
521        readonly = False,
522        )
523
524    email = schema.ASCIILine(
[7723]525        title = _(u'Email Address'),
[7369]526        required = True,
527        constraint=validate_email,
528        )
Note: See TracBrowser for help on using the repository browser.