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

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

Fix sources.

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