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

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

Add nationality vocab.

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