source: main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py @ 7224

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

Now we have a configuration object and can provide ContactAdminForm? with proper credentials for a smtp server.

Add Email address to IAccount objects so that 'From' fields in emails, sent by users, can be automatically filled.

  • Property svn:keywords set to Id
File size: 11.5 KB
RevLine 
[7191]1## $Id: interfaces.py 7221 2011-11-27 06:50: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##
[6996]18from datetime import datetime
[7150]19from zope.interface import Attribute, invariant, Interface
[6756]20from zope.interface.exceptions import Invalid
[6621]21from zope import schema
[7221]22from waeup.sirp.interfaces import (
23    IWAeUPObject, academic_sessions_vocab, validate_email)
[6788]24from waeup.sirp.schema import TextLineChoice
[6874]25from waeup.sirp.university.vocabularies import CourseSource, study_modes
[6648]26from waeup.sirp.students.vocabularies import (
[7214]27  CertificateSource, verdicts, StudyLevelSource,
[6996]28  contextual_reg_num_source, contextual_mat_num_source, GenderSource,
[6648]29  )
[6877]30from waeup.sirp.payments.interfaces import IPaymentsContainer, IOnlinePayment
[6621]31
[7150]32class IStudentsUtils(Interface):
33    """A collection of methods which are subject to customization.
34
35    """
[7186]36    def getPaymentDetails(category, student):
[7150]37        """Get the payment dates of a student for the payment category
38        specified.
39
40        """
41
[7186]42    def getAccommodation_details(student):
[7150]43        """Determine the accommodation dates of a student.
44
45        """
46
[7186]47    def selectBed(available_beds):
[7150]48        """Select a bed from a list of available beds.
49
50        In the standard configuration we select the first bed found,
51        but can also randomize the selection if we like.
52        """
53
[7186]54    def renderPDF(view, subject='', filename='slip.pdf',):
[7150]55        """Render pdf slips for various pages.
56
57        """
58
[6692]59class IStudentsContainer(IWAeUPObject):
[7096]60    """A students container contains university students.
[6692]61
62    """
63    def addStudent(student):
64        """Add an IStudent object and subcontainers.
65
66        """
67
68    def archive(id=None):
69        """Create on-dist archive of students.
70
71        If id is `None`, all students are archived.
72
73        If id contains a single id string, only the respective
74        students are archived.
75
76        If id contains a list of id strings all of the respective
77        students types are saved to disk.
78        """
79
80    def clear(id=None, archive=True):
81        """Remove students of type given by 'id'.
82
83        Optionally archive the students.
84
85        If id is `None`, all students are archived.
86
87        If id contains a single id string, only the respective
88        students are archived.
89
90        If id contains a list of id strings all of the respective
91        student types are saved to disk.
92
93        If `archive` is ``False`` none of the archive-handling is done
94        and respective students are simply removed from the
95        database.
96        """
97
[6642]98class IStudentNavigation(IWAeUPObject):
99    """Interface needed for student navigation.
[7150]100
[6642]101    """
102    def getStudent():
103        """Return student object.
[7150]104
[6642]105        """
106
[6631]107class IStudentBase(IWAeUPObject):
108    """Representation of student base data.
[7150]109
[6621]110    """
[7062]111    history = Attribute('Object history, a list of messages')
[6637]112    state = Attribute('Returns the registration state of a student')
[6699]113    password = Attribute('Encrypted password of a student')
[7203]114    certcode = Attribute('The certificate code of any chosen study course')
115    depcode = Attribute('The department code of any chosen study course')
116    faccode = Attribute('The faculty code of any chosen study course')
[7062]117    current_session = Attribute('The current session of the student')
[6637]118
119    def loggerInfo(ob_class, comment):
[7150]120        """Adds an INFO message to the log file.
121
[6637]122        """
123
[6665]124    student_id = schema.TextLine(
125        title = u'Student ID',
[6849]126        required = False,
[6665]127        )
128
[6818]129    fullname = schema.TextLine(
[6631]130        title = u'Full Name',
[6818]131        default = None,
[6621]132        required = True,
133        )
134
[6996]135    sex = schema.Choice(
136        title = u'Sex',
137        source = GenderSource(),
138        default = u'm',
139        required = True,
140        )
141
[6788]142    reg_number = TextLineChoice(
[6696]143        title = u'Registration Number',
[6818]144        default = None,
[6696]145        required = True,
146        readonly = False,
[6788]147        source = contextual_reg_num_source,
[6696]148        )
149
[6788]150    matric_number = TextLineChoice(
[6750]151        title = u'Matriculation Number',
[6788]152        #default = u'',
[6750]153        required = False,
154        readonly = False,
[6788]155        source = contextual_mat_num_source,
[6750]156        )
157
[6769]158    adm_code = schema.TextLine(
[6935]159        title = u'PWD Activation Code',
[6769]160        default = u'',
161        required = False,
162        readonly = True,
163        )
164
[7133]165    email = schema.ASCIILine(
166        title = u'Email',
167        required = False,
168        constraint=validate_email,
169        )
170    phone = schema.Int(
171        title = u'Phone',
172        description = u'Enter phone number with country code and without spaces.',
173        required = False,
174        )
175
[6631]176class IStudentClearance(IWAeUPObject):
177    """Representation of student clearance data.
[7150]178
[6631]179    """
180    date_of_birth = schema.Date(
181        title = u'Date of Birth',
182        required = True,
183        )
184
[6695]185    clearance_locked = schema.Bool(
186        title = u'Clearance form locked',
187        default = False,
188        )
189
[6769]190    clr_code = schema.TextLine(
[6935]191        title = u'CLR Activation Code',
[6769]192        default = u'',
193        required = False,
194        readonly = True,
195        )
196
[6631]197class IStudentPersonal(IWAeUPObject):
198    """Representation of student personal data.
[7150]199
[6631]200    """
[6651]201    perm_address = schema.Text(
[6631]202        title = u'Permanent Address',
203        required = False,
204        )
205
206class IStudent(IStudentBase,IStudentClearance,IStudentPersonal):
207    """Representation of a student.
[7150]208
[6631]209    """
210
[6849]211class IStudentUpdateByRegNo(IStudent):
212    """Representation of a student. Skip regular reg_number validation.
[7150]213
[6849]214    """
215    reg_number = schema.TextLine(
216        title = u'Registration Number',
217        default = None,
218        required = False,
219        )
220
221class IStudentUpdateByMatricNo(IStudent):
222    """Representation of a student. Skip regular matric_number validation.
[7150]223
[6849]224    """
225    matric_number = schema.TextLine(
226        title = u'Matriculation Number',
227        default = None,
228        required = False,
229        )
230
[6633]231class IStudentStudyCourse(IWAeUPObject):
232    """A container for student study levels.
233
234    """
[6648]235    certificate = schema.Choice(
236        title = u'Certificate',
237        source = CertificateSource(),
238        default = None,
[7209]239        required = False,
[6633]240        )
[6635]241
[6996]242
243    entry_mode = schema.Choice(
244        title = u'Entry Mode',
245        vocabulary = study_modes,
246        default = u'ug_ft',
247        required = True,
248        readonly = False,
249        )
250
251    entry_session = schema.Choice(
252        title = u'Entry Session',
253        source = academic_sessions_vocab,
254        default = datetime.now().year,
255        required = True,
256        readonly = False,
257        )
258
[6724]259    current_session = schema.Choice(
260        title = u'Current Session',
[6744]261        source = academic_sessions_vocab,
[6724]262        default = None,
263        required = True,
[6996]264        readonly = False,
[6724]265        )
266
267    current_level = schema.Choice(
268        title = u'Current Level',
[6725]269        source = StudyLevelSource(),
[6724]270        default = None,
[6725]271        required = False,
[6996]272        readonly = False,
[6724]273        )
274
275    current_verdict = schema.Choice(
276        title = u'Current Verdict',
277        source = verdicts,
[6804]278        default = '0',
[6725]279        required = False,
[6724]280        )
281
282    previous_verdict = schema.Choice(
283        title = u'Previous Verdict',
284        source = verdicts,
[6805]285        default = '0',
[6725]286        required = False,
[6724]287        )
288
[6825]289class IStudentStudyCourseImport(IStudentStudyCourse):
290    """A container for student study levels.
291
292    """
293    current_level = schema.Int(
294        title = u'Current Level',
295        default = None,
296        )
297
[6774]298class IStudentStudyLevel(IWAeUPObject):
299    """A container for course tickets.
300
301    """
302    level = Attribute('The level code')
[6793]303    validation_date = Attribute('The date of validation')
304    validated_by = Attribute('User Id of course adviser')
[6774]305
[6793]306    level_session = schema.Choice(
307        title = u'Session',
308        source = academic_sessions_vocab,
309        default = None,
310        required = True,
311        )
[6781]312
[6793]313    level_verdict = schema.Choice(
314        title = u'Verdict',
315        source = verdicts,
[6805]316        default = '0',
[6793]317        required = False,
318        )
319
[6781]320class ICourseTicket(IWAeUPObject):
321    """A course ticket.
322
323    """
[6783]324    code = Attribute('code of the original course')
325    title = Attribute('title of the original course')
326    credits = Attribute('credits of the original course')
327    passmark = Attribute('passmark of the original course')
328    semester = Attribute('semester of the original course')
329    faculty = Attribute('faculty of the original course')
330    department = Attribute('department of the original course')
[6781]331
[6795]332    core_or_elective = schema.Bool(
333        title = u'Mandatory',
334        default = False,
335        required = False,
336        readonly = False,
337        )
338
[6781]339    score = schema.Int(
340        title = u'Score',
341        default = 0,
342        required = False,
343        readonly = False,
344        )
345
[6806]346    automatic = schema.Bool(
347        title = u'Automatical Creation',
348        default = False,
349        required = False,
350        readonly = True,
351        )
352
[6795]353class ICourseTicketAdd(ICourseTicket):
[7150]354    """An interface for adding course tickets.
[6795]355
356    """
357    course = schema.Choice(
358        title = u'Course',
359        source = CourseSource(),
360        readonly = False,
361        )
362
[6635]363class IStudentAccommodation(IWAeUPObject):
364    """A container for student accommodation objects.
365
366    """
367
[6989]368class IBedTicket(IWAeUPObject):
369    """A ticket for accommodation booking.
370
371    """
[6996]372    bed = Attribute('The bed object.')
373
374    bed_coordinates = schema.TextLine(
375        title = u'Bed Coordinates',
[6992]376        default = None,
377        required = False,
[7014]378        readonly = False,
[6992]379        )
380
[6996]381    bed_type = schema.TextLine(
382        title = u'Bed Type',
383        default = None,
384        required = False,
[7014]385        readonly = False,
[6996]386        )
387
[6992]388    booking_session = schema.Choice(
389        title = u'Session',
390        source = academic_sessions_vocab,
391        default = None,
392        required = True,
[7014]393        readonly = True,
[6992]394        )
395
396    booking_date = schema.Datetime(
397        title = u'Booking Date',
398        required = False,
[7014]399        readonly = True,
[6992]400        )
401
402    booking_code = schema.TextLine(
403        title = u'Booking Activation Code',
404        default = u'',
405        required = False,
[7014]406        readonly = True,
[6992]407        )
408
[6994]409    def getSessionString():
[7150]410        """Returns the the title of academic_sessions_vocab term.
411
[6994]412        """
[6992]413
[6860]414class IStudentPaymentsContainer(IPaymentsContainer):
[6635]415    """A container for student payment objects.
416
417    """
418
[6877]419class IStudentOnlinePayment(IOnlinePayment):
420    """A student payment via payment gateways.
421
422    """
423    p_session = schema.Choice(
424        title = u'Payment Session',
425        source = academic_sessions_vocab,
426        required = False,
427        )
428
429IStudentOnlinePayment['p_session'].order = IStudentOnlinePayment[
430    'p_item'].order
431
[6694]432# Interfaces for students only
433
434class IStudentClearanceEdit(IStudentClearance):
435    """Interface needed for restricted editing of student clearance data.
[7150]436
[6694]437    """
438
439class IStudentPersonalEdit(IStudentPersonal):
440    """Interface needed for restricted editing of student personal data.
[7150]441
[6694]442    """
Note: See TracBrowser for help on using the repository browser.