source: WAeUP_SRP/branches/srpp_branch/Students.py @ 3943

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