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

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

Now we have a configuration object and can provide ContactAdminForm? with proper credentials for a smtp server.

Add Email address to IAccount objects so that 'From' fields in emails, sent by users, can be automatically filled.

  • Property svn:keywords set to Id
File size: 11.5 KB
Line 
1## $Id: interfaces.py 7221 2011-11-27 06:50:43Z henrik $
2##
3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18from datetime import datetime
19from zope.interface import Attribute, invariant, Interface
20from zope.interface.exceptions import Invalid
21from zope import schema
22from waeup.sirp.interfaces import (
23    IWAeUPObject, academic_sessions_vocab, validate_email)
24from waeup.sirp.schema import TextLineChoice
25from waeup.sirp.university.vocabularies import CourseSource, study_modes
26from waeup.sirp.students.vocabularies import (
27  CertificateSource, verdicts, StudyLevelSource,
28  contextual_reg_num_source, contextual_mat_num_source, GenderSource,
29  )
30from waeup.sirp.payments.interfaces import IPaymentsContainer, IOnlinePayment
31
32class IStudentsUtils(Interface):
33    """A collection of methods which are subject to customization.
34
35    """
36    def getPaymentDetails(category, student):
37        """Get the payment dates of a student for the payment category
38        specified.
39
40        """
41
42    def getAccommodation_details(student):
43        """Determine the accommodation dates of a student.
44
45        """
46
47    def selectBed(available_beds):
48        """Select a bed from a list of available beds.
49
50        In the standard configuration we select the first bed found,
51        but can also randomize the selection if we like.
52        """
53
54    def renderPDF(view, subject='', filename='slip.pdf',):
55        """Render pdf slips for various pages.
56
57        """
58
59class IStudentsContainer(IWAeUPObject):
60    """A students container contains university students.
61
62    """
63    def addStudent(student):
64        """Add an IStudent object and subcontainers.
65
66        """
67
68    def archive(id=None):
69        """Create on-dist archive of students.
70
71        If id is `None`, all students are archived.
72
73        If id contains a single id string, only the respective
74        students are archived.
75
76        If id contains a list of id strings all of the respective
77        students types are saved to disk.
78        """
79
80    def clear(id=None, archive=True):
81        """Remove students of type given by 'id'.
82
83        Optionally archive the students.
84
85        If id is `None`, all students are archived.
86
87        If id contains a single id string, only the respective
88        students are archived.
89
90        If id contains a list of id strings all of the respective
91        student types are saved to disk.
92
93        If `archive` is ``False`` none of the archive-handling is done
94        and respective students are simply removed from the
95        database.
96        """
97
98class IStudentNavigation(IWAeUPObject):
99    """Interface needed for student navigation.
100
101    """
102    def getStudent():
103        """Return student object.
104
105        """
106
107class IStudentBase(IWAeUPObject):
108    """Representation of student base data.
109
110    """
111    history = Attribute('Object history, a list of messages')
112    state = Attribute('Returns the registration state of a student')
113    password = Attribute('Encrypted password of a student')
114    certcode = Attribute('The certificate code of any chosen study course')
115    depcode = Attribute('The department code of any chosen study course')
116    faccode = Attribute('The faculty code of any chosen study course')
117    current_session = Attribute('The current session of the student')
118
119    def loggerInfo(ob_class, comment):
120        """Adds an INFO message to the log file.
121
122        """
123
124    student_id = schema.TextLine(
125        title = u'Student ID',
126        required = False,
127        )
128
129    fullname = schema.TextLine(
130        title = u'Full Name',
131        default = None,
132        required = True,
133        )
134
135    sex = schema.Choice(
136        title = u'Sex',
137        source = GenderSource(),
138        default = u'm',
139        required = True,
140        )
141
142    reg_number = TextLineChoice(
143        title = u'Registration Number',
144        default = None,
145        required = True,
146        readonly = False,
147        source = contextual_reg_num_source,
148        )
149
150    matric_number = TextLineChoice(
151        title = u'Matriculation Number',
152        #default = u'',
153        required = False,
154        readonly = False,
155        source = contextual_mat_num_source,
156        )
157
158    adm_code = schema.TextLine(
159        title = u'PWD Activation Code',
160        default = u'',
161        required = False,
162        readonly = True,
163        )
164
165    email = schema.ASCIILine(
166        title = u'Email',
167        required = False,
168        constraint=validate_email,
169        )
170    phone = schema.Int(
171        title = u'Phone',
172        description = u'Enter phone number with country code and without spaces.',
173        required = False,
174        )
175
176class IStudentClearance(IWAeUPObject):
177    """Representation of student clearance data.
178
179    """
180    date_of_birth = schema.Date(
181        title = u'Date of Birth',
182        required = True,
183        )
184
185    clearance_locked = schema.Bool(
186        title = u'Clearance form locked',
187        default = False,
188        )
189
190    clr_code = schema.TextLine(
191        title = u'CLR Activation Code',
192        default = u'',
193        required = False,
194        readonly = True,
195        )
196
197class IStudentPersonal(IWAeUPObject):
198    """Representation of student personal data.
199
200    """
201    perm_address = schema.Text(
202        title = u'Permanent Address',
203        required = False,
204        )
205
206class IStudent(IStudentBase,IStudentClearance,IStudentPersonal):
207    """Representation of a student.
208
209    """
210
211class IStudentUpdateByRegNo(IStudent):
212    """Representation of a student. Skip regular reg_number validation.
213
214    """
215    reg_number = schema.TextLine(
216        title = u'Registration Number',
217        default = None,
218        required = False,
219        )
220
221class IStudentUpdateByMatricNo(IStudent):
222    """Representation of a student. Skip regular matric_number validation.
223
224    """
225    matric_number = schema.TextLine(
226        title = u'Matriculation Number',
227        default = None,
228        required = False,
229        )
230
231class IStudentStudyCourse(IWAeUPObject):
232    """A container for student study levels.
233
234    """
235    certificate = schema.Choice(
236        title = u'Certificate',
237        source = CertificateSource(),
238        default = None,
239        required = False,
240        )
241
242
243    entry_mode = schema.Choice(
244        title = u'Entry Mode',
245        vocabulary = study_modes,
246        default = u'ug_ft',
247        required = True,
248        readonly = False,
249        )
250
251    entry_session = schema.Choice(
252        title = u'Entry Session',
253        source = academic_sessions_vocab,
254        default = datetime.now().year,
255        required = True,
256        readonly = False,
257        )
258
259    current_session = schema.Choice(
260        title = u'Current Session',
261        source = academic_sessions_vocab,
262        default = None,
263        required = True,
264        readonly = False,
265        )
266
267    current_level = schema.Choice(
268        title = u'Current Level',
269        source = StudyLevelSource(),
270        default = None,
271        required = False,
272        readonly = False,
273        )
274
275    current_verdict = schema.Choice(
276        title = u'Current Verdict',
277        source = verdicts,
278        default = '0',
279        required = False,
280        )
281
282    previous_verdict = schema.Choice(
283        title = u'Previous Verdict',
284        source = verdicts,
285        default = '0',
286        required = False,
287        )
288
289class IStudentStudyCourseImport(IStudentStudyCourse):
290    """A container for student study levels.
291
292    """
293    current_level = schema.Int(
294        title = u'Current Level',
295        default = None,
296        )
297
298class IStudentStudyLevel(IWAeUPObject):
299    """A container for course tickets.
300
301    """
302    level = Attribute('The level code')
303    validation_date = Attribute('The date of validation')
304    validated_by = Attribute('User Id of course adviser')
305
306    level_session = schema.Choice(
307        title = u'Session',
308        source = academic_sessions_vocab,
309        default = None,
310        required = True,
311        )
312
313    level_verdict = schema.Choice(
314        title = u'Verdict',
315        source = verdicts,
316        default = '0',
317        required = False,
318        )
319
320class ICourseTicket(IWAeUPObject):
321    """A course ticket.
322
323    """
324    code = Attribute('code of the original course')
325    title = Attribute('title of the original course')
326    credits = Attribute('credits of the original course')
327    passmark = Attribute('passmark of the original course')
328    semester = Attribute('semester of the original course')
329    faculty = Attribute('faculty of the original course')
330    department = Attribute('department of the original course')
331
332    core_or_elective = schema.Bool(
333        title = u'Mandatory',
334        default = False,
335        required = False,
336        readonly = False,
337        )
338
339    score = schema.Int(
340        title = u'Score',
341        default = 0,
342        required = False,
343        readonly = False,
344        )
345
346    automatic = schema.Bool(
347        title = u'Automatical Creation',
348        default = False,
349        required = False,
350        readonly = True,
351        )
352
353class ICourseTicketAdd(ICourseTicket):
354    """An interface for adding course tickets.
355
356    """
357    course = schema.Choice(
358        title = u'Course',
359        source = CourseSource(),
360        readonly = False,
361        )
362
363class IStudentAccommodation(IWAeUPObject):
364    """A container for student accommodation objects.
365
366    """
367
368class IBedTicket(IWAeUPObject):
369    """A ticket for accommodation booking.
370
371    """
372    bed = Attribute('The bed object.')
373
374    bed_coordinates = schema.TextLine(
375        title = u'Bed Coordinates',
376        default = None,
377        required = False,
378        readonly = False,
379        )
380
381    bed_type = schema.TextLine(
382        title = u'Bed Type',
383        default = None,
384        required = False,
385        readonly = False,
386        )
387
388    booking_session = schema.Choice(
389        title = u'Session',
390        source = academic_sessions_vocab,
391        default = None,
392        required = True,
393        readonly = True,
394        )
395
396    booking_date = schema.Datetime(
397        title = u'Booking Date',
398        required = False,
399        readonly = True,
400        )
401
402    booking_code = schema.TextLine(
403        title = u'Booking Activation Code',
404        default = u'',
405        required = False,
406        readonly = True,
407        )
408
409    def getSessionString():
410        """Returns the the title of academic_sessions_vocab term.
411
412        """
413
414class IStudentPaymentsContainer(IPaymentsContainer):
415    """A container for student payment objects.
416
417    """
418
419class IStudentOnlinePayment(IOnlinePayment):
420    """A student payment via payment gateways.
421
422    """
423    p_session = schema.Choice(
424        title = u'Payment Session',
425        source = academic_sessions_vocab,
426        required = False,
427        )
428
429IStudentOnlinePayment['p_session'].order = IStudentOnlinePayment[
430    'p_item'].order
431
432# Interfaces for students only
433
434class IStudentClearanceEdit(IStudentClearance):
435    """Interface needed for restricted editing of student clearance data.
436
437    """
438
439class IStudentPersonalEdit(IStudentPersonal):
440    """Interface needed for restricted editing of student personal data.
441
442    """
Note: See TracBrowser for help on using the repository browser.