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

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

We can't requite level_session since this value is missing in SRP.

  • Property svn:keywords set to Id
File size: 16.6 KB
RevLine 
[7191]1## $Id: interfaces.py 9167 2012-09-10 08:33:43Z henrik $
[6621]2##
[7191]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##
[8409]18#from datetime import datetime
[7620]19from zope.component import getUtility
[7256]20from zope.interface import Attribute, Interface
[6621]21from zope import schema
[7620]22from zc.sourcefactory.contextual import BasicContextualSourceFactory
[7811]23from waeup.kofa.interfaces import (
[8409]24    IKofaObject, academic_sessions_vocab, validate_email, ICSVExporter)
[7811]25from waeup.kofa.interfaces import MessageFactory as _
[8176]26from waeup.kofa.schema import TextLineChoice, FormattedDate, PhoneNumber
[7811]27from waeup.kofa.students.vocabularies import (
[7915]28    StudyLevelSource, contextual_reg_num_source, contextual_mat_num_source,
29    GenderSource, nats_vocab,
30    )
[8160]31from waeup.kofa.payments.interfaces import (
[8174]32    IPaymentsContainer, IOnlinePayment)
[7915]33from waeup.kofa.university.vocabularies import (
34    CourseSource, StudyModeSource, CertificateSource)
[6621]35
[7620]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):
[7841]43        verdicts_dict = getUtility(IStudentsUtils).VERDICTS_DICT
[8820]44        return sorted(verdicts_dict.keys())
[7620]45
46    def getToken(self, context, value):
47        return value
48
49    def getTitle(self, context, value):
[7841]50        verdicts_dict = getUtility(IStudentsUtils).VERDICTS_DICT
[8820]51        if value != '0':
52            return verdicts_dict[value] + ' (%s)' % value
[7688]53        return verdicts_dict[value]
[7620]54
[7681]55
[7150]56class IStudentsUtils(Interface):
57    """A collection of methods which are subject to customization.
58
59    """
[7841]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
[9148]68    def setPaymentDetails(category, student, previous_session=None,
69            previous_level=None,):
[8595]70        """Create Payment object and set the payment data of a student for
71        the payment category specified.
[7150]72
73        """
74
[7186]75    def getAccommodation_details(student):
[7150]76        """Determine the accommodation dates of a student.
77
78        """
79
[7186]80    def selectBed(available_beds):
[7150]81        """Select a bed from a list of available beds.
82
83        In the standard configuration we select the first bed found,
84        but can also randomize the selection if we like.
85        """
86
[7186]87    def renderPDF(view, subject='', filename='slip.pdf',):
[7150]88        """Render pdf slips for various pages.
89
90        """
91
[7819]92class IStudentsContainer(IKofaObject):
[7096]93    """A students container contains university students.
[6692]94
95    """
96    def addStudent(student):
97        """Add an IStudent object and subcontainers.
98
99        """
100
101    def archive(id=None):
102        """Create on-dist archive of students.
103
104        If id is `None`, all students are archived.
105
106        If id contains a single id string, only the respective
107        students are archived.
108
109        If id contains a list of id strings all of the respective
110        students types are saved to disk.
111        """
112
113    def clear(id=None, archive=True):
114        """Remove students of type given by 'id'.
115
116        Optionally archive the students.
117
118        If id is `None`, all students are archived.
119
120        If id contains a single id string, only the respective
121        students are archived.
122
123        If id contains a list of id strings all of the respective
124        student types are saved to disk.
125
126        If `archive` is ``False`` none of the archive-handling is done
127        and respective students are simply removed from the
128        database.
129        """
130
[8408]131    unique_student_id = Attribute("""A unique student id.""")
132
[7819]133class IStudentNavigation(IKofaObject):
[8735]134    """Interface needed for student navigation, logging, etc.
[7150]135
[6642]136    """
[8736]137    student = Attribute('Student object of context.')
[7150]138
[8735]139    def writeLogMessage(view, message):
140        """Write a view specific log message into students.log.
141
142        """
143
[7819]144class IStudentBase(IKofaObject):
[6631]145    """Representation of student base data.
[7150]146
[6621]147    """
[7062]148    history = Attribute('Object history, a list of messages')
[6637]149    state = Attribute('Returns the registration state of a student')
[6699]150    password = Attribute('Encrypted password of a student')
[7203]151    certcode = Attribute('The certificate code of any chosen study course')
152    depcode = Attribute('The department code of any chosen study course')
153    faccode = Attribute('The faculty code of any chosen study course')
[7062]154    current_session = Attribute('The current session of the student')
[9142]155    current_level = Attribute('The current level of the student')
[7641]156    current_mode = Attribute('The current mode of the student')
[7364]157    fullname = Attribute('All name parts separated by hyphens')
158    display_fullname = Attribute('The fullname of an applicant')
[8969]159    is_postgrad = Attribute('True if postgraduate student')
[6637]160
[8983]161    suspended = schema.Bool(
162        title = _(u'Account suspended'),
163        default = False,
[9035]164        required = False,
[8983]165        )
166
[6665]167    student_id = schema.TextLine(
[7723]168        title = _(u'Student Id'),
[6849]169        required = False,
[6665]170        )
171
[7357]172    firstname = schema.TextLine(
[7723]173        title = _(u'First Name'),
[6621]174        required = True,
175        )
176
[7357]177    middlename = schema.TextLine(
[7723]178        title = _(u'Middle Name'),
[7357]179        required = False,
180        )
181
182    lastname = schema.TextLine(
[7723]183        title = _(u'Last Name (Surname)'),
[7357]184        required = True,
185        )
186
[6996]187    sex = schema.Choice(
[7723]188        title = _(u'Sex'),
[6996]189        source = GenderSource(),
190        required = True,
191        )
192
[6788]193    reg_number = TextLineChoice(
[7723]194        title = _(u'Registration Number'),
[6696]195        required = True,
196        readonly = False,
[6788]197        source = contextual_reg_num_source,
[6696]198        )
199
[6788]200    matric_number = TextLineChoice(
[7723]201        title = _(u'Matriculation Number'),
[6750]202        required = False,
203        readonly = False,
[6788]204        source = contextual_mat_num_source,
[6750]205        )
206
[6769]207    adm_code = schema.TextLine(
[7723]208        title = _(u'PWD Activation Code'),
[6769]209        required = False,
[8977]210        readonly = False,
[6769]211        )
212
[7133]213    email = schema.ASCIILine(
[7723]214        title = _(u'Email'),
[7133]215        required = False,
216        constraint=validate_email,
217        )
[8176]218    phone = PhoneNumber(
[7723]219        title = _(u'Phone'),
[7331]220        description = u'',
[7133]221        required = False,
222        )
223
[9131]224    def transfer(certificate, current_session,
225        current_level, current_verdict):
226        """ Creates a new studycourse and backups the old one.
227
228        """
229
[7993]230class IUGStudentClearance(IKofaObject):
231    """Representation of undergraduate student clearance data.
[7150]232
[6631]233    """
[8160]234    date_of_birth = FormattedDate(
[7723]235        title = _(u'Date of Birth'),
[6631]236        required = True,
[8160]237        show_year = True,
[6631]238        )
239
[6695]240    clearance_locked = schema.Bool(
[7723]241        title = _(u'Clearance form locked'),
[6695]242        default = False,
[9035]243        required = False,
[6695]244        )
245
[6769]246    clr_code = schema.TextLine(
[7723]247        title = _(u'CLR Activation Code'),
[6769]248        required = False,
[8977]249        readonly = False,
[6769]250        )
251
[7523]252    nationality = schema.Choice(
[8069]253        vocabulary = nats_vocab,
[7723]254        title = _(u'Nationality'),
[7983]255        required = False,
[7523]256        )
257
[7993]258class IPGStudentClearance(IUGStudentClearance):
259    """Representation of postgraduate student clearance data.
260
261    """
262    employer = schema.TextLine(
263        title = _(u'Employer'),
264        required = False,
265        readonly = False,
266        )
267
[7819]268class IStudentPersonal(IKofaObject):
[6631]269    """Representation of student personal data.
[7150]270
[6631]271    """
[6651]272    perm_address = schema.Text(
[7723]273        title = _(u'Permanent Address'),
[6631]274        required = False,
275        )
276
[8008]277class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance,
278    IStudentPersonal):
[6631]279    """Representation of a student.
[7150]280
[6631]281    """
282
[6849]283class IStudentUpdateByRegNo(IStudent):
284    """Representation of a student. Skip regular reg_number validation.
[7150]285
[6849]286    """
287    reg_number = schema.TextLine(
[7723]288        title = _(u'Registration Number'),
[6849]289        required = False,
290        )
291
292class IStudentUpdateByMatricNo(IStudent):
293    """Representation of a student. Skip regular matric_number validation.
[7150]294
[6849]295    """
296    matric_number = schema.TextLine(
[7723]297        title = _(u'Matriculation Number'),
[6849]298        required = False,
299        )
300
[8779]301class IStudentRequestPW(IStudent):
302    """Representation of an student for first-time password request.
303
304    This interface is used when students use the requestpw page to
305    login for the the first time.
306    """
[8854]307    number = schema.TextLine(
308        title = _(u'Registr. or Matric. Number'),
[8779]309        required = True,
310        )
311
312    firstname = schema.TextLine(
313        title = _(u'First Name'),
314        required = True,
315        )
316
317    email = schema.ASCIILine(
318        title = _(u'Email Address'),
319        required = True,
320        constraint=validate_email,
321        )
322
[7819]323class IStudentStudyCourse(IKofaObject):
[6633]324    """A container for student study levels.
325
326    """
[6648]327    certificate = schema.Choice(
[7723]328        title = _(u'Certificate'),
[6648]329        source = CertificateSource(),
[7209]330        required = False,
[6633]331        )
[6635]332
[6996]333    entry_mode = schema.Choice(
[7723]334        title = _(u'Entry Mode'),
[7681]335        source = StudyModeSource(),
[6996]336        required = True,
337        readonly = False,
338        )
339
340    entry_session = schema.Choice(
[7723]341        title = _(u'Entry Session'),
[6996]342        source = academic_sessions_vocab,
[7425]343        #default = datetime.now().year,
[6996]344        required = True,
345        readonly = False,
346        )
347
[6724]348    current_session = schema.Choice(
[7723]349        title = _(u'Current Session'),
[6744]350        source = academic_sessions_vocab,
[6724]351        required = True,
[6996]352        readonly = False,
[6724]353        )
354
355    current_level = schema.Choice(
[7723]356        title = _(u'Current Level'),
[6725]357        source = StudyLevelSource(),
358        required = False,
[6996]359        readonly = False,
[6724]360        )
361
362    current_verdict = schema.Choice(
[7723]363        title = _(u'Current Verdict'),
[7619]364        source = VerdictSource(),
[8820]365        default = '0',
[6725]366        required = False,
[6724]367        )
368
369    previous_verdict = schema.Choice(
[7723]370        title = _(u'Previous Verdict'),
[7619]371        source = VerdictSource(),
[8820]372        default = '0',
[6725]373        required = False,
[6724]374        )
375
[9138]376class IStudentStudyCourseTransfer(IStudentStudyCourse):
377    """An student transfers.
378
379    """
380
381    certificate = schema.Choice(
382        title = _(u'Certificate'),
383        source = CertificateSource(),
384        required = True,
385        )
386
387    current_level = schema.Choice(
388        title = _(u'Current Level'),
389        source = StudyLevelSource(),
390        required = True,
391        readonly = False,
392        )
393
394
395IStudentStudyCourseTransfer['certificate'].order = IStudentStudyCourse[
396    'certificate'].order
397IStudentStudyCourseTransfer['current_level'].order = IStudentStudyCourse[
398    'current_level'].order
399
[7951]400class IStudentVerdictUpdate(IKofaObject):
401    """A interface for verdict imports.
402
403    """
404
405    current_verdict = schema.Choice(
406        title = _(u'Current Verdict'),
407        source = VerdictSource(),
408        required = True,
409        )
410
411    current_session = schema.Choice(
412        title = _(u'Current Session'),
413        source = academic_sessions_vocab,
414        required = True,
415        )
416
417    current_level = schema.Choice(
418        title = _(u'Current Level'),
419        source = StudyLevelSource(),
420        required = True,
421        )
422
[7819]423class IStudentStudyLevel(IKofaObject):
[6774]424    """A container for course tickets.
425
426    """
427    level = Attribute('The level code')
428
[6793]429    level_session = schema.Choice(
[7723]430        title = _(u'Session'),
[6793]431        source = academic_sessions_vocab,
[9167]432        required = False,
[6793]433        )
[6781]434
[6793]435    level_verdict = schema.Choice(
[7723]436        title = _(u'Verdict'),
[7619]437        source = VerdictSource(),
[8820]438        default = '0',
[6793]439        required = False,
440        )
441
[9161]442    validated_by = schema.TextLine(
443        title = _(u'Validated by'),
444        default = None,
445        required = False,
446        )
447
448    validation_date = schema.Datetime(
449        title = _(u'Validation Date'),
450        required = False,
451        readonly = False,
452        )
453
[8920]454    def addCourseTicket(ticket, course):
[8182]455        """Add a course ticket object.
456        """
457
[7819]458class ICourseTicket(IKofaObject):
[6781]459    """A course ticket.
460
461    """
[6783]462    code = Attribute('code of the original course')
463    title = Attribute('title of the original course')
464    credits = Attribute('credits of the original course')
465    passmark = Attribute('passmark of the original course')
466    semester = Attribute('semester of the original course')
[7304]467    fcode = Attribute('faculty code of the original course')
468    dcode = Attribute('department code of the original course')
[6781]469
[7665]470    mandatory = schema.Bool(
[7723]471        title = _(u'Mandatory'),
[6795]472        default = False,
473        required = False,
474        readonly = False,
475        )
476
[6781]477    score = schema.Int(
[7723]478        title = _(u'Score'),
[6781]479        default = 0,
480        required = False,
481        readonly = False,
482        )
483
[6806]484    automatic = schema.Bool(
[7723]485        title = _(u'Automatical Creation'),
[6806]486        default = False,
487        required = False,
488        readonly = True,
489        )
490
[7661]491    carry_over = schema.Bool(
[7723]492        title = _(u'Carry-over Course'),
[7661]493        default = False,
494        required = False,
495        readonly = False,
496        )
497
[7633]498    def getLevel():
499        """Returns the id of the level the ticket has been added to.
500        """
501
502    def getLevelSession():
503        """Returns the session of the level the ticket has been added to.
504        """
505
[6795]506class ICourseTicketAdd(ICourseTicket):
[7150]507    """An interface for adding course tickets.
[6795]508
509    """
510    course = schema.Choice(
[7723]511        title = _(u'Course'),
[6795]512        source = CourseSource(),
513        readonly = False,
514        )
515
[7819]516class IStudentAccommodation(IKofaObject):
[6635]517    """A container for student accommodation objects.
518
519    """
520
[7819]521class IBedTicket(IKofaObject):
[6989]522    """A ticket for accommodation booking.
523
524    """
[6996]525    bed = Attribute('The bed object.')
526
527    bed_coordinates = schema.TextLine(
[7723]528        title = _(u'Bed Coordinates'),
[6992]529        required = False,
[7014]530        readonly = False,
[6992]531        )
532
[6996]533    bed_type = schema.TextLine(
[7723]534        title = _(u'Bed Type'),
[6996]535        required = False,
[7014]536        readonly = False,
[6996]537        )
538
[6992]539    booking_session = schema.Choice(
[7723]540        title = _(u'Session'),
[6992]541        source = academic_sessions_vocab,
542        required = True,
[7014]543        readonly = True,
[6992]544        )
545
[8170]546    booking_date = schema.Datetime(
[7723]547        title = _(u'Booking Date'),
[6992]548        required = False,
[7014]549        readonly = True,
[6992]550        )
551
552    booking_code = schema.TextLine(
[7723]553        title = _(u'Booking Activation Code'),
[6992]554        required = False,
[7014]555        readonly = True,
[6992]556        )
557
[6994]558    def getSessionString():
[7633]559        """Returns the title of academic_sessions_vocab term.
[7150]560
[6994]561        """
[6992]562
[6860]563class IStudentPaymentsContainer(IPaymentsContainer):
[6635]564    """A container for student payment objects.
565
566    """
567
[6877]568class IStudentOnlinePayment(IOnlinePayment):
569    """A student payment via payment gateways.
570
571    """
572
[9148]573    p_current = schema.Bool(
574        title = _(u'Current Session Payment'),
575        default = True,
576        required = False,
577        )
578
[8268]579    p_level = schema.Int(
580        title = _(u'Payment Level'),
581        required = False,
582        readonly = True,
583        )
[6877]584
[8422]585    def doAfterStudentPayment():
586        """Process student after payment was made.
587
588        """
589
[8453]590    def doAfterStudentPaymentApproval():
591        """Process student after payment was approved.
592
593        """
594
[8420]595    def approveStudentPayment():
[8422]596        """Approve payment and process student.
[8420]597
598        """
599
[8268]600IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[
601    'p_session'].order
[8408]602
[9148]603class IStudentPreviousPayment(IOnlinePayment):
604    """An interface for adding previous session payments.
605
606    """
607
608    p_session = schema.Choice(
609        title = _(u'Payment Session'),
610        source = academic_sessions_vocab,
611        required = True,
612        )
613
614    p_level = schema.Choice(
615        title = _(u'Payment Level'),
616        source = StudyLevelSource(),
617        required = True,
618        )
619
[8408]620class ICSVStudentExporter(ICSVExporter):
621    """A regular ICSVExporter that additionally supports exporting
622      data from a given student object.
623    """
624
625    def export_student(student, filepath=None):
626        """Export data for a given student.
627        """
Note: See TracBrowser for help on using the repository browser.