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

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

Use same technique for approval of payments in students and in applicants.

  • Property svn:keywords set to Id
File size: 14.1 KB
Line 
1## $Id: interfaces.py 8422 2012-05-11 16:32:07Z 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 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
128    unique_student_id = Attribute("""A unique student id.""")
129
130class IStudentNavigation(IKofaObject):
131    """Interface needed for student navigation.
132
133    """
134    def getStudent():
135        """Return student object.
136
137        """
138
139class IStudentBase(IKofaObject):
140    """Representation of student base data.
141
142    """
143    history = Attribute('Object history, a list of messages')
144    state = Attribute('Returns the registration state of a student')
145    password = Attribute('Encrypted password of a student')
146    certcode = Attribute('The certificate code of any chosen study course')
147    depcode = Attribute('The department code of any chosen study course')
148    faccode = Attribute('The faculty code of any chosen study course')
149    current_session = Attribute('The current session of the student')
150    current_mode = Attribute('The current mode of the student')
151    fullname = Attribute('All name parts separated by hyphens')
152    display_fullname = Attribute('The fullname of an applicant')
153
154    def loggerInfo(ob_class, comment):
155        """Adds an INFO message to the log file.
156
157        """
158
159    student_id = schema.TextLine(
160        title = _(u'Student Id'),
161        required = False,
162        )
163
164    firstname = schema.TextLine(
165        title = _(u'First Name'),
166        required = True,
167        )
168
169    middlename = schema.TextLine(
170        title = _(u'Middle Name'),
171        required = False,
172        )
173
174    lastname = schema.TextLine(
175        title = _(u'Last Name (Surname)'),
176        required = True,
177        )
178
179    sex = schema.Choice(
180        title = _(u'Sex'),
181        source = GenderSource(),
182        required = True,
183        )
184
185    reg_number = TextLineChoice(
186        title = _(u'Registration Number'),
187        required = True,
188        readonly = False,
189        source = contextual_reg_num_source,
190        )
191
192    matric_number = TextLineChoice(
193        title = _(u'Matriculation Number'),
194        required = False,
195        readonly = False,
196        source = contextual_mat_num_source,
197        )
198
199    adm_code = schema.TextLine(
200        title = _(u'PWD Activation Code'),
201        required = False,
202        readonly = True,
203        )
204
205    email = schema.ASCIILine(
206        title = _(u'Email'),
207        required = False,
208        constraint=validate_email,
209        )
210    phone = PhoneNumber(
211        title = _(u'Phone'),
212        description = u'',
213        required = False,
214        )
215
216class IUGStudentClearance(IKofaObject):
217    """Representation of undergraduate student clearance data.
218
219    """
220    date_of_birth = FormattedDate(
221        title = _(u'Date of Birth'),
222        required = True,
223        show_year = True,
224        )
225
226    clearance_locked = schema.Bool(
227        title = _(u'Clearance form locked'),
228        default = False,
229        )
230
231    clr_code = schema.TextLine(
232        title = _(u'CLR Activation Code'),
233        required = False,
234        readonly = True,
235        )
236
237    nationality = schema.Choice(
238        vocabulary = nats_vocab,
239        title = _(u'Nationality'),
240        required = False,
241        )
242
243class IPGStudentClearance(IUGStudentClearance):
244    """Representation of postgraduate student clearance data.
245
246    """
247    employer = schema.TextLine(
248        title = _(u'Employer'),
249        required = False,
250        readonly = False,
251        )
252
253class IStudentPersonal(IKofaObject):
254    """Representation of student personal data.
255
256    """
257    perm_address = schema.Text(
258        title = _(u'Permanent Address'),
259        required = False,
260        )
261
262class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance,
263    IStudentPersonal):
264    """Representation of a student.
265
266    """
267
268class IStudentUpdateByRegNo(IStudent):
269    """Representation of a student. Skip regular reg_number validation.
270
271    """
272    reg_number = schema.TextLine(
273        title = _(u'Registration Number'),
274        required = False,
275        )
276
277class IStudentUpdateByMatricNo(IStudent):
278    """Representation of a student. Skip regular matric_number validation.
279
280    """
281    matric_number = schema.TextLine(
282        title = _(u'Matriculation Number'),
283        required = False,
284        )
285
286class IStudentStudyCourse(IKofaObject):
287    """A container for student study levels.
288
289    """
290    certificate = schema.Choice(
291        title = _(u'Certificate'),
292        source = CertificateSource(),
293        required = False,
294        )
295
296    entry_mode = schema.Choice(
297        title = _(u'Entry Mode'),
298        source = StudyModeSource(),
299        required = True,
300        readonly = False,
301        )
302
303    entry_session = schema.Choice(
304        title = _(u'Entry Session'),
305        source = academic_sessions_vocab,
306        #default = datetime.now().year,
307        required = True,
308        readonly = False,
309        )
310
311    current_session = schema.Choice(
312        title = _(u'Current Session'),
313        source = academic_sessions_vocab,
314        required = True,
315        readonly = False,
316        )
317
318    current_level = schema.Choice(
319        title = _(u'Current Level'),
320        source = StudyLevelSource(),
321        required = False,
322        readonly = False,
323        )
324
325    current_verdict = schema.Choice(
326        title = _(u'Current Verdict'),
327        source = VerdictSource(),
328        default = '0',
329        required = False,
330        )
331
332    previous_verdict = schema.Choice(
333        title = _(u'Previous Verdict'),
334        source = VerdictSource(),
335        default = '0',
336        required = False,
337        )
338
339class IStudentVerdictUpdate(IKofaObject):
340    """A interface for verdict imports.
341
342    """
343
344    current_verdict = schema.Choice(
345        title = _(u'Current Verdict'),
346        source = VerdictSource(),
347        required = True,
348        )
349
350    current_session = schema.Choice(
351        title = _(u'Current Session'),
352        source = academic_sessions_vocab,
353        required = True,
354        )
355
356    current_level = schema.Choice(
357        title = _(u'Current Level'),
358        source = StudyLevelSource(),
359        required = True,
360        )
361
362class IStudentStudyLevel(IKofaObject):
363    """A container for course tickets.
364
365    """
366    level = Attribute('The level code')
367    validation_date = Attribute('The date of validation')
368    validated_by = Attribute('User Id of course adviser')
369
370    level_session = schema.Choice(
371        title = _(u'Session'),
372        source = academic_sessions_vocab,
373        required = True,
374        )
375
376    level_verdict = schema.Choice(
377        title = _(u'Verdict'),
378        source = VerdictSource(),
379        default = '0',
380        required = False,
381        )
382
383    def addCourseTicket(courseticket):
384        """Add a course ticket object.
385        """
386
387    def getStudent():
388        """Return student
389        """
390
391class ICourseTicket(IKofaObject):
392    """A course ticket.
393
394    """
395    code = Attribute('code of the original course')
396    title = Attribute('title of the original course')
397    credits = Attribute('credits of the original course')
398    passmark = Attribute('passmark of the original course')
399    semester = Attribute('semester of the original course')
400    fcode = Attribute('faculty code of the original course')
401    dcode = Attribute('department code of the original course')
402
403    mandatory = schema.Bool(
404        title = _(u'Mandatory'),
405        default = False,
406        required = False,
407        readonly = False,
408        )
409
410    score = schema.Int(
411        title = _(u'Score'),
412        default = 0,
413        required = False,
414        readonly = False,
415        )
416
417    automatic = schema.Bool(
418        title = _(u'Automatical Creation'),
419        default = False,
420        required = False,
421        readonly = True,
422        )
423
424    carry_over = schema.Bool(
425        title = _(u'Carry-over Course'),
426        default = False,
427        required = False,
428        readonly = False,
429        )
430
431    def getLevel():
432        """Returns the id of the level the ticket has been added to.
433        """
434
435    def getLevelSession():
436        """Returns the session of the level the ticket has been added to.
437        """
438
439class ICourseTicketAdd(ICourseTicket):
440    """An interface for adding course tickets.
441
442    """
443    course = schema.Choice(
444        title = _(u'Course'),
445        source = CourseSource(),
446        readonly = False,
447        )
448
449class IStudentAccommodation(IKofaObject):
450    """A container for student accommodation objects.
451
452    """
453
454class IBedTicket(IKofaObject):
455    """A ticket for accommodation booking.
456
457    """
458    bed = Attribute('The bed object.')
459
460    bed_coordinates = schema.TextLine(
461        title = _(u'Bed Coordinates'),
462        required = False,
463        readonly = False,
464        )
465
466    bed_type = schema.TextLine(
467        title = _(u'Bed Type'),
468        required = False,
469        readonly = False,
470        )
471
472    booking_session = schema.Choice(
473        title = _(u'Session'),
474        source = academic_sessions_vocab,
475        required = True,
476        readonly = True,
477        )
478
479    booking_date = schema.Datetime(
480        title = _(u'Booking Date'),
481        required = False,
482        readonly = True,
483        )
484
485    booking_code = schema.TextLine(
486        title = _(u'Booking Activation Code'),
487        required = False,
488        readonly = True,
489        )
490
491    def getSessionString():
492        """Returns the title of academic_sessions_vocab term.
493
494        """
495
496class IStudentPaymentsContainer(IPaymentsContainer):
497    """A container for student payment objects.
498
499    """
500
501class IStudentOnlinePayment(IOnlinePayment):
502    """A student payment via payment gateways.
503
504    """
505
506    p_level = schema.Int(
507        title = _(u'Payment Level'),
508        required = False,
509        readonly = True,
510        )
511
512    def doAfterStudentPayment():
513        """Process student after payment was made.
514
515        """
516
517    def approveStudentPayment():
518        """Approve payment and process student.
519
520        """
521
522IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[
523    'p_session'].order
524
525class ICSVStudentExporter(ICSVExporter):
526    """A regular ICSVExporter that additionally supports exporting
527      data from a given student object.
528    """
529
530    def export_student(student, filepath=None):
531        """Export data for a given student.
532        """
Note: See TracBrowser for help on using the repository browser.