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

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

Add current_session to students_catalog indexes.

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