source: main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py @ 10009

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

Start internationalization of students package (work in progress).

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