source: main/waeup.sirp/branches/uli-studentpw/src/waeup/sirp/students/interfaces.py @ 6726

Last change on this file since 6726 was 6706, checked in by uli, 13 years ago

Check matching of entered passwords via invariant.

  • Property svn:keywords set to Id
File size: 4.6 KB
Line 
1##
2## interfaces.py
3from zope.interface import Interface, Attribute, invariant
4from zope.interface.exceptions import Invalid
5from zope import schema
6from waeup.sirp.interfaces import IWAeUPObject
7from waeup.sirp.students.vocabularies import (
8  year_range, lgas_vocab, CertificateSource, GenderSource,
9  )
10
11class IStudentsContainer(IWAeUPObject):
12    """An students container contains university students.
13
14    """
15
16    def addStudent(student):
17        """Add an IStudent object and subcontainers.
18
19        """
20
21    def archive(id=None):
22        """Create on-dist archive of students.
23
24        If id is `None`, all students are archived.
25
26        If id contains a single id string, only the respective
27        students are archived.
28
29        If id contains a list of id strings all of the respective
30        students types are saved to disk.
31        """
32
33    def clear(id=None, archive=True):
34        """Remove students of type given by 'id'.
35
36        Optionally archive the students.
37
38        If id is `None`, all students are archived.
39
40        If id contains a single id string, only the respective
41        students are archived.
42
43        If id contains a list of id strings all of the respective
44        student types are saved to disk.
45
46        If `archive` is ``False`` none of the archive-handling is done
47        and respective students are simply removed from the
48        database.
49        """
50
51class IStudentNavigation(IWAeUPObject):
52    """Interface needed for student navigation.
53    """
54
55    def getStudent():
56        """Return student object.
57        """
58
59class IStudentPasswordSetting(IWAeUPObject):
60    """Data needed for password setting.
61    """
62    name = schema.TextLine(
63        title = u'Full Name',
64        default = u'Nobody',
65        required = True,
66        )
67
68    password = schema.Password(
69        title = u'New password',
70        required = False,
71        )
72
73    password_repeat = schema.Password(
74        title = u'Retype new password',
75        required = False,
76        )
77
78    @invariant
79    def passwords_match(obj):
80        if obj.password == obj.password_repeat:
81            return
82        raise Invalid('passwords do not match')
83
84class IStudentBase(IWAeUPObject):
85    """Representation of student base data.
86    """
87    history = Attribute('Object history, a list of messages.')
88    state = Attribute('Returns the registration state of a student')
89    password = Attribute('Encrypted password of a student')
90
91    password = schema.Password(
92        title = u'Password',
93        required = False,
94        )
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 = True,
103        )
104
105    name = schema.TextLine(
106        title = u'Full Name',
107        default = u'Nobody',
108        required = True,
109        )
110
111    reg_number = schema.TextLine(
112        title = u'Registration Number',
113        default = u'',
114        required = True,
115        readonly = False,
116        )
117
118class IStudentClearance(IWAeUPObject):
119    """Representation of student clearance data.
120    """
121
122    date_of_birth = schema.Date(
123        title = u'Date of Birth',
124        required = True,
125        )
126
127    clearance_locked = schema.Bool(
128        title = u'Clearance form locked',
129        default = False,
130        )
131
132class IStudentPersonal(IWAeUPObject):
133    """Representation of student personal data.
134    """
135
136    perm_address = schema.Text(
137        title = u'Permanent Address',
138        required = False,
139        )
140
141class IStudent(IStudentBase,IStudentClearance,IStudentPersonal):
142    """Representation of a student.
143    """
144
145class IStudentStudyCourse(IWAeUPObject):
146    """A container for student study levels.
147
148    """
149
150    certificate = schema.Choice(
151        title = u'Certificate',
152        source = CertificateSource(),
153        default = None,
154        required = True,
155        )
156
157class IStudentAccommodation(IWAeUPObject):
158    """A container for student accommodation objects.
159
160    """
161
162class IStudentPayments(IWAeUPObject):
163    """A container for student payment objects.
164
165    """
166
167# Interfaces for students only
168
169class IStudentBaseEdit(IStudentBase):
170    """Interface needed for editing of student base data by students.
171    """
172
173    name = schema.TextLine(
174        title = u'Full Name',
175        default = u'Nobody',
176        required = True,
177        readonly = True,
178        )
179
180IStudentBaseEdit['name'].order =  IStudentBase['name'].order
181
182class IStudentClearanceEdit(IStudentClearance):
183    """Interface needed for restricted editing of student clearance data.
184    """
185
186class IStudentPersonalEdit(IStudentPersonal):
187    """Interface needed for restricted editing of student personal data.
188    """
Note: See TracBrowser for help on using the repository browser.