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