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

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

Add password request page for first-time login withot email address and pwd activation code.

To do: What happens if a wrong email address has been entered. Solution: We need to remember if a student has logged in.

  • Property svn:keywords set to Id
File size: 14.7 KB
RevLine 
[7191]1## $Id: interfaces.py 8779 2012-06-23 06:32:56Z 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
[8779]283class IStudentRequestPW(IStudent):
284    """Representation of an student for first-time password request.
285
286    This interface is used when students use the requestpw page to
287    login for the the first time.
288    """
289    reg_number = schema.TextLine(
290        title = u'Registration Number',
291        required = True,
292        )
293
294    firstname = schema.TextLine(
295        title = _(u'First Name'),
296        required = True,
297        )
298
299    email = schema.ASCIILine(
300        title = _(u'Email Address'),
301        required = True,
302        constraint=validate_email,
303        )
304
[7819]305class IStudentStudyCourse(IKofaObject):
[6633]306    """A container for student study levels.
307
308    """
[6648]309    certificate = schema.Choice(
[7723]310        title = _(u'Certificate'),
[6648]311        source = CertificateSource(),
[7209]312        required = False,
[6633]313        )
[6635]314
[6996]315    entry_mode = schema.Choice(
[7723]316        title = _(u'Entry Mode'),
[7681]317        source = StudyModeSource(),
[6996]318        required = True,
319        readonly = False,
320        )
321
322    entry_session = schema.Choice(
[7723]323        title = _(u'Entry Session'),
[6996]324        source = academic_sessions_vocab,
[7425]325        #default = datetime.now().year,
[6996]326        required = True,
327        readonly = False,
328        )
329
[6724]330    current_session = schema.Choice(
[7723]331        title = _(u'Current Session'),
[6744]332        source = academic_sessions_vocab,
[6724]333        required = True,
[6996]334        readonly = False,
[6724]335        )
336
337    current_level = schema.Choice(
[7723]338        title = _(u'Current Level'),
[6725]339        source = StudyLevelSource(),
340        required = False,
[6996]341        readonly = False,
[6724]342        )
343
344    current_verdict = schema.Choice(
[7723]345        title = _(u'Current Verdict'),
[7619]346        source = VerdictSource(),
[8621]347        default = 'NY',
[6725]348        required = False,
[6724]349        )
350
351    previous_verdict = schema.Choice(
[7723]352        title = _(u'Previous Verdict'),
[7619]353        source = VerdictSource(),
[8621]354        default = 'NY',
[6725]355        required = False,
[6724]356        )
357
[7951]358class IStudentVerdictUpdate(IKofaObject):
359    """A interface for verdict imports.
360
361    """
362
363    current_verdict = schema.Choice(
364        title = _(u'Current Verdict'),
365        source = VerdictSource(),
366        required = True,
367        )
368
369    current_session = schema.Choice(
370        title = _(u'Current Session'),
371        source = academic_sessions_vocab,
372        required = True,
373        )
374
375    current_level = schema.Choice(
376        title = _(u'Current Level'),
377        source = StudyLevelSource(),
378        required = True,
379        )
380
[7819]381class IStudentStudyLevel(IKofaObject):
[6774]382    """A container for course tickets.
383
384    """
385    level = Attribute('The level code')
[6793]386    validation_date = Attribute('The date of validation')
387    validated_by = Attribute('User Id of course adviser')
[6774]388
[6793]389    level_session = schema.Choice(
[7723]390        title = _(u'Session'),
[6793]391        source = academic_sessions_vocab,
392        required = True,
393        )
[6781]394
[6793]395    level_verdict = schema.Choice(
[7723]396        title = _(u'Verdict'),
[7619]397        source = VerdictSource(),
[8621]398        default = 'NY',
[6793]399        required = False,
400        )
401
[8182]402    def addCourseTicket(courseticket):
403        """Add a course ticket object.
404        """
405
[7819]406class ICourseTicket(IKofaObject):
[6781]407    """A course ticket.
408
409    """
[6783]410    code = Attribute('code of the original course')
411    title = Attribute('title of the original course')
412    credits = Attribute('credits of the original course')
413    passmark = Attribute('passmark of the original course')
414    semester = Attribute('semester of the original course')
[7304]415    fcode = Attribute('faculty code of the original course')
416    dcode = Attribute('department code of the original course')
[6781]417
[7665]418    mandatory = schema.Bool(
[7723]419        title = _(u'Mandatory'),
[6795]420        default = False,
421        required = False,
422        readonly = False,
423        )
424
[6781]425    score = schema.Int(
[7723]426        title = _(u'Score'),
[6781]427        default = 0,
428        required = False,
429        readonly = False,
430        )
431
[6806]432    automatic = schema.Bool(
[7723]433        title = _(u'Automatical Creation'),
[6806]434        default = False,
435        required = False,
436        readonly = True,
437        )
438
[7661]439    carry_over = schema.Bool(
[7723]440        title = _(u'Carry-over Course'),
[7661]441        default = False,
442        required = False,
443        readonly = False,
444        )
445
[7633]446    def getLevel():
447        """Returns the id of the level the ticket has been added to.
448        """
449
450    def getLevelSession():
451        """Returns the session of the level the ticket has been added to.
452        """
453
[6795]454class ICourseTicketAdd(ICourseTicket):
[7150]455    """An interface for adding course tickets.
[6795]456
457    """
458    course = schema.Choice(
[7723]459        title = _(u'Course'),
[6795]460        source = CourseSource(),
461        readonly = False,
462        )
463
[7819]464class IStudentAccommodation(IKofaObject):
[6635]465    """A container for student accommodation objects.
466
467    """
468
[7819]469class IBedTicket(IKofaObject):
[6989]470    """A ticket for accommodation booking.
471
472    """
[6996]473    bed = Attribute('The bed object.')
474
475    bed_coordinates = schema.TextLine(
[7723]476        title = _(u'Bed Coordinates'),
[6992]477        required = False,
[7014]478        readonly = False,
[6992]479        )
480
[6996]481    bed_type = schema.TextLine(
[7723]482        title = _(u'Bed Type'),
[6996]483        required = False,
[7014]484        readonly = False,
[6996]485        )
486
[6992]487    booking_session = schema.Choice(
[7723]488        title = _(u'Session'),
[6992]489        source = academic_sessions_vocab,
490        required = True,
[7014]491        readonly = True,
[6992]492        )
493
[8170]494    booking_date = schema.Datetime(
[7723]495        title = _(u'Booking Date'),
[6992]496        required = False,
[7014]497        readonly = True,
[6992]498        )
499
500    booking_code = schema.TextLine(
[7723]501        title = _(u'Booking Activation Code'),
[6992]502        required = False,
[7014]503        readonly = True,
[6992]504        )
505
[6994]506    def getSessionString():
[7633]507        """Returns the title of academic_sessions_vocab term.
[7150]508
[6994]509        """
[6992]510
[6860]511class IStudentPaymentsContainer(IPaymentsContainer):
[6635]512    """A container for student payment objects.
513
514    """
515
[6877]516class IStudentOnlinePayment(IOnlinePayment):
517    """A student payment via payment gateways.
518
519    """
520
[8268]521    p_level = schema.Int(
522        title = _(u'Payment Level'),
523        required = False,
524        readonly = True,
525        )
[6877]526
[8422]527    def doAfterStudentPayment():
528        """Process student after payment was made.
529
530        """
531
[8453]532    def doAfterStudentPaymentApproval():
533        """Process student after payment was approved.
534
535        """
536
[8420]537    def approveStudentPayment():
[8422]538        """Approve payment and process student.
[8420]539
540        """
541
[8268]542IStudentOnlinePayment['p_level'].order = IStudentOnlinePayment[
543    'p_session'].order
[8408]544
545class ICSVStudentExporter(ICSVExporter):
546    """A regular ICSVExporter that additionally supports exporting
547      data from a given student object.
548    """
549
550    def export_student(student, filepath=None):
551        """Export data for a given student.
552        """
Note: See TracBrowser for help on using the repository browser.