source: main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py @ 8099

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

Remove Nigerian lgas from base package. LGAs are not core data.

Use the COUNTRIES instead of NATS.

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