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

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

Add fields email and phone which can be edited via the StudentBaseEditFormPage?. email, phone and passport picture are required for starting clearance.

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