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

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

Adjust copyright statement and svn keyword in students.

  • Property svn:keywords set to Id
File size: 11.7 KB
RevLine 
[7191]1## $Id: interfaces.py 7191 2011-11-25 07:13:22Z 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 (
[6788]27  CertificateSource, academic_sessions_vocab, 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')
[6814]125    certificate = Attribute('The certificate of any chosen study course')
[7062]126    current_session = Attribute('The current session of the student')
[6637]127
128    def loggerInfo(ob_class, comment):
[7150]129        """Adds an INFO message to the log file.
130
[6637]131        """
132
[6665]133    student_id = schema.TextLine(
134        title = u'Student ID',
[6849]135        required = False,
[6665]136        )
137
[6818]138    fullname = schema.TextLine(
[6631]139        title = u'Full Name',
[6818]140        default = None,
[6621]141        required = True,
142        )
143
[6996]144    sex = schema.Choice(
145        title = u'Sex',
146        source = GenderSource(),
147        default = u'm',
148        required = True,
149        )
150
[6788]151    reg_number = TextLineChoice(
[6696]152        title = u'Registration Number',
[6818]153        default = None,
[6696]154        required = True,
155        readonly = False,
[6788]156        source = contextual_reg_num_source,
[6696]157        )
158
[6788]159    matric_number = TextLineChoice(
[6750]160        title = u'Matriculation Number',
[6788]161        #default = u'',
[6750]162        required = False,
163        readonly = False,
[6788]164        source = contextual_mat_num_source,
[6750]165        )
166
[6769]167    adm_code = schema.TextLine(
[6935]168        title = u'PWD Activation Code',
[6769]169        default = u'',
170        required = False,
171        readonly = True,
172        )
173
[7133]174    email = schema.ASCIILine(
175        title = u'Email',
176        required = False,
177        constraint=validate_email,
178        )
179    phone = schema.Int(
180        title = u'Phone',
181        description = u'Enter phone number with country code and without spaces.',
182        required = False,
183        )
184
[6631]185class IStudentClearance(IWAeUPObject):
186    """Representation of student clearance data.
[7150]187
[6631]188    """
189    date_of_birth = schema.Date(
190        title = u'Date of Birth',
191        required = True,
192        )
193
[6695]194    clearance_locked = schema.Bool(
195        title = u'Clearance form locked',
196        default = False,
197        )
198
[6769]199    clr_code = schema.TextLine(
[6935]200        title = u'CLR Activation Code',
[6769]201        default = u'',
202        required = False,
203        readonly = True,
204        )
205
[6631]206class IStudentPersonal(IWAeUPObject):
207    """Representation of student personal data.
[7150]208
[6631]209    """
[6651]210    perm_address = schema.Text(
[6631]211        title = u'Permanent Address',
212        required = False,
213        )
214
215class IStudent(IStudentBase,IStudentClearance,IStudentPersonal):
216    """Representation of a student.
[7150]217
[6631]218    """
219
[6849]220class IStudentUpdateByRegNo(IStudent):
221    """Representation of a student. Skip regular reg_number validation.
[7150]222
[6849]223    """
224    reg_number = schema.TextLine(
225        title = u'Registration Number',
226        default = None,
227        required = False,
228        )
229
230class IStudentUpdateByMatricNo(IStudent):
231    """Representation of a student. Skip regular matric_number validation.
[7150]232
[6849]233    """
234    matric_number = schema.TextLine(
235        title = u'Matriculation Number',
236        default = None,
237        required = False,
238        )
239
[6633]240class IStudentStudyCourse(IWAeUPObject):
241    """A container for student study levels.
242
243    """
[6648]244    certificate = schema.Choice(
245        title = u'Certificate',
246        source = CertificateSource(),
247        default = None,
[6633]248        required = True,
249        )
[6635]250
[6996]251
252    entry_mode = schema.Choice(
253        title = u'Entry Mode',
254        vocabulary = study_modes,
255        default = u'ug_ft',
256        required = True,
257        readonly = False,
258        )
259
260    entry_session = schema.Choice(
261        title = u'Entry Session',
262        source = academic_sessions_vocab,
263        default = datetime.now().year,
264        required = True,
265        readonly = False,
266        )
267
[6724]268    current_session = schema.Choice(
269        title = u'Current Session',
[6744]270        source = academic_sessions_vocab,
[6724]271        default = None,
272        required = True,
[6996]273        readonly = False,
[6724]274        )
275
276    current_level = schema.Choice(
277        title = u'Current Level',
[6725]278        source = StudyLevelSource(),
[6724]279        default = None,
[6725]280        required = False,
[6996]281        readonly = False,
[6724]282        )
283
284    current_verdict = schema.Choice(
285        title = u'Current Verdict',
286        source = verdicts,
[6804]287        default = '0',
[6725]288        required = False,
[6724]289        )
290
291    previous_verdict = schema.Choice(
292        title = u'Previous Verdict',
293        source = verdicts,
[6805]294        default = '0',
[6725]295        required = False,
[6724]296        )
297
[6825]298class IStudentStudyCourseImport(IStudentStudyCourse):
299    """A container for student study levels.
300
301    """
302    current_level = schema.Int(
303        title = u'Current Level',
304        default = None,
305        )
306
[6774]307class IStudentStudyLevel(IWAeUPObject):
308    """A container for course tickets.
309
310    """
311    level = Attribute('The level code')
[6793]312    validation_date = Attribute('The date of validation')
313    validated_by = Attribute('User Id of course adviser')
[6774]314
[6793]315    level_session = schema.Choice(
316        title = u'Session',
317        source = academic_sessions_vocab,
318        default = None,
319        required = True,
320        )
[6781]321
[6793]322    level_verdict = schema.Choice(
323        title = u'Verdict',
324        source = verdicts,
[6805]325        default = '0',
[6793]326        required = False,
327        )
328
[6781]329class ICourseTicket(IWAeUPObject):
330    """A course ticket.
331
332    """
[6783]333    code = Attribute('code of the original course')
334    title = Attribute('title of the original course')
335    credits = Attribute('credits of the original course')
336    passmark = Attribute('passmark of the original course')
337    semester = Attribute('semester of the original course')
338    faculty = Attribute('faculty of the original course')
339    department = Attribute('department of the original course')
[6781]340
[6795]341    core_or_elective = schema.Bool(
342        title = u'Mandatory',
343        default = False,
344        required = False,
345        readonly = False,
346        )
347
[6781]348    score = schema.Int(
349        title = u'Score',
350        default = 0,
351        required = False,
352        readonly = False,
353        )
354
[6806]355    automatic = schema.Bool(
356        title = u'Automatical Creation',
357        default = False,
358        required = False,
359        readonly = True,
360        )
361
[6795]362class ICourseTicketAdd(ICourseTicket):
[7150]363    """An interface for adding course tickets.
[6795]364
365    """
366    course = schema.Choice(
367        title = u'Course',
368        source = CourseSource(),
369        readonly = False,
370        )
371
[6635]372class IStudentAccommodation(IWAeUPObject):
373    """A container for student accommodation objects.
374
375    """
376
[6989]377class IBedTicket(IWAeUPObject):
378    """A ticket for accommodation booking.
379
380    """
[6996]381    bed = Attribute('The bed object.')
382
383    bed_coordinates = schema.TextLine(
384        title = u'Bed Coordinates',
[6992]385        default = None,
386        required = False,
[7014]387        readonly = False,
[6992]388        )
389
[6996]390    bed_type = schema.TextLine(
391        title = u'Bed Type',
392        default = None,
393        required = False,
[7014]394        readonly = False,
[6996]395        )
396
[6992]397    booking_session = schema.Choice(
398        title = u'Session',
399        source = academic_sessions_vocab,
400        default = None,
401        required = True,
[7014]402        readonly = True,
[6992]403        )
404
405    booking_date = schema.Datetime(
406        title = u'Booking Date',
407        required = False,
[7014]408        readonly = True,
[6992]409        )
410
411    booking_code = schema.TextLine(
412        title = u'Booking Activation Code',
413        default = u'',
414        required = False,
[7014]415        readonly = True,
[6992]416        )
417
[6994]418    def getSessionString():
[7150]419        """Returns the the title of academic_sessions_vocab term.
420
[6994]421        """
[6992]422
[6860]423class IStudentPaymentsContainer(IPaymentsContainer):
[6635]424    """A container for student payment objects.
425
426    """
427
[6877]428class IStudentOnlinePayment(IOnlinePayment):
429    """A student payment via payment gateways.
430
431    """
432    p_session = schema.Choice(
433        title = u'Payment Session',
434        source = academic_sessions_vocab,
435        required = False,
436        )
437
438IStudentOnlinePayment['p_session'].order = IStudentOnlinePayment[
439    'p_item'].order
440
[6694]441# Interfaces for students only
442
443class IStudentClearanceEdit(IStudentClearance):
444    """Interface needed for restricted editing of student clearance data.
[7150]445
[6694]446    """
447
448class IStudentPersonalEdit(IStudentPersonal):
449    """Interface needed for restricted editing of student personal data.
[7150]450
[6694]451    """
Note: See TracBrowser for help on using the repository browser.