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

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

Don't use a general StudentBaseEditFormPage? for students, use dedicated forms instead for password editing and file upload. The files upload page is only used for the passport picture in the base package.

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