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

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

Use new date and datetime widgets everywhere in base package.

Use standard datetime widgets for imports. I don't know if this is really necessary.

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