source: main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/students/interfaces.py @ 10009

Last change on this file since 10009 was 9211, checked in by uli, 12 years ago

Rollback r9209. Looks like multiple merges from trunk confuse svn when merging back into trunk.

  • Property svn:keywords set to Id
File size: 14.8 KB
RevLine 
[7191]1## $Id: interfaces.py 9211 2012-09-21 08:19:35Z uli $
[6621]2##
[7191]3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
[8409]18#from datetime import datetime
[7620]19from zope.component import getUtility
[7256]20from zope.interface import Attribute, Interface
[6621]21from zope import schema
[7620]22from zc.sourcefactory.contextual import BasicContextualSourceFactory
[9004]23from waeup.kofa.browser.interfaces import IStudentNavigationBase
[7811]24from waeup.kofa.interfaces import (
[8409]25    IKofaObject, academic_sessions_vocab, validate_email, ICSVExporter)
[7811]26from waeup.kofa.interfaces import MessageFactory as _
[8176]27from waeup.kofa.schema import TextLineChoice, FormattedDate, PhoneNumber
[7811]28from waeup.kofa.students.vocabularies import (
[7915]29    StudyLevelSource, contextual_reg_num_source, contextual_mat_num_source,
30    GenderSource, nats_vocab,
31    )
[8160]32from waeup.kofa.payments.interfaces import (
[8174]33    IPaymentsContainer, IOnlinePayment)
[7915]34from waeup.kofa.university.vocabularies import (
35    CourseSource, StudyModeSource, CertificateSource)
[6621]36
[7620]37# VerdictSource can't be placed into the vocabularies module because it
38# requires importing IStudentsUtils which then leads to circular imports.
39class VerdictSource(BasicContextualSourceFactory):
40    """A verdicts source delivers all verdicts provided
41    in the portal.
42    """
43    def getValues(self, context):
[7841]44        verdicts_dict = getUtility(IStudentsUtils).VERDICTS_DICT
[9211]45        return verdicts_dict.keys()
[7620]46
47    def getToken(self, context, value):
48        return value
49
50    def getTitle(self, context, value):
[7841]51        verdicts_dict = getUtility(IStudentsUtils).VERDICTS_DICT
[7688]52        return verdicts_dict[value]
[7620]53
[7681]54
[7150]55class IStudentsUtils(Interface):
56    """A collection of methods which are subject to customization.
57
58    """
[7841]59    def setReturningData(student):
60        """ This method defines what happens after school fee payment
61        depending on the student's senate verdict.
62
63        In the base configuration current level is always increased
64        by 100 no matter which verdict has been assigned.
65        """
66
[9211]67    def setPaymentDetails(category, student):
[8595]68        """Create Payment object and set the payment data of a student for
69        the payment category specified.
[7150]70
71        """
72
[7186]73    def getAccommodation_details(student):
[7150]74        """Determine the accommodation dates of a student.
75
76        """
77
[7186]78    def selectBed(available_beds):
[7150]79        """Select a bed from a list of available beds.
80
81        In the standard configuration we select the first bed found,
82        but can also randomize the selection if we like.
83        """
84
[7186]85    def renderPDF(view, subject='', filename='slip.pdf',):
[7150]86        """Render pdf slips for various pages.
87
88        """
89
[7819]90class IStudentsContainer(IKofaObject):
[7096]91    """A students container contains university students.
[6692]92
93    """
94    def addStudent(student):
95        """Add an IStudent object and subcontainers.
96
97        """
98
99    def archive(id=None):
100        """Create on-dist archive of students.
101
102        If id is `None`, all students are archived.
103
104        If id contains a single id string, only the respective
105        students are archived.
106
107        If id contains a list of id strings all of the respective
108        students types are saved to disk.
109        """
110
111    def clear(id=None, archive=True):
112        """Remove students of type given by 'id'.
113
114        Optionally archive the students.
115
116        If id is `None`, all students are archived.
117
118        If id contains a single id string, only the respective
119        students are archived.
120
121        If id contains a list of id strings all of the respective
122        student types are saved to disk.
123
124        If `archive` is ``False`` none of the archive-handling is done
125        and respective students are simply removed from the
126        database.
127        """
128
[8408]129    unique_student_id = Attribute("""A unique student id.""")
130
[9004]131class IStudentNavigation(IStudentNavigationBase):
[8735]132    """Interface needed for student navigation, logging, etc.
[7150]133
[6642]134    """
[8736]135    student = Attribute('Student object of context.')
[7150]136
[8735]137    def writeLogMessage(view, message):
138        """Write a view specific log message into students.log.
139
140        """
141
[7819]142class IStudentBase(IKofaObject):
[6631]143    """Representation of student base data.
[7150]144
[6621]145    """
[7062]146    history = Attribute('Object history, a list of messages')
[6637]147    state = Attribute('Returns the registration state of a student')
[6699]148    password = Attribute('Encrypted password of a student')
[7203]149    certcode = Attribute('The certificate code of any chosen study course')
150    depcode = Attribute('The department code of any chosen study course')
151    faccode = Attribute('The faculty code of any chosen study course')
[7062]152    current_session = Attribute('The current session of the student')
[7641]153    current_mode = Attribute('The current mode of the student')
[7364]154    fullname = Attribute('All name parts separated by hyphens')
155    display_fullname = Attribute('The fullname of an applicant')
[6637]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,
[9211]200        readonly = True,
[6769]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,
[9211]232        readonly = True,
[6769]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
[8779]284class IStudentRequestPW(IStudent):
285    """Representation of an student for first-time password request.
286
287    This interface is used when students use the requestpw page to
288    login for the the first time.
289    """
[9211]290    reg_number = schema.TextLine(
291        title = u'Registration Number',
[8779]292        required = True,
293        )
294
295    firstname = schema.TextLine(
296        title = _(u'First Name'),
297        required = True,
298        )
299
300    email = schema.ASCIILine(
301        title = _(u'Email Address'),
302        required = True,
303        constraint=validate_email,
304        )
305
[7819]306class IStudentStudyCourse(IKofaObject):
[6633]307    """A container for student study levels.
308
309    """
[6648]310    certificate = schema.Choice(
[7723]311        title = _(u'Certificate'),
[6648]312        source = CertificateSource(),
[7209]313        required = False,
[6633]314        )
[6635]315
[6996]316    entry_mode = schema.Choice(
[7723]317        title = _(u'Entry Mode'),
[7681]318        source = StudyModeSource(),
[6996]319        required = True,
320        readonly = False,
321        )
322
323    entry_session = schema.Choice(
[7723]324        title = _(u'Entry Session'),
[6996]325        source = academic_sessions_vocab,
[7425]326        #default = datetime.now().year,
[6996]327        required = True,
328        readonly = False,
329        )
330
[6724]331    current_session = schema.Choice(
[7723]332        title = _(u'Current Session'),
[6744]333        source = academic_sessions_vocab,
[6724]334        required = True,
[6996]335        readonly = False,
[6724]336        )
337
338    current_level = schema.Choice(
[7723]339        title = _(u'Current Level'),
[6725]340        source = StudyLevelSource(),
341        required = False,
[6996]342        readonly = False,
[6724]343        )
344
345    current_verdict = schema.Choice(
[7723]346        title = _(u'Current Verdict'),
[7619]347        source = VerdictSource(),
[9211]348        default = 'NY',
[6725]349        required = False,
[6724]350        )
351
352    previous_verdict = schema.Choice(
[7723]353        title = _(u'Previous Verdict'),
[7619]354        source = VerdictSource(),
[9211]355        default = 'NY',
[6725]356        required = False,
[6724]357        )
358
[7951]359class IStudentVerdictUpdate(IKofaObject):
360    """A interface for verdict imports.
361
362    """
363
364    current_verdict = schema.Choice(
365        title = _(u'Current Verdict'),
366        source = VerdictSource(),
367        required = True,
368        )
369
370    current_session = schema.Choice(
371        title = _(u'Current Session'),
372        source = academic_sessions_vocab,
373        required = True,
374        )
375
376    current_level = schema.Choice(
377        title = _(u'Current Level'),
378        source = StudyLevelSource(),
379        required = True,
380        )
381
[7819]382class IStudentStudyLevel(IKofaObject):
[6774]383    """A container for course tickets.
384
385    """
386    level = Attribute('The level code')
[9211]387    validation_date = Attribute('The date of validation')
388    validated_by = Attribute('User Id of course adviser')
[6774]389
[6793]390    level_session = schema.Choice(
[7723]391        title = _(u'Session'),
[6793]392        source = academic_sessions_vocab,
[9211]393        required = True,
[6793]394        )
[6781]395
[6793]396    level_verdict = schema.Choice(
[7723]397        title = _(u'Verdict'),
[7619]398        source = VerdictSource(),
[9211]399        default = 'NY',
[6793]400        required = False,
401        )
402
[9211]403    def addCourseTicket(courseticket):
[8182]404        """Add a course ticket object.
405        """
406
[7819]407class ICourseTicket(IKofaObject):
[6781]408    """A course ticket.
409
410    """
[6783]411    code = Attribute('code of the original course')
412    title = Attribute('title of the original course')
413    credits = Attribute('credits of the original course')
414    passmark = Attribute('passmark of the original course')
415    semester = Attribute('semester of the original course')
[7304]416    fcode = Attribute('faculty code of the original course')
417    dcode = Attribute('department code of the original course')
[6781]418
[7665]419    mandatory = schema.Bool(
[7723]420        title = _(u'Mandatory'),
[6795]421        default = False,
422        required = False,
423        readonly = False,
424        )
425
[6781]426    score = schema.Int(
[7723]427        title = _(u'Score'),
[6781]428        default = 0,
429        required = False,
430        readonly = False,
431        )
432
[6806]433    automatic = schema.Bool(
[7723]434        title = _(u'Automatical Creation'),
[6806]435        default = False,
436        required = False,
437        readonly = True,
438        )
439
[7661]440    carry_over = schema.Bool(
[7723]441        title = _(u'Carry-over Course'),
[7661]442        default = False,
443        required = False,
444        readonly = False,
445        )
446
[7633]447    def getLevel():
448        """Returns the id of the level the ticket has been added to.
449        """
450
451    def getLevelSession():
452        """Returns the session of the level the ticket has been added to.
453        """
454
[6795]455class ICourseTicketAdd(ICourseTicket):
[7150]456    """An interface for adding course tickets.
[6795]457
458    """
459    course = schema.Choice(
[7723]460        title = _(u'Course'),
[6795]461        source = CourseSource(),
462        readonly = False,
463        )
464
[7819]465class IStudentAccommodation(IKofaObject):
[6635]466    """A container for student accommodation objects.
467
468    """
469
[7819]470class IBedTicket(IKofaObject):
[6989]471    """A ticket for accommodation booking.
472
473    """
[6996]474    bed = Attribute('The bed object.')
475
476    bed_coordinates = schema.TextLine(
[7723]477        title = _(u'Bed Coordinates'),
[6992]478        required = False,
[7014]479        readonly = False,
[6992]480        )
481
[6996]482    bed_type = schema.TextLine(
[7723]483        title = _(u'Bed Type'),
[6996]484        required = False,
[7014]485        readonly = False,
[6996]486        )
487
[6992]488    booking_session = schema.Choice(
[7723]489        title = _(u'Session'),
[6992]490        source = academic_sessions_vocab,
491        required = True,
[7014]492        readonly = True,
[6992]493        )
494
[8170]495    booking_date = schema.Datetime(
[7723]496        title = _(u'Booking Date'),
[6992]497        required = False,
[7014]498        readonly = True,
[6992]499        )
500
501    booking_code = schema.TextLine(
[7723]502        title = _(u'Booking Activation Code'),
[6992]503        required = False,
[7014]504        readonly = True,
[6992]505        )
506
[6994]507    def getSessionString():
[7633]508        """Returns the title of academic_sessions_vocab term.
[7150]509
[6994]510        """
[6992]511
[6860]512class IStudentPaymentsContainer(IPaymentsContainer):
[6635]513    """A container for student payment objects.
514
515    """
516
[6877]517class IStudentOnlinePayment(IOnlinePayment):
518    """A student payment via payment gateways.
519
520    """
521
[8268]522    p_level = schema.Int(
523        title = _(u'Payment Level'),
524        required = False,
525        readonly = True,
526        )
[6877]527
[8422]528    def doAfterStudentPayment():
529        """Process student after payment was made.
530
531        """
532
[8453]533    def doAfterStudentPaymentApproval():
534        """Process student after payment was approved.
535
536        """
537
[8420]538    def approveStudentPayment():
[8422]539        """Approve payment and process student.
[8420]540
541        """
542
[8268]543IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[
544    'p_session'].order
[8408]545
546class ICSVStudentExporter(ICSVExporter):
547    """A regular ICSVExporter that additionally supports exporting
548      data from a given student object.
549    """
550
551    def export_student(student, filepath=None):
552        """Export data for a given student.
553        """
Note: See TracBrowser for help on using the repository browser.