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

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

Searching for reg_numbers or matric_numbers makes batch importing more difficult. Field validation must be skipped for reg_numbers and matric_numbers respectively if these fields are used for seeking students. After quite a lot of experiments I came to the conclusion that we need dedicated interfaces to skip the regular validation.

  • Property svn:keywords set to Id
File size: 8.0 KB
RevLine 
[6621]1##
2## interfaces.py
[6788]3from zope.interface import Attribute, invariant
[6756]4from zope.interface.exceptions import Invalid
[6621]5from zope import schema
6from waeup.sirp.interfaces import IWAeUPObject
[6788]7from waeup.sirp.schema import TextLineChoice
[6795]8from waeup.sirp.university.vocabularies import CourseSource
[6648]9from waeup.sirp.students.vocabularies import (
[6788]10  CertificateSource, academic_sessions_vocab, verdicts, StudyLevelSource,
11  contextual_reg_num_source, contextual_mat_num_source,
[6648]12  )
[6621]13
[6692]14class IStudentsContainer(IWAeUPObject):
15    """An students container contains university students.
16
17    """
18
19    def addStudent(student):
20        """Add an IStudent object and subcontainers.
21
22        """
23
24    def archive(id=None):
25        """Create on-dist archive of students.
26
27        If id is `None`, all students are archived.
28
29        If id contains a single id string, only the respective
30        students are archived.
31
32        If id contains a list of id strings all of the respective
33        students types are saved to disk.
34        """
35
36    def clear(id=None, archive=True):
37        """Remove students of type given by 'id'.
38
39        Optionally archive the 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        student types are saved to disk.
48
49        If `archive` is ``False`` none of the archive-handling is done
50        and respective students are simply removed from the
51        database.
52        """
53
[6642]54class IStudentNavigation(IWAeUPObject):
55    """Interface needed for student navigation.
56    """
57
58    def getStudent():
59        """Return student object.
60        """
61
[6756]62class IStudentPasswordSetting(IWAeUPObject):
63    """Data needed for password setting.
64    """
65    name = schema.TextLine(
66        title = u'Full Name',
67        default = u'Nobody',
68        required = True,
[6764]69        readonly = True
[6756]70        )
71
72    password = schema.Password(
73        title = u'New password',
74        required = False,
75        )
76
77    password_repeat = schema.Password(
78        title = u'Retype new password',
79        required = False,
80        )
81
82    @invariant
83    def passwords_match(obj):
84        if obj.password == obj.password_repeat:
85            return
86        raise Invalid('passwords do not match')
87
[6631]88class IStudentBase(IWAeUPObject):
89    """Representation of student base data.
[6621]90    """
[6637]91    history = Attribute('Object history, a list of messages.')
92    state = Attribute('Returns the registration state of a student')
[6699]93    password = Attribute('Encrypted password of a student')
[6814]94    certificate = Attribute('The certificate of any chosen study course')
[6637]95
96    def loggerInfo(ob_class, comment):
97        """Adds an INFO message to the log file
98        """
99
[6665]100    student_id = schema.TextLine(
101        title = u'Student ID',
[6849]102        required = False,
[6665]103        )
104
[6818]105    fullname = schema.TextLine(
[6631]106        title = u'Full Name',
[6818]107        default = None,
[6621]108        required = True,
109        )
110
[6788]111    reg_number = TextLineChoice(
[6696]112        title = u'Registration Number',
[6818]113        default = None,
[6696]114        required = True,
115        readonly = False,
[6788]116        source = contextual_reg_num_source,
[6696]117        )
118
[6788]119    matric_number = TextLineChoice(
[6750]120        title = u'Matriculation Number',
[6788]121        #default = u'',
[6750]122        required = False,
123        readonly = False,
[6788]124        source = contextual_mat_num_source,
[6750]125        )
126
[6769]127    adm_code = schema.TextLine(
[6771]128        title = u'PWD Access Code',
[6769]129        default = u'',
130        required = False,
131        readonly = True,
132        )
133
[6631]134class IStudentClearance(IWAeUPObject):
135    """Representation of student clearance data.
136    """
[6622]137
[6631]138    date_of_birth = schema.Date(
139        title = u'Date of Birth',
140        required = True,
141        )
142
[6695]143    clearance_locked = schema.Bool(
144        title = u'Clearance form locked',
145        default = False,
146        )
147
[6769]148    clr_code = schema.TextLine(
[6771]149        title = u'CLR Access Code',
[6769]150        default = u'',
151        required = False,
152        readonly = True,
153        )
154
[6631]155class IStudentPersonal(IWAeUPObject):
156    """Representation of student personal data.
157    """
158
[6651]159    perm_address = schema.Text(
[6631]160        title = u'Permanent Address',
161        required = False,
162        )
163
164class IStudent(IStudentBase,IStudentClearance,IStudentPersonal):
165    """Representation of a student.
166    """
167
[6849]168class IStudentUpdateByRegNo(IStudent):
169    """Representation of a student. Skip regular reg_number validation.
170    """
171
172    reg_number = schema.TextLine(
173        title = u'Registration Number',
174        default = None,
175        required = False,
176        )
177
178class IStudentUpdateByMatricNo(IStudent):
179    """Representation of a student. Skip regular matric_number validation.
180    """
181
182    matric_number = schema.TextLine(
183        title = u'Matriculation Number',
184        default = None,
185        required = False,
186        )
187
[6633]188class IStudentStudyCourse(IWAeUPObject):
189    """A container for student study levels.
190
191    """
192
[6648]193    certificate = schema.Choice(
194        title = u'Certificate',
195        source = CertificateSource(),
196        default = None,
[6633]197        required = True,
198        )
[6635]199
[6724]200    current_session = schema.Choice(
201        title = u'Current Session',
[6744]202        source = academic_sessions_vocab,
[6724]203        default = None,
204        required = True,
205        )
206
207    current_level = schema.Choice(
208        title = u'Current Level',
[6725]209        source = StudyLevelSource(),
[6724]210        default = None,
[6725]211        required = False,
[6724]212        )
213
214    current_verdict = schema.Choice(
215        title = u'Current Verdict',
216        source = verdicts,
[6804]217        default = '0',
[6725]218        required = False,
[6724]219        )
220
221    previous_verdict = schema.Choice(
222        title = u'Previous Verdict',
223        source = verdicts,
[6805]224        default = '0',
[6725]225        required = False,
[6724]226        )
227
[6825]228class IStudentStudyCourseImport(IStudentStudyCourse):
229    """A container for student study levels.
230
231    """
232
233    current_level = schema.Int(
234        title = u'Current Level',
235        default = None,
236        )
237
[6774]238class IStudentStudyLevel(IWAeUPObject):
239    """A container for course tickets.
240
241    """
242    level = Attribute('The level code')
[6793]243    validation_date = Attribute('The date of validation')
244    validated_by = Attribute('User Id of course adviser')
[6774]245
[6793]246    level_session = schema.Choice(
247        title = u'Session',
248        source = academic_sessions_vocab,
249        default = None,
250        required = True,
251        )
[6781]252
[6793]253    level_verdict = schema.Choice(
254        title = u'Verdict',
255        source = verdicts,
[6805]256        default = '0',
[6793]257        required = False,
258        )
259
[6781]260class ICourseTicket(IWAeUPObject):
261    """A course ticket.
262
263    """
[6783]264    code = Attribute('code of the original course')
265    title = Attribute('title of the original course')
266    credits = Attribute('credits of the original course')
267    passmark = Attribute('passmark of the original course')
268    semester = Attribute('semester of the original course')
269    faculty = Attribute('faculty of the original course')
270    department = Attribute('department of the original course')
[6781]271
[6795]272    core_or_elective = schema.Bool(
273        title = u'Mandatory',
274        default = False,
275        required = False,
276        readonly = False,
277        )
278
[6781]279    score = schema.Int(
280        title = u'Score',
281        default = 0,
282        required = False,
283        readonly = False,
284        )
285
[6806]286    automatic = schema.Bool(
287        title = u'Automatical Creation',
288        default = False,
289        required = False,
290        readonly = True,
291        )
292
[6795]293class ICourseTicketAdd(ICourseTicket):
294    """An interface for adding course tickets
295
296    """
297    course = schema.Choice(
298        title = u'Course',
299        source = CourseSource(),
300        readonly = False,
301        )
302
[6635]303class IStudentAccommodation(IWAeUPObject):
304    """A container for student accommodation objects.
305
306    """
307
308class IStudentPayments(IWAeUPObject):
309    """A container for student payment objects.
310
311    """
312
[6694]313# Interfaces for students only
314
315class IStudentClearanceEdit(IStudentClearance):
316    """Interface needed for restricted editing of student clearance data.
317    """
318
319class IStudentPersonalEdit(IStudentPersonal):
320    """Interface needed for restricted editing of student personal data.
321    """
Note: See TracBrowser for help on using the repository browser.