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

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

Use a constraint for password validation.

It seems that the constraint does not comply with the PasswordChangeCredentialsPlugin?. The test fails because the new credentials have been set although the form validation failed.

What shall we do?

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