source: main/waeup.kofa/branches/uli-zc-async/src/waeup/kofa/students/interfaces.py @ 10021

Last change on this file since 10021 was 9211, checked in by uli, 12 years ago

Rollback r9209. Looks like multiple merges from trunk confuse svn when merging back into trunk.

  • Property svn:keywords set to Id
File size: 14.8 KB
Line 
1## $Id: interfaces.py 9211 2012-09-21 08:19:35Z uli $
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.browser.interfaces import IStudentNavigationBase
24from waeup.kofa.interfaces import (
25    IKofaObject, academic_sessions_vocab, validate_email, ICSVExporter)
26from waeup.kofa.interfaces import MessageFactory as _
27from waeup.kofa.schema import TextLineChoice, FormattedDate, PhoneNumber
28from waeup.kofa.students.vocabularies import (
29    StudyLevelSource, contextual_reg_num_source, contextual_mat_num_source,
30    GenderSource, nats_vocab,
31    )
32from waeup.kofa.payments.interfaces import (
33    IPaymentsContainer, IOnlinePayment)
34from waeup.kofa.university.vocabularies import (
35    CourseSource, StudyModeSource, CertificateSource)
36
37# VerdictSource can't be placed into the vocabularies module because it
38# requires importing IStudentsUtils which then leads to circular imports.
39class VerdictSource(BasicContextualSourceFactory):
40    """A verdicts source delivers all verdicts provided
41    in the portal.
42    """
43    def getValues(self, context):
44        verdicts_dict = getUtility(IStudentsUtils).VERDICTS_DICT
45        return verdicts_dict.keys()
46
47    def getToken(self, context, value):
48        return value
49
50    def getTitle(self, context, value):
51        verdicts_dict = getUtility(IStudentsUtils).VERDICTS_DICT
52        return verdicts_dict[value]
53
54
55class IStudentsUtils(Interface):
56    """A collection of methods which are subject to customization.
57
58    """
59    def setReturningData(student):
60        """ This method defines what happens after school fee payment
61        depending on the student's senate verdict.
62
63        In the base configuration current level is always increased
64        by 100 no matter which verdict has been assigned.
65        """
66
67    def setPaymentDetails(category, student):
68        """Create Payment object and set the payment data of a student for
69        the payment category specified.
70
71        """
72
73    def getAccommodation_details(student):
74        """Determine the accommodation dates of a student.
75
76        """
77
78    def selectBed(available_beds):
79        """Select a bed from a list of available beds.
80
81        In the standard configuration we select the first bed found,
82        but can also randomize the selection if we like.
83        """
84
85    def renderPDF(view, subject='', filename='slip.pdf',):
86        """Render pdf slips for various pages.
87
88        """
89
90class IStudentsContainer(IKofaObject):
91    """A students container contains university students.
92
93    """
94    def addStudent(student):
95        """Add an IStudent object and subcontainers.
96
97        """
98
99    def archive(id=None):
100        """Create on-dist archive of students.
101
102        If id is `None`, all students are archived.
103
104        If id contains a single id string, only the respective
105        students are archived.
106
107        If id contains a list of id strings all of the respective
108        students types are saved to disk.
109        """
110
111    def clear(id=None, archive=True):
112        """Remove students of type given by 'id'.
113
114        Optionally archive the students.
115
116        If id is `None`, all students are archived.
117
118        If id contains a single id string, only the respective
119        students are archived.
120
121        If id contains a list of id strings all of the respective
122        student types are saved to disk.
123
124        If `archive` is ``False`` none of the archive-handling is done
125        and respective students are simply removed from the
126        database.
127        """
128
129    unique_student_id = Attribute("""A unique student id.""")
130
131class IStudentNavigation(IStudentNavigationBase):
132    """Interface needed for student navigation, logging, etc.
133
134    """
135    student = Attribute('Student object of context.')
136
137    def writeLogMessage(view, message):
138        """Write a view specific log message into students.log.
139
140        """
141
142class IStudentBase(IKofaObject):
143    """Representation of student base data.
144
145    """
146    history = Attribute('Object history, a list of messages')
147    state = Attribute('Returns the registration state of a student')
148    password = Attribute('Encrypted password of a student')
149    certcode = Attribute('The certificate code of any chosen study course')
150    depcode = Attribute('The department code of any chosen study course')
151    faccode = Attribute('The faculty code of any chosen study course')
152    current_session = Attribute('The current session of the student')
153    current_mode = Attribute('The current mode of the student')
154    fullname = Attribute('All name parts separated by hyphens')
155    display_fullname = Attribute('The fullname of an applicant')
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 = PhoneNumber(
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 IStudentRequestPW(IStudent):
285    """Representation of an student for first-time password request.
286
287    This interface is used when students use the requestpw page to
288    login for the the first time.
289    """
290    reg_number = schema.TextLine(
291        title = u'Registration Number',
292        required = True,
293        )
294
295    firstname = schema.TextLine(
296        title = _(u'First Name'),
297        required = True,
298        )
299
300    email = schema.ASCIILine(
301        title = _(u'Email Address'),
302        required = True,
303        constraint=validate_email,
304        )
305
306class IStudentStudyCourse(IKofaObject):
307    """A container for student study levels.
308
309    """
310    certificate = schema.Choice(
311        title = _(u'Certificate'),
312        source = CertificateSource(),
313        required = False,
314        )
315
316    entry_mode = schema.Choice(
317        title = _(u'Entry Mode'),
318        source = StudyModeSource(),
319        required = True,
320        readonly = False,
321        )
322
323    entry_session = schema.Choice(
324        title = _(u'Entry Session'),
325        source = academic_sessions_vocab,
326        #default = datetime.now().year,
327        required = True,
328        readonly = False,
329        )
330
331    current_session = schema.Choice(
332        title = _(u'Current Session'),
333        source = academic_sessions_vocab,
334        required = True,
335        readonly = False,
336        )
337
338    current_level = schema.Choice(
339        title = _(u'Current Level'),
340        source = StudyLevelSource(),
341        required = False,
342        readonly = False,
343        )
344
345    current_verdict = schema.Choice(
346        title = _(u'Current Verdict'),
347        source = VerdictSource(),
348        default = 'NY',
349        required = False,
350        )
351
352    previous_verdict = schema.Choice(
353        title = _(u'Previous Verdict'),
354        source = VerdictSource(),
355        default = 'NY',
356        required = False,
357        )
358
359class IStudentVerdictUpdate(IKofaObject):
360    """A interface for verdict imports.
361
362    """
363
364    current_verdict = schema.Choice(
365        title = _(u'Current Verdict'),
366        source = VerdictSource(),
367        required = True,
368        )
369
370    current_session = schema.Choice(
371        title = _(u'Current Session'),
372        source = academic_sessions_vocab,
373        required = True,
374        )
375
376    current_level = schema.Choice(
377        title = _(u'Current Level'),
378        source = StudyLevelSource(),
379        required = True,
380        )
381
382class IStudentStudyLevel(IKofaObject):
383    """A container for course tickets.
384
385    """
386    level = Attribute('The level code')
387    validation_date = Attribute('The date of validation')
388    validated_by = Attribute('User Id of course adviser')
389
390    level_session = schema.Choice(
391        title = _(u'Session'),
392        source = academic_sessions_vocab,
393        required = True,
394        )
395
396    level_verdict = schema.Choice(
397        title = _(u'Verdict'),
398        source = VerdictSource(),
399        default = 'NY',
400        required = False,
401        )
402
403    def addCourseTicket(courseticket):
404        """Add a course ticket object.
405        """
406
407class ICourseTicket(IKofaObject):
408    """A course ticket.
409
410    """
411    code = Attribute('code of the original course')
412    title = Attribute('title of the original course')
413    credits = Attribute('credits of the original course')
414    passmark = Attribute('passmark of the original course')
415    semester = Attribute('semester of the original course')
416    fcode = Attribute('faculty code of the original course')
417    dcode = Attribute('department code of the original course')
418
419    mandatory = schema.Bool(
420        title = _(u'Mandatory'),
421        default = False,
422        required = False,
423        readonly = False,
424        )
425
426    score = schema.Int(
427        title = _(u'Score'),
428        default = 0,
429        required = False,
430        readonly = False,
431        )
432
433    automatic = schema.Bool(
434        title = _(u'Automatical Creation'),
435        default = False,
436        required = False,
437        readonly = True,
438        )
439
440    carry_over = schema.Bool(
441        title = _(u'Carry-over Course'),
442        default = False,
443        required = False,
444        readonly = False,
445        )
446
447    def getLevel():
448        """Returns the id of the level the ticket has been added to.
449        """
450
451    def getLevelSession():
452        """Returns the session of the level the ticket has been added to.
453        """
454
455class ICourseTicketAdd(ICourseTicket):
456    """An interface for adding course tickets.
457
458    """
459    course = schema.Choice(
460        title = _(u'Course'),
461        source = CourseSource(),
462        readonly = False,
463        )
464
465class IStudentAccommodation(IKofaObject):
466    """A container for student accommodation objects.
467
468    """
469
470class IBedTicket(IKofaObject):
471    """A ticket for accommodation booking.
472
473    """
474    bed = Attribute('The bed object.')
475
476    bed_coordinates = schema.TextLine(
477        title = _(u'Bed Coordinates'),
478        required = False,
479        readonly = False,
480        )
481
482    bed_type = schema.TextLine(
483        title = _(u'Bed Type'),
484        required = False,
485        readonly = False,
486        )
487
488    booking_session = schema.Choice(
489        title = _(u'Session'),
490        source = academic_sessions_vocab,
491        required = True,
492        readonly = True,
493        )
494
495    booking_date = schema.Datetime(
496        title = _(u'Booking Date'),
497        required = False,
498        readonly = True,
499        )
500
501    booking_code = schema.TextLine(
502        title = _(u'Booking Activation Code'),
503        required = False,
504        readonly = True,
505        )
506
507    def getSessionString():
508        """Returns the title of academic_sessions_vocab term.
509
510        """
511
512class IStudentPaymentsContainer(IPaymentsContainer):
513    """A container for student payment objects.
514
515    """
516
517class IStudentOnlinePayment(IOnlinePayment):
518    """A student payment via payment gateways.
519
520    """
521
522    p_level = schema.Int(
523        title = _(u'Payment Level'),
524        required = False,
525        readonly = True,
526        )
527
528    def doAfterStudentPayment():
529        """Process student after payment was made.
530
531        """
532
533    def doAfterStudentPaymentApproval():
534        """Process student after payment was approved.
535
536        """
537
538    def approveStudentPayment():
539        """Approve payment and process student.
540
541        """
542
543IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[
544    'p_session'].order
545
546class ICSVStudentExporter(ICSVExporter):
547    """A regular ICSVExporter that additionally supports exporting
548      data from a given student object.
549    """
550
551    def export_student(student, filepath=None):
552        """Export data for a given student.
553        """
Note: See TracBrowser for help on using the repository browser.