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

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

pyflakes

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