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

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

Add indexes faccode, depcode and certcode to students_catalog.

  • Property svn:keywords set to Id
File size: 11.8 KB
Line 
1## $Id: interfaces.py 7203 2011-11-25 20:54:14Z 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    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')
128    current_session = Attribute('The current session of the student')
129
130    def loggerInfo(ob_class, comment):
131        """Adds an INFO message to the log file.
132
133        """
134
135    student_id = schema.TextLine(
136        title = u'Student ID',
137        required = False,
138        )
139
140    fullname = schema.TextLine(
141        title = u'Full Name',
142        default = None,
143        required = True,
144        )
145
146    sex = schema.Choice(
147        title = u'Sex',
148        source = GenderSource(),
149        default = u'm',
150        required = True,
151        )
152
153    reg_number = TextLineChoice(
154        title = u'Registration Number',
155        default = None,
156        required = True,
157        readonly = False,
158        source = contextual_reg_num_source,
159        )
160
161    matric_number = TextLineChoice(
162        title = u'Matriculation Number',
163        #default = u'',
164        required = False,
165        readonly = False,
166        source = contextual_mat_num_source,
167        )
168
169    adm_code = schema.TextLine(
170        title = u'PWD Activation Code',
171        default = u'',
172        required = False,
173        readonly = True,
174        )
175
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
187class IStudentClearance(IWAeUPObject):
188    """Representation of student clearance data.
189
190    """
191    date_of_birth = schema.Date(
192        title = u'Date of Birth',
193        required = True,
194        )
195
196    clearance_locked = schema.Bool(
197        title = u'Clearance form locked',
198        default = False,
199        )
200
201    clr_code = schema.TextLine(
202        title = u'CLR Activation Code',
203        default = u'',
204        required = False,
205        readonly = True,
206        )
207
208class IStudentPersonal(IWAeUPObject):
209    """Representation of student personal data.
210
211    """
212    perm_address = schema.Text(
213        title = u'Permanent Address',
214        required = False,
215        )
216
217class IStudent(IStudentBase,IStudentClearance,IStudentPersonal):
218    """Representation of a student.
219
220    """
221
222class IStudentUpdateByRegNo(IStudent):
223    """Representation of a student. Skip regular reg_number validation.
224
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.
234
235    """
236    matric_number = schema.TextLine(
237        title = u'Matriculation Number',
238        default = None,
239        required = False,
240        )
241
242class IStudentStudyCourse(IWAeUPObject):
243    """A container for student study levels.
244
245    """
246    certificate = schema.Choice(
247        title = u'Certificate',
248        source = CertificateSource(),
249        default = None,
250        required = True,
251        )
252
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
270    current_session = schema.Choice(
271        title = u'Current Session',
272        source = academic_sessions_vocab,
273        default = None,
274        required = True,
275        readonly = False,
276        )
277
278    current_level = schema.Choice(
279        title = u'Current Level',
280        source = StudyLevelSource(),
281        default = None,
282        required = False,
283        readonly = False,
284        )
285
286    current_verdict = schema.Choice(
287        title = u'Current Verdict',
288        source = verdicts,
289        default = '0',
290        required = False,
291        )
292
293    previous_verdict = schema.Choice(
294        title = u'Previous Verdict',
295        source = verdicts,
296        default = '0',
297        required = False,
298        )
299
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
309class IStudentStudyLevel(IWAeUPObject):
310    """A container for course tickets.
311
312    """
313    level = Attribute('The level code')
314    validation_date = Attribute('The date of validation')
315    validated_by = Attribute('User Id of course adviser')
316
317    level_session = schema.Choice(
318        title = u'Session',
319        source = academic_sessions_vocab,
320        default = None,
321        required = True,
322        )
323
324    level_verdict = schema.Choice(
325        title = u'Verdict',
326        source = verdicts,
327        default = '0',
328        required = False,
329        )
330
331class ICourseTicket(IWAeUPObject):
332    """A course ticket.
333
334    """
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')
342
343    core_or_elective = schema.Bool(
344        title = u'Mandatory',
345        default = False,
346        required = False,
347        readonly = False,
348        )
349
350    score = schema.Int(
351        title = u'Score',
352        default = 0,
353        required = False,
354        readonly = False,
355        )
356
357    automatic = schema.Bool(
358        title = u'Automatical Creation',
359        default = False,
360        required = False,
361        readonly = True,
362        )
363
364class ICourseTicketAdd(ICourseTicket):
365    """An interface for adding course tickets.
366
367    """
368    course = schema.Choice(
369        title = u'Course',
370        source = CourseSource(),
371        readonly = False,
372        )
373
374class IStudentAccommodation(IWAeUPObject):
375    """A container for student accommodation objects.
376
377    """
378
379class IBedTicket(IWAeUPObject):
380    """A ticket for accommodation booking.
381
382    """
383    bed = Attribute('The bed object.')
384
385    bed_coordinates = schema.TextLine(
386        title = u'Bed Coordinates',
387        default = None,
388        required = False,
389        readonly = False,
390        )
391
392    bed_type = schema.TextLine(
393        title = u'Bed Type',
394        default = None,
395        required = False,
396        readonly = False,
397        )
398
399    booking_session = schema.Choice(
400        title = u'Session',
401        source = academic_sessions_vocab,
402        default = None,
403        required = True,
404        readonly = True,
405        )
406
407    booking_date = schema.Datetime(
408        title = u'Booking Date',
409        required = False,
410        readonly = True,
411        )
412
413    booking_code = schema.TextLine(
414        title = u'Booking Activation Code',
415        default = u'',
416        required = False,
417        readonly = True,
418        )
419
420    def getSessionString():
421        """Returns the the title of academic_sessions_vocab term.
422
423        """
424
425class IStudentPaymentsContainer(IPaymentsContainer):
426    """A container for student payment objects.
427
428    """
429
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
443# Interfaces for students only
444
445class IStudentClearanceEdit(IStudentClearance):
446    """Interface needed for restricted editing of student clearance data.
447
448    """
449
450class IStudentPersonalEdit(IStudentPersonal):
451    """Interface needed for restricted editing of student personal data.
452
453    """
Note: See TracBrowser for help on using the repository browser.