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

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

Replace getStudent method by a 'student' attribute.

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