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
Line 
1## $Id: interfaces.py 7191 2011-11-25 07:13:22Z henrik $
2##
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##
18import re
19from datetime import datetime
20from zope.interface import Attribute, invariant, Interface
21from zope.interface.exceptions import Invalid
22from zope import schema
23from waeup.sirp.interfaces import IWAeUPObject, academic_sessions_vocab
24from waeup.sirp.schema import TextLineChoice
25from waeup.sirp.university.vocabularies import CourseSource, study_modes
26from waeup.sirp.students.vocabularies import (
27  CertificateSource, academic_sessions_vocab, verdicts, StudyLevelSource,
28  contextual_reg_num_source, contextual_mat_num_source, GenderSource,
29  )
30from waeup.sirp.payments.interfaces import IPaymentsContainer, IOnlinePayment
31
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
43class IStudentsUtils(Interface):
44    """A collection of methods which are subject to customization.
45
46    """
47    def getPaymentDetails(category, student):
48        """Get the payment dates of a student for the payment category
49        specified.
50
51        """
52
53    def getAccommodation_details(student):
54        """Determine the accommodation dates of a student.
55
56        """
57
58    def selectBed(available_beds):
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
65    def renderPDF(view, subject='', filename='slip.pdf',):
66        """Render pdf slips for various pages.
67
68        """
69
70class IStudentsContainer(IWAeUPObject):
71    """A students container contains university students.
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
109class IStudentNavigation(IWAeUPObject):
110    """Interface needed for student navigation.
111
112    """
113    def getStudent():
114        """Return student object.
115
116        """
117
118class IStudentBase(IWAeUPObject):
119    """Representation of student base data.
120
121    """
122    history = Attribute('Object history, a list of messages')
123    state = Attribute('Returns the registration state of a student')
124    password = Attribute('Encrypted password of a student')
125    certificate = Attribute('The certificate of any chosen study course')
126    current_session = Attribute('The current session of the student')
127
128    def loggerInfo(ob_class, comment):
129        """Adds an INFO message to the log file.
130
131        """
132
133    student_id = schema.TextLine(
134        title = u'Student ID',
135        required = False,
136        )
137
138    fullname = schema.TextLine(
139        title = u'Full Name',
140        default = None,
141        required = True,
142        )
143
144    sex = schema.Choice(
145        title = u'Sex',
146        source = GenderSource(),
147        default = u'm',
148        required = True,
149        )
150
151    reg_number = TextLineChoice(
152        title = u'Registration Number',
153        default = None,
154        required = True,
155        readonly = False,
156        source = contextual_reg_num_source,
157        )
158
159    matric_number = TextLineChoice(
160        title = u'Matriculation Number',
161        #default = u'',
162        required = False,
163        readonly = False,
164        source = contextual_mat_num_source,
165        )
166
167    adm_code = schema.TextLine(
168        title = u'PWD Activation Code',
169        default = u'',
170        required = False,
171        readonly = True,
172        )
173
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
185class IStudentClearance(IWAeUPObject):
186    """Representation of student clearance data.
187
188    """
189    date_of_birth = schema.Date(
190        title = u'Date of Birth',
191        required = True,
192        )
193
194    clearance_locked = schema.Bool(
195        title = u'Clearance form locked',
196        default = False,
197        )
198
199    clr_code = schema.TextLine(
200        title = u'CLR Activation Code',
201        default = u'',
202        required = False,
203        readonly = True,
204        )
205
206class IStudentPersonal(IWAeUPObject):
207    """Representation of student personal data.
208
209    """
210    perm_address = schema.Text(
211        title = u'Permanent Address',
212        required = False,
213        )
214
215class IStudent(IStudentBase,IStudentClearance,IStudentPersonal):
216    """Representation of a student.
217
218    """
219
220class IStudentUpdateByRegNo(IStudent):
221    """Representation of a student. Skip regular reg_number validation.
222
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.
232
233    """
234    matric_number = schema.TextLine(
235        title = u'Matriculation Number',
236        default = None,
237        required = False,
238        )
239
240class IStudentStudyCourse(IWAeUPObject):
241    """A container for student study levels.
242
243    """
244    certificate = schema.Choice(
245        title = u'Certificate',
246        source = CertificateSource(),
247        default = None,
248        required = True,
249        )
250
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
268    current_session = schema.Choice(
269        title = u'Current Session',
270        source = academic_sessions_vocab,
271        default = None,
272        required = True,
273        readonly = False,
274        )
275
276    current_level = schema.Choice(
277        title = u'Current Level',
278        source = StudyLevelSource(),
279        default = None,
280        required = False,
281        readonly = False,
282        )
283
284    current_verdict = schema.Choice(
285        title = u'Current Verdict',
286        source = verdicts,
287        default = '0',
288        required = False,
289        )
290
291    previous_verdict = schema.Choice(
292        title = u'Previous Verdict',
293        source = verdicts,
294        default = '0',
295        required = False,
296        )
297
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
307class IStudentStudyLevel(IWAeUPObject):
308    """A container for course tickets.
309
310    """
311    level = Attribute('The level code')
312    validation_date = Attribute('The date of validation')
313    validated_by = Attribute('User Id of course adviser')
314
315    level_session = schema.Choice(
316        title = u'Session',
317        source = academic_sessions_vocab,
318        default = None,
319        required = True,
320        )
321
322    level_verdict = schema.Choice(
323        title = u'Verdict',
324        source = verdicts,
325        default = '0',
326        required = False,
327        )
328
329class ICourseTicket(IWAeUPObject):
330    """A course ticket.
331
332    """
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')
340
341    core_or_elective = schema.Bool(
342        title = u'Mandatory',
343        default = False,
344        required = False,
345        readonly = False,
346        )
347
348    score = schema.Int(
349        title = u'Score',
350        default = 0,
351        required = False,
352        readonly = False,
353        )
354
355    automatic = schema.Bool(
356        title = u'Automatical Creation',
357        default = False,
358        required = False,
359        readonly = True,
360        )
361
362class ICourseTicketAdd(ICourseTicket):
363    """An interface for adding course tickets.
364
365    """
366    course = schema.Choice(
367        title = u'Course',
368        source = CourseSource(),
369        readonly = False,
370        )
371
372class IStudentAccommodation(IWAeUPObject):
373    """A container for student accommodation objects.
374
375    """
376
377class IBedTicket(IWAeUPObject):
378    """A ticket for accommodation booking.
379
380    """
381    bed = Attribute('The bed object.')
382
383    bed_coordinates = schema.TextLine(
384        title = u'Bed Coordinates',
385        default = None,
386        required = False,
387        readonly = False,
388        )
389
390    bed_type = schema.TextLine(
391        title = u'Bed Type',
392        default = None,
393        required = False,
394        readonly = False,
395        )
396
397    booking_session = schema.Choice(
398        title = u'Session',
399        source = academic_sessions_vocab,
400        default = None,
401        required = True,
402        readonly = True,
403        )
404
405    booking_date = schema.Datetime(
406        title = u'Booking Date',
407        required = False,
408        readonly = True,
409        )
410
411    booking_code = schema.TextLine(
412        title = u'Booking Activation Code',
413        default = u'',
414        required = False,
415        readonly = True,
416        )
417
418    def getSessionString():
419        """Returns the the title of academic_sessions_vocab term.
420
421        """
422
423class IStudentPaymentsContainer(IPaymentsContainer):
424    """A container for student payment objects.
425
426    """
427
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
441# Interfaces for students only
442
443class IStudentClearanceEdit(IStudentClearance):
444    """Interface needed for restricted editing of student clearance data.
445
446    """
447
448class IStudentPersonalEdit(IStudentPersonal):
449    """Interface needed for restricted editing of student personal data.
450
451    """
Note: See TracBrowser for help on using the repository browser.