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

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

Simplify change password algorithm. No interface IStudentPasswordSetting needed, no adapter StudentPasswordSetting? needed.

I have to think about using a global utility instead of the validatePassword function in utils.py. Therefore validatePassword is not yet used by the PasswordChangeCredentialsPlugin?.

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