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

Last change on this file since 6851 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
Line 
1##
2## interfaces.py
3from zope.interface import Attribute, invariant
4from zope.interface.exceptions import Invalid
5from zope import schema
6from waeup.sirp.interfaces import IWAeUPObject
7from waeup.sirp.schema import TextLineChoice
8from waeup.sirp.university.vocabularies import CourseSource
9from waeup.sirp.students.vocabularies import (
10  CertificateSource, academic_sessions_vocab, verdicts, StudyLevelSource,
11  contextual_reg_num_source, contextual_mat_num_source,
12  )
13
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
54class IStudentNavigation(IWAeUPObject):
55    """Interface needed for student navigation.
56    """
57
58    def getStudent():
59        """Return student object.
60        """
61
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,
69        readonly = True
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
88class IStudentBase(IWAeUPObject):
89    """Representation of student base data.
90    """
91    history = Attribute('Object history, a list of messages.')
92    state = Attribute('Returns the registration state of a student')
93    password = Attribute('Encrypted password of a student')
94    certificate = Attribute('The certificate of any chosen study course')
95
96    def loggerInfo(ob_class, comment):
97        """Adds an INFO message to the log file
98        """
99
100    student_id = schema.TextLine(
101        title = u'Student ID',
102        required = False,
103        )
104
105    fullname = schema.TextLine(
106        title = u'Full Name',
107        default = None,
108        required = True,
109        )
110
111    reg_number = TextLineChoice(
112        title = u'Registration Number',
113        default = None,
114        required = True,
115        readonly = False,
116        source = contextual_reg_num_source,
117        )
118
119    matric_number = TextLineChoice(
120        title = u'Matriculation Number',
121        #default = u'',
122        required = False,
123        readonly = False,
124        source = contextual_mat_num_source,
125        )
126
127    adm_code = schema.TextLine(
128        title = u'PWD Access Code',
129        default = u'',
130        required = False,
131        readonly = True,
132        )
133
134class IStudentClearance(IWAeUPObject):
135    """Representation of student clearance data.
136    """
137
138    date_of_birth = schema.Date(
139        title = u'Date of Birth',
140        required = True,
141        )
142
143    clearance_locked = schema.Bool(
144        title = u'Clearance form locked',
145        default = False,
146        )
147
148    clr_code = schema.TextLine(
149        title = u'CLR Access Code',
150        default = u'',
151        required = False,
152        readonly = True,
153        )
154
155class IStudentPersonal(IWAeUPObject):
156    """Representation of student personal data.
157    """
158
159    perm_address = schema.Text(
160        title = u'Permanent Address',
161        required = False,
162        )
163
164class IStudent(IStudentBase,IStudentClearance,IStudentPersonal):
165    """Representation of a student.
166    """
167
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
188class IStudentStudyCourse(IWAeUPObject):
189    """A container for student study levels.
190
191    """
192
193    certificate = schema.Choice(
194        title = u'Certificate',
195        source = CertificateSource(),
196        default = None,
197        required = True,
198        )
199
200    current_session = schema.Choice(
201        title = u'Current Session',
202        source = academic_sessions_vocab,
203        default = None,
204        required = True,
205        )
206
207    current_level = schema.Choice(
208        title = u'Current Level',
209        source = StudyLevelSource(),
210        default = None,
211        required = False,
212        )
213
214    current_verdict = schema.Choice(
215        title = u'Current Verdict',
216        source = verdicts,
217        default = '0',
218        required = False,
219        )
220
221    previous_verdict = schema.Choice(
222        title = u'Previous Verdict',
223        source = verdicts,
224        default = '0',
225        required = False,
226        )
227
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
238class IStudentStudyLevel(IWAeUPObject):
239    """A container for course tickets.
240
241    """
242    level = Attribute('The level code')
243    validation_date = Attribute('The date of validation')
244    validated_by = Attribute('User Id of course adviser')
245
246    level_session = schema.Choice(
247        title = u'Session',
248        source = academic_sessions_vocab,
249        default = None,
250        required = True,
251        )
252
253    level_verdict = schema.Choice(
254        title = u'Verdict',
255        source = verdicts,
256        default = '0',
257        required = False,
258        )
259
260class ICourseTicket(IWAeUPObject):
261    """A course ticket.
262
263    """
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')
271
272    core_or_elective = schema.Bool(
273        title = u'Mandatory',
274        default = False,
275        required = False,
276        readonly = False,
277        )
278
279    score = schema.Int(
280        title = u'Score',
281        default = 0,
282        required = False,
283        readonly = False,
284        )
285
286    automatic = schema.Bool(
287        title = u'Automatical Creation',
288        default = False,
289        required = False,
290        readonly = True,
291        )
292
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
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
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.