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

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

Remove unneeded default values in interfaces. Adjust tests.

  • Property svn:keywords set to Id
File size: 13.5 KB
Line 
1## $Id: interfaces.py 7983 2012-03-26 09:31:08Z 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 IStudentClearance(IKofaObject):
214    """Representation of 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        source = nats_vocab,
235        title = _(u'Nationality'),
236        default = 'nigeria',
237        required = False,
238        )
239
240class IStudentPersonal(IKofaObject):
241    """Representation of student personal data.
242
243    """
244    perm_address = schema.Text(
245        title = _(u'Permanent Address'),
246        required = False,
247        )
248
249class IStudent(IStudentBase,IStudentClearance,IStudentPersonal):
250    """Representation of a student.
251
252    """
253
254class IStudentUpdateByRegNo(IStudent):
255    """Representation of a student. Skip regular reg_number validation.
256
257    """
258    reg_number = schema.TextLine(
259        title = _(u'Registration Number'),
260        required = False,
261        )
262
263class IStudentUpdateByMatricNo(IStudent):
264    """Representation of a student. Skip regular matric_number validation.
265
266    """
267    matric_number = schema.TextLine(
268        title = _(u'Matriculation Number'),
269        required = False,
270        )
271
272class IStudentStudyCourse(IKofaObject):
273    """A container for student study levels.
274
275    """
276    certificate = schema.Choice(
277        title = _(u'Certificate'),
278        source = CertificateSource(),
279        required = False,
280        )
281
282    entry_mode = schema.Choice(
283        title = _(u'Entry Mode'),
284        source = StudyModeSource(),
285        required = True,
286        readonly = False,
287        )
288
289    entry_session = schema.Choice(
290        title = _(u'Entry Session'),
291        source = academic_sessions_vocab,
292        #default = datetime.now().year,
293        required = True,
294        readonly = False,
295        )
296
297    current_session = schema.Choice(
298        title = _(u'Current Session'),
299        source = academic_sessions_vocab,
300        required = True,
301        readonly = False,
302        )
303
304    current_level = schema.Choice(
305        title = _(u'Current Level'),
306        source = StudyLevelSource(),
307        required = False,
308        readonly = False,
309        )
310
311    current_verdict = schema.Choice(
312        title = _(u'Current Verdict'),
313        source = VerdictSource(),
314        default = '0',
315        required = False,
316        )
317
318    previous_verdict = schema.Choice(
319        title = _(u'Previous Verdict'),
320        source = VerdictSource(),
321        default = '0',
322        required = False,
323        )
324
325class IStudentVerdictUpdate(IKofaObject):
326    """A interface for verdict imports.
327
328    """
329
330    current_verdict = schema.Choice(
331        title = _(u'Current Verdict'),
332        source = VerdictSource(),
333        required = True,
334        )
335
336    current_session = schema.Choice(
337        title = _(u'Current Session'),
338        source = academic_sessions_vocab,
339        required = True,
340        )
341
342    current_level = schema.Choice(
343        title = _(u'Current Level'),
344        source = StudyLevelSource(),
345        required = True,
346        )
347
348class IStudentStudyLevel(IKofaObject):
349    """A container for course tickets.
350
351    """
352    level = Attribute('The level code')
353    validation_date = Attribute('The date of validation')
354    validated_by = Attribute('User Id of course adviser')
355
356    level_session = schema.Choice(
357        title = _(u'Session'),
358        source = academic_sessions_vocab,
359        required = True,
360        )
361
362    level_verdict = schema.Choice(
363        title = _(u'Verdict'),
364        source = VerdictSource(),
365        default = '0',
366        required = False,
367        )
368
369class ICourseTicket(IKofaObject):
370    """A course ticket.
371
372    """
373    code = Attribute('code of the original course')
374    title = Attribute('title of the original course')
375    credits = Attribute('credits of the original course')
376    passmark = Attribute('passmark of the original course')
377    semester = Attribute('semester of the original course')
378    fcode = Attribute('faculty code of the original course')
379    dcode = Attribute('department code of the original course')
380
381    mandatory = schema.Bool(
382        title = _(u'Mandatory'),
383        default = False,
384        required = False,
385        readonly = False,
386        )
387
388    score = schema.Int(
389        title = _(u'Score'),
390        default = 0,
391        required = False,
392        readonly = False,
393        )
394
395    automatic = schema.Bool(
396        title = _(u'Automatical Creation'),
397        default = False,
398        required = False,
399        readonly = True,
400        )
401
402    carry_over = schema.Bool(
403        title = _(u'Carry-over Course'),
404        default = False,
405        required = False,
406        readonly = False,
407        )
408
409    def getLevel():
410        """Returns the id of the level the ticket has been added to.
411        """
412
413    def getLevelSession():
414        """Returns the session of the level the ticket has been added to.
415        """
416
417class ICourseTicketAdd(ICourseTicket):
418    """An interface for adding course tickets.
419
420    """
421    course = schema.Choice(
422        title = _(u'Course'),
423        source = CourseSource(),
424        readonly = False,
425        )
426
427class IStudentAccommodation(IKofaObject):
428    """A container for student accommodation objects.
429
430    """
431
432class IBedTicket(IKofaObject):
433    """A ticket for accommodation booking.
434
435    """
436    bed = Attribute('The bed object.')
437
438    bed_coordinates = schema.TextLine(
439        title = _(u'Bed Coordinates'),
440        required = False,
441        readonly = False,
442        )
443
444    bed_type = schema.TextLine(
445        title = _(u'Bed Type'),
446        required = False,
447        readonly = False,
448        )
449
450    booking_session = schema.Choice(
451        title = _(u'Session'),
452        source = academic_sessions_vocab,
453        required = True,
454        readonly = True,
455        )
456
457    booking_date = schema.Datetime(
458        title = _(u'Booking Date'),
459        required = False,
460        readonly = True,
461        )
462
463    booking_code = schema.TextLine(
464        title = _(u'Booking Activation Code'),
465        required = False,
466        readonly = True,
467        )
468
469    def getSessionString():
470        """Returns the title of academic_sessions_vocab term.
471
472        """
473
474class IStudentPaymentsContainer(IPaymentsContainer):
475    """A container for student payment objects.
476
477    """
478
479class IStudentOnlinePayment(IOnlinePayment):
480    """A student payment via payment gateways.
481
482    """
483    p_session = schema.Choice(
484        title = _(u'Payment Session'),
485        source = academic_sessions_vocab,
486        required = False,
487        )
488
489IStudentOnlinePayment['p_session'].order = IStudentOnlinePayment[
490    'p_item'].order
491
492class IStudentChangePassword(IKofaObject):
493    """Interface needed for change pasword page.
494
495    """
496
497    reg_number = schema.TextLine(
498        title = _(u'Registration Number'),
499        required = True,
500        readonly = False,
501        )
502
503    email = schema.ASCIILine(
504        title = _(u'Email Address'),
505        required = True,
506        constraint=validate_email,
507        )
Note: See TracBrowser for help on using the repository browser.