1 | #-*- mode: python; mode: fold -*- |
---|
2 | from Globals import InitializeClass |
---|
3 | from AccessControl import ClassSecurityInfo |
---|
4 | from AccessControl.SecurityManagement import newSecurityManager |
---|
5 | |
---|
6 | from Products.CMFCore.utils import UniqueObject, getToolByName |
---|
7 | from Products.CMFCore.permissions import View |
---|
8 | from Products.CMFCore.permissions import ModifyPortalContent |
---|
9 | from Products.CPSCore.CPSBase import CPSBase_adder, CPSBaseFolder |
---|
10 | #from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument |
---|
11 | from Products.CPSDocument.CPSDocument import CPSDocument |
---|
12 | from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder |
---|
13 | from Products.CPSCore.CPSMembershipTool import CPSUnrestrictedUser |
---|
14 | class StudentsFolder(BaseBTreeFolder): ###( |
---|
15 | """ |
---|
16 | WAeUP container for the various WAeUP containers data |
---|
17 | """ |
---|
18 | meta_type = 'Students Folder' |
---|
19 | portal_type = meta_type |
---|
20 | security = ClassSecurityInfo() |
---|
21 | |
---|
22 | |
---|
23 | InitializeClass(StudentsFolder) |
---|
24 | |
---|
25 | def addStudentsFolder(container, id, REQUEST=None, **kw): |
---|
26 | """Add a Student.""" |
---|
27 | ob = StudentsFolder(id, **kw) |
---|
28 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
29 | ###) |
---|
30 | |
---|
31 | student_fti = { ###( |
---|
32 | 'title': 'WAeUP Student', |
---|
33 | 'description': '', |
---|
34 | 'content_icon': 'student.gif', |
---|
35 | 'content_meta_type': 'Student', |
---|
36 | 'factory': 'addStudent', |
---|
37 | 'immediate_view': 'cpsdocument_view', |
---|
38 | 'global_allow': True, |
---|
39 | 'filter_content_types': True, |
---|
40 | 'allowed_content_types': ('Jamb','StudentPersonal'), |
---|
41 | 'allow_discussion': False, |
---|
42 | } |
---|
43 | |
---|
44 | ###) |
---|
45 | |
---|
46 | class Student(CPSDocument): ###( |
---|
47 | """ |
---|
48 | WAeUP Student container for the various student data |
---|
49 | """ |
---|
50 | meta_type = 'Student' |
---|
51 | portal_type = meta_type |
---|
52 | security = ClassSecurityInfo() |
---|
53 | |
---|
54 | security.declareProtected(View,"Title") |
---|
55 | def Title(self): |
---|
56 | """compose title""" |
---|
57 | reg_nr = self.getId()[1:] |
---|
58 | data = getattr(self,'PERSONAL',None) |
---|
59 | if data is None: |
---|
60 | data = getattr(self,'JAMB',None) |
---|
61 | if data: |
---|
62 | content = data.getContent() |
---|
63 | return "%s %s" % (content.firstname,content.lastname) |
---|
64 | return self.title |
---|
65 | |
---|
66 | def Description(self): |
---|
67 | """compose description""" |
---|
68 | data = getattr(self,'PERSONAL',None) |
---|
69 | data_jamb = getattr(self,'JAMB',None) |
---|
70 | if data is None: |
---|
71 | data = data_jamb |
---|
72 | if data: |
---|
73 | content_data = data.getContent() |
---|
74 | content_jamb = data_jamb.getContent() |
---|
75 | return "%s %s is studying %s" % (content_data.firstname,content_data.lastname,content_jamb.course) |
---|
76 | return self.description |
---|
77 | |
---|
78 | security.declareProtected(View,"setScratchCardData") |
---|
79 | def setScratchCardData(self,ident,ds): |
---|
80 | """set this data """ |
---|
81 | dict = {'%s_sc_pin' % ident : ds.get('sc_pin'), |
---|
82 | '%s_sc_id' % ident : ds.get('sc_id'), |
---|
83 | '%s_sc_value' % ident : ds.get('sc_value'), |
---|
84 | '%s_date' % ident : ds.get('sc_date'), |
---|
85 | } |
---|
86 | |
---|
87 | old_user = self.portal_membership.getAuthenticatedMember() |
---|
88 | if self.portal_membership.isAnonymousUser(): |
---|
89 | tmp_user = CPSUnrestrictedUser('s%(jamb_id)s' % ds, '', |
---|
90 | ['StudentManager'], '') |
---|
91 | tmp_user = tmp_user.__of__(self.acl_users) |
---|
92 | newSecurityManager(None, tmp_user) |
---|
93 | #print str(dict) |
---|
94 | self.edit(mapping=dict) |
---|
95 | newSecurityManager(None, old_user) |
---|
96 | |
---|
97 | security.declareProtected(View,"memberIsOwner") |
---|
98 | def memberIsOwner(self): |
---|
99 | """is the current user the owner""" |
---|
100 | member = self.portal_membership.getAuthenticatedMember() |
---|
101 | #print member, self.getId(),self.aq_parent.getId() |
---|
102 | if self.aq_parent.getId() == str(member): |
---|
103 | return True |
---|
104 | return False |
---|
105 | |
---|
106 | security.declareProtected(View,"accommodationIsBooked") |
---|
107 | def accommodationIsBooked(self): |
---|
108 | """is the accommodation booked""" |
---|
109 | if self.accommodation_sc_pin != '': |
---|
110 | return True |
---|
111 | return False |
---|
112 | |
---|
113 | security.declareProtected(View,"accommodationIsPayed") |
---|
114 | def accommodationIsPayed(self): |
---|
115 | """is the accommodation payed""" |
---|
116 | if self.hostel_fee_sc_pin != '': |
---|
117 | return True |
---|
118 | return False |
---|
119 | |
---|
120 | security.declareProtected(View,"isRegisteredForCurrentLevel") |
---|
121 | def isRegisteredForCurrentLevel(self): |
---|
122 | """is the student registered for the current level""" |
---|
123 | for l in self.aq_parent.objectValues(): |
---|
124 | if l.portal_type == 'StudyLevel': |
---|
125 | return True |
---|
126 | return False |
---|
127 | |
---|
128 | InitializeClass(Student) |
---|
129 | |
---|
130 | def addStudent(container, id, REQUEST=None, **kw): |
---|
131 | """Add a Student.""" |
---|
132 | ob = Student(id, **kw) |
---|
133 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
134 | |
---|
135 | ###) |
---|
136 | |
---|
137 | studentpersonal_fti = { ###( |
---|
138 | 'title': 'WAeUP StudentPersonal', |
---|
139 | 'description': '', |
---|
140 | 'content_icon': 'student.gif', |
---|
141 | 'content_meta_type': 'StudentPersonal', |
---|
142 | 'factory': 'addStudent', |
---|
143 | 'immediate_view': 'student_personal_index_html', |
---|
144 | 'global_allow': True, |
---|
145 | 'filter_content_types': True, |
---|
146 | 'allowed_content_types': (), |
---|
147 | 'allow_discussion': False, |
---|
148 | } |
---|
149 | |
---|
150 | ###) |
---|
151 | |
---|
152 | class StudentPersonal(CPSDocument): ###( |
---|
153 | """ |
---|
154 | WAeUP Student container for the various student data |
---|
155 | """ |
---|
156 | meta_type = 'StudentPersonal' |
---|
157 | portal_type = meta_type |
---|
158 | security = ClassSecurityInfo() |
---|
159 | |
---|
160 | security.declareProtected(View,"Title") |
---|
161 | def Title(self): |
---|
162 | """compose title""" |
---|
163 | content = self.getContent() |
---|
164 | return "Personal Data for %s %s" % (content.firstname,content.lastname) |
---|
165 | |
---|
166 | |
---|
167 | InitializeClass(StudentPersonal) |
---|
168 | |
---|
169 | def addStudentPersonal(container, id, REQUEST=None, **kw): |
---|
170 | """Add a Students personal data.""" |
---|
171 | ob = StudentPersonal(id, **kw) |
---|
172 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
173 | |
---|
174 | ###) |
---|
175 | |
---|
176 | studenteligibility_fti = { ###( |
---|
177 | 'title': 'WAeUP StudentEligibility', |
---|
178 | 'description': '', |
---|
179 | 'content_icon': 'student.gif', |
---|
180 | 'content_meta_type': 'StudentEligibility', |
---|
181 | 'factory': 'addStudent', |
---|
182 | 'immediate_view': 'student_eligibility_index_html', |
---|
183 | 'global_allow': True, |
---|
184 | 'filter_content_types': True, |
---|
185 | 'allowed_content_types': (), |
---|
186 | 'allow_discussion': False, |
---|
187 | } |
---|
188 | |
---|
189 | ###) |
---|
190 | |
---|
191 | class StudentEligibility(CPSDocument): ###( |
---|
192 | """ |
---|
193 | WAeUP Student container for the various student data |
---|
194 | """ |
---|
195 | meta_type = 'StudentEligibility' |
---|
196 | portal_type = meta_type |
---|
197 | security = ClassSecurityInfo() |
---|
198 | |
---|
199 | security.declareProtected(View,"Title") |
---|
200 | def Title(self): |
---|
201 | """compose title""" |
---|
202 | return "Eligibility Data" |
---|
203 | |
---|
204 | |
---|
205 | InitializeClass(StudentEligibility) |
---|
206 | |
---|
207 | def addStudentEligibility(container, id, REQUEST=None, **kw): |
---|
208 | """Add a Students eligibility data.""" |
---|
209 | ob = StudentEligibility(id, **kw) |
---|
210 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
211 | |
---|
212 | ###) |
---|
213 | |
---|
214 | studentdocuments_fti = { ###( |
---|
215 | 'title': 'WAeUP StudentDocuments', |
---|
216 | 'description': '', |
---|
217 | 'content_icon': 'student.gif', |
---|
218 | 'content_meta_type': 'StudentDocuments', |
---|
219 | 'factory': 'addStudent', |
---|
220 | 'immediate_view': 'temporary_view_all', |
---|
221 | 'global_allow': True, |
---|
222 | 'filter_content_types': True, |
---|
223 | 'allowed_content_types': (), |
---|
224 | 'allow_discussion': False, |
---|
225 | } |
---|
226 | |
---|
227 | ###) |
---|
228 | |
---|
229 | class StudentDocuments(CPSDocument): ###( |
---|
230 | """ |
---|
231 | WAeUP Student container for the various student data |
---|
232 | """ |
---|
233 | meta_type = 'StudentDocuments' |
---|
234 | portal_type = meta_type |
---|
235 | security = ClassSecurityInfo() |
---|
236 | |
---|
237 | security.declareProtected(View,"Title") |
---|
238 | def Title(self): |
---|
239 | """compose title""" |
---|
240 | content = self.getContent() |
---|
241 | return "Scanned Documents" |
---|
242 | |
---|
243 | |
---|
244 | InitializeClass(StudentDocuments) |
---|
245 | |
---|
246 | def addStudentDocuments(container, id, REQUEST=None, **kw): |
---|
247 | """Add a Students documents""" |
---|
248 | ob = StudentDocuments(id, **kw) |
---|
249 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
250 | |
---|
251 | ###) |
---|
252 | |
---|
253 | jamb_fti = { ###( |
---|
254 | 'title': 'WAeUP Jamb', |
---|
255 | 'description': '', |
---|
256 | 'content_icon': '', |
---|
257 | 'content_meta_type': 'Jamb', |
---|
258 | 'factory': 'addJamb', |
---|
259 | 'immediate_view': 'cpsdocument_view', |
---|
260 | 'global_allow': True, |
---|
261 | 'filter_content_types': True, |
---|
262 | 'allowed_content_types': ('Course',), |
---|
263 | 'allow_discussion': False, |
---|
264 | } |
---|
265 | ###) |
---|
266 | |
---|
267 | class Jamb(CPSDocument): ###( |
---|
268 | """ |
---|
269 | WAeUP Jamb containing the courses and students |
---|
270 | """ |
---|
271 | meta_type = 'Jamb' |
---|
272 | portal_type = meta_type |
---|
273 | security = ClassSecurityInfo() |
---|
274 | |
---|
275 | security.declareProtected(View,"Title") |
---|
276 | def Title(self): |
---|
277 | """compose title""" |
---|
278 | content = self.getContent() |
---|
279 | return "JAMB Data for %s %s" % (content.firstname,content.lastname) |
---|
280 | |
---|
281 | security.declareProtected(View,"setOwnership") |
---|
282 | def setOwnership(self,member_id): |
---|
283 | """set ownership""" |
---|
284 | pm = getattr(self,'portal_membership') |
---|
285 | member = pm.getMemberById(member_id) |
---|
286 | self.changeOwnership(member) |
---|
287 | |
---|
288 | InitializeClass(Jamb) |
---|
289 | |
---|
290 | def addJamb(container, id, REQUEST=None, **kw): |
---|
291 | """Add a Jamb.""" |
---|
292 | ob = Jamb(id, **kw) |
---|
293 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
294 | ###) |
---|
295 | |
---|
296 | study_level_fti = { ###( |
---|
297 | 'title': 'WAeUP StudyLevel', |
---|
298 | 'description': '', |
---|
299 | 'content_icon': '', |
---|
300 | 'content_meta_type': 'StudyLevel', |
---|
301 | 'factory': 'addStudyLevel', |
---|
302 | 'immediate_view': 'cpsdocument_view', |
---|
303 | 'global_allow': True, |
---|
304 | 'filter_content_types': True, |
---|
305 | 'allowed_content_types': ('Course',), |
---|
306 | 'allow_discussion': False, |
---|
307 | } |
---|
308 | ###) |
---|
309 | |
---|
310 | class StudyLevel(CPSDocument): ###( |
---|
311 | """ |
---|
312 | WAeUP StudyLevel containing the courses and students |
---|
313 | """ |
---|
314 | meta_type = 'StudyLevel' |
---|
315 | portal_type = meta_type |
---|
316 | security = ClassSecurityInfo() |
---|
317 | |
---|
318 | InitializeClass(StudyLevel) |
---|
319 | |
---|
320 | def addStudyLevel(container, id, REQUEST=None, **kw): |
---|
321 | """Add a StudyLevel.""" |
---|
322 | ob = StudyLevel(id, **kw) |
---|
323 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
324 | ###) |
---|
325 | |
---|
326 | semester_fti = { ###( |
---|
327 | 'title': 'WAeUP Semester', |
---|
328 | 'description': '', |
---|
329 | 'content_icon': '', |
---|
330 | 'content_meta_type': 'Semester', |
---|
331 | 'factory': 'addSemester', |
---|
332 | 'immediate_view': 'cpsdocument_view', |
---|
333 | 'global_allow': True, |
---|
334 | 'filter_content_types': True, |
---|
335 | 'allowed_content_types': ('Course',), |
---|
336 | 'allow_discussion': False, |
---|
337 | } |
---|
338 | ###) |
---|
339 | |
---|
340 | class Semester(CPSDocument): ###( |
---|
341 | """ |
---|
342 | WAeUP Semester containing the courses and students |
---|
343 | """ |
---|
344 | meta_type = 'Semester' |
---|
345 | portal_type = meta_type |
---|
346 | security = ClassSecurityInfo() |
---|
347 | |
---|
348 | InitializeClass(Semester) |
---|
349 | |
---|
350 | def addSemester(container, id, REQUEST=None, **kw): |
---|
351 | """Add a Semester.""" |
---|
352 | ob = Semester(id, **kw) |
---|
353 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
354 | ###) |
---|
355 | |
---|