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

Last change on this file since 8855 was 8854, checked in by Henrik Bettermann, 12 years ago

Returning students do not necessarily have a registration number and can use their matric. number instead.

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