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

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

Uses sources instead of vocabularies and feed sources with dictionaries defined in SIRPUtils. This way we can easily customize the sources.

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