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

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

Remove unnecessary or duplicate imports.

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