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

Last change on this file since 8759 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
RevLine 
[7191]1## $Id: interfaces.py 8736 2012-06-17 07:09:21Z 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
[7688]44        return 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
[7688]51        return verdicts_dict[value]
[7620]52
[7681]53
[7150]54class IStudentsUtils(Interface):
55    """A collection of methods which are subject to customization.
56
57    """
[7841]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
[8595]66    def setPaymentDetails(category, student):
67        """Create Payment object and set the payment data of a student for
68        the payment category specified.
[7150]69
70        """
71
[7186]72    def getAccommodation_details(student):
[7150]73        """Determine the accommodation dates of a student.
74
75        """
76
[7186]77    def selectBed(available_beds):
[7150]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
[7186]84    def renderPDF(view, subject='', filename='slip.pdf',):
[7150]85        """Render pdf slips for various pages.
86
87        """
88
[7819]89class IStudentsContainer(IKofaObject):
[7096]90    """A students container contains university students.
[6692]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
[8408]128    unique_student_id = Attribute("""A unique student id.""")
129
[7819]130class IStudentNavigation(IKofaObject):
[8735]131    """Interface needed for student navigation, logging, etc.
[7150]132
[6642]133    """
[8736]134    student = Attribute('Student object of context.')
[7150]135
[8735]136    def writeLogMessage(view, message):
137        """Write a view specific log message into students.log.
138
139        """
140
[7819]141class IStudentBase(IKofaObject):
[6631]142    """Representation of student base data.
[7150]143
[6621]144    """
[7062]145    history = Attribute('Object history, a list of messages')
[6637]146    state = Attribute('Returns the registration state of a student')
[6699]147    password = Attribute('Encrypted password of a student')
[7203]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')
[7062]151    current_session = Attribute('The current session of the student')
[7641]152    current_mode = Attribute('The current mode of the student')
[7364]153    fullname = Attribute('All name parts separated by hyphens')
154    display_fullname = Attribute('The fullname of an applicant')
[6637]155
[6665]156    student_id = schema.TextLine(
[7723]157        title = _(u'Student Id'),
[6849]158        required = False,
[6665]159        )
160
[7357]161    firstname = schema.TextLine(
[7723]162        title = _(u'First Name'),
[6621]163        required = True,
164        )
165
[7357]166    middlename = schema.TextLine(
[7723]167        title = _(u'Middle Name'),
[7357]168        required = False,
169        )
170
171    lastname = schema.TextLine(
[7723]172        title = _(u'Last Name (Surname)'),
[7357]173        required = True,
174        )
175
[6996]176    sex = schema.Choice(
[7723]177        title = _(u'Sex'),
[6996]178        source = GenderSource(),
179        required = True,
180        )
181
[6788]182    reg_number = TextLineChoice(
[7723]183        title = _(u'Registration Number'),
[6696]184        required = True,
185        readonly = False,
[6788]186        source = contextual_reg_num_source,
[6696]187        )
188
[6788]189    matric_number = TextLineChoice(
[7723]190        title = _(u'Matriculation Number'),
[6750]191        required = False,
192        readonly = False,
[6788]193        source = contextual_mat_num_source,
[6750]194        )
195
[6769]196    adm_code = schema.TextLine(
[7723]197        title = _(u'PWD Activation Code'),
[6769]198        required = False,
199        readonly = True,
200        )
201
[7133]202    email = schema.ASCIILine(
[7723]203        title = _(u'Email'),
[7133]204        required = False,
205        constraint=validate_email,
206        )
[8176]207    phone = PhoneNumber(
[7723]208        title = _(u'Phone'),
[7331]209        description = u'',
[7133]210        required = False,
211        )
212
[7993]213class IUGStudentClearance(IKofaObject):
214    """Representation of undergraduate student clearance data.
[7150]215
[6631]216    """
[8160]217    date_of_birth = FormattedDate(
[7723]218        title = _(u'Date of Birth'),
[6631]219        required = True,
[8160]220        show_year = True,
[6631]221        )
222
[6695]223    clearance_locked = schema.Bool(
[7723]224        title = _(u'Clearance form locked'),
[6695]225        default = False,
226        )
227
[6769]228    clr_code = schema.TextLine(
[7723]229        title = _(u'CLR Activation Code'),
[6769]230        required = False,
231        readonly = True,
232        )
233
[7523]234    nationality = schema.Choice(
[8069]235        vocabulary = nats_vocab,
[7723]236        title = _(u'Nationality'),
[7983]237        required = False,
[7523]238        )
239
[7993]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
[7819]250class IStudentPersonal(IKofaObject):
[6631]251    """Representation of student personal data.
[7150]252
[6631]253    """
[6651]254    perm_address = schema.Text(
[7723]255        title = _(u'Permanent Address'),
[6631]256        required = False,
257        )
258
[8008]259class IStudent(IStudentBase,IUGStudentClearance,IPGStudentClearance,
260    IStudentPersonal):
[6631]261    """Representation of a student.
[7150]262
[6631]263    """
264
[6849]265class IStudentUpdateByRegNo(IStudent):
266    """Representation of a student. Skip regular reg_number validation.
[7150]267
[6849]268    """
269    reg_number = schema.TextLine(
[7723]270        title = _(u'Registration Number'),
[6849]271        required = False,
272        )
273
274class IStudentUpdateByMatricNo(IStudent):
275    """Representation of a student. Skip regular matric_number validation.
[7150]276
[6849]277    """
278    matric_number = schema.TextLine(
[7723]279        title = _(u'Matriculation Number'),
[6849]280        required = False,
281        )
282
[7819]283class IStudentStudyCourse(IKofaObject):
[6633]284    """A container for student study levels.
285
286    """
[6648]287    certificate = schema.Choice(
[7723]288        title = _(u'Certificate'),
[6648]289        source = CertificateSource(),
[7209]290        required = False,
[6633]291        )
[6635]292
[6996]293    entry_mode = schema.Choice(
[7723]294        title = _(u'Entry Mode'),
[7681]295        source = StudyModeSource(),
[6996]296        required = True,
297        readonly = False,
298        )
299
300    entry_session = schema.Choice(
[7723]301        title = _(u'Entry Session'),
[6996]302        source = academic_sessions_vocab,
[7425]303        #default = datetime.now().year,
[6996]304        required = True,
305        readonly = False,
306        )
307
[6724]308    current_session = schema.Choice(
[7723]309        title = _(u'Current Session'),
[6744]310        source = academic_sessions_vocab,
[6724]311        required = True,
[6996]312        readonly = False,
[6724]313        )
314
315    current_level = schema.Choice(
[7723]316        title = _(u'Current Level'),
[6725]317        source = StudyLevelSource(),
318        required = False,
[6996]319        readonly = False,
[6724]320        )
321
322    current_verdict = schema.Choice(
[7723]323        title = _(u'Current Verdict'),
[7619]324        source = VerdictSource(),
[8621]325        default = 'NY',
[6725]326        required = False,
[6724]327        )
328
329    previous_verdict = schema.Choice(
[7723]330        title = _(u'Previous Verdict'),
[7619]331        source = VerdictSource(),
[8621]332        default = 'NY',
[6725]333        required = False,
[6724]334        )
335
[7951]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
[7819]359class IStudentStudyLevel(IKofaObject):
[6774]360    """A container for course tickets.
361
362    """
363    level = Attribute('The level code')
[6793]364    validation_date = Attribute('The date of validation')
365    validated_by = Attribute('User Id of course adviser')
[6774]366
[6793]367    level_session = schema.Choice(
[7723]368        title = _(u'Session'),
[6793]369        source = academic_sessions_vocab,
370        required = True,
371        )
[6781]372
[6793]373    level_verdict = schema.Choice(
[7723]374        title = _(u'Verdict'),
[7619]375        source = VerdictSource(),
[8621]376        default = 'NY',
[6793]377        required = False,
378        )
379
[8182]380    def addCourseTicket(courseticket):
381        """Add a course ticket object.
382        """
383
[7819]384class ICourseTicket(IKofaObject):
[6781]385    """A course ticket.
386
387    """
[6783]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')
[7304]393    fcode = Attribute('faculty code of the original course')
394    dcode = Attribute('department code of the original course')
[6781]395
[7665]396    mandatory = schema.Bool(
[7723]397        title = _(u'Mandatory'),
[6795]398        default = False,
399        required = False,
400        readonly = False,
401        )
402
[6781]403    score = schema.Int(
[7723]404        title = _(u'Score'),
[6781]405        default = 0,
406        required = False,
407        readonly = False,
408        )
409
[6806]410    automatic = schema.Bool(
[7723]411        title = _(u'Automatical Creation'),
[6806]412        default = False,
413        required = False,
414        readonly = True,
415        )
416
[7661]417    carry_over = schema.Bool(
[7723]418        title = _(u'Carry-over Course'),
[7661]419        default = False,
420        required = False,
421        readonly = False,
422        )
423
[7633]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
[6795]432class ICourseTicketAdd(ICourseTicket):
[7150]433    """An interface for adding course tickets.
[6795]434
435    """
436    course = schema.Choice(
[7723]437        title = _(u'Course'),
[6795]438        source = CourseSource(),
439        readonly = False,
440        )
441
[7819]442class IStudentAccommodation(IKofaObject):
[6635]443    """A container for student accommodation objects.
444
445    """
446
[7819]447class IBedTicket(IKofaObject):
[6989]448    """A ticket for accommodation booking.
449
450    """
[6996]451    bed = Attribute('The bed object.')
452
453    bed_coordinates = schema.TextLine(
[7723]454        title = _(u'Bed Coordinates'),
[6992]455        required = False,
[7014]456        readonly = False,
[6992]457        )
458
[6996]459    bed_type = schema.TextLine(
[7723]460        title = _(u'Bed Type'),
[6996]461        required = False,
[7014]462        readonly = False,
[6996]463        )
464
[6992]465    booking_session = schema.Choice(
[7723]466        title = _(u'Session'),
[6992]467        source = academic_sessions_vocab,
468        required = True,
[7014]469        readonly = True,
[6992]470        )
471
[8170]472    booking_date = schema.Datetime(
[7723]473        title = _(u'Booking Date'),
[6992]474        required = False,
[7014]475        readonly = True,
[6992]476        )
477
478    booking_code = schema.TextLine(
[7723]479        title = _(u'Booking Activation Code'),
[6992]480        required = False,
[7014]481        readonly = True,
[6992]482        )
483
[6994]484    def getSessionString():
[7633]485        """Returns the title of academic_sessions_vocab term.
[7150]486
[6994]487        """
[6992]488
[6860]489class IStudentPaymentsContainer(IPaymentsContainer):
[6635]490    """A container for student payment objects.
491
492    """
493
[6877]494class IStudentOnlinePayment(IOnlinePayment):
495    """A student payment via payment gateways.
496
497    """
498
[8268]499    p_level = schema.Int(
500        title = _(u'Payment Level'),
501        required = False,
502        readonly = True,
503        )
[6877]504
[8422]505    def doAfterStudentPayment():
506        """Process student after payment was made.
507
508        """
509
[8453]510    def doAfterStudentPaymentApproval():
511        """Process student after payment was approved.
512
513        """
514
[8420]515    def approveStudentPayment():
[8422]516        """Approve payment and process student.
[8420]517
518        """
519
[8268]520IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[
521    'p_session'].order
[8408]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.