source: waeup_product/trunk/Students.py @ 179

Last change on this file since 179 was 179, checked in by joachim, 19 years ago

=post-primary results adding

  • Property svn:keywords set to Id
File size: 10.0 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        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
128InitializeClass(Student)
129
130def 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
137studentpersonal_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
152class 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
167InitializeClass(StudentPersonal)
168
169def 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
176studenteligibility_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
191class 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
200InitializeClass(StudentEligibility)
201
202def addStudentEligibility(container, id, REQUEST=None, **kw):
203    """Add a Students eligibility data."""
204    ob = StudentEligibility(id, **kw)
205    return CPSBase_adder(container, ob, REQUEST=REQUEST)
206
207###)
208 
209studentdocuments_fti = { ###(
210    'title': 'WAeUP StudentDocuments',
211    'description': '',
212    'content_icon': 'student.gif',
213    'content_meta_type': 'StudentDocuments',
214    'factory': 'addStudent',
215    'immediate_view': 'temporary_view_all',
216    'global_allow': True,
217    'filter_content_types': True,
218    'allowed_content_types': (),
219    'allow_discussion': False,
220}
221
222###)
223
224class StudentDocuments(CPSDocument): ###(
225    """
226    WAeUP Student container for the various student data
227    """
228    meta_type = 'StudentDocuments'
229    portal_type = meta_type
230    security = ClassSecurityInfo()
231
232    security.declareProtected(View,"Title")
233    def Title(self):
234        """compose title"""
235        content = self.getContent()
236        return "Scanned Documents"
237
238
239InitializeClass(StudentDocuments)
240
241def addStudentDocuments(container, id, REQUEST=None, **kw):
242    """Add a Students documents"""
243    ob = StudentDocuments(id, **kw)
244    return CPSBase_adder(container, ob, REQUEST=REQUEST)
245
246###)
247
248jamb_fti = { ###(
249    'title': 'WAeUP Jamb',
250    'description': '',
251    'content_icon': '',
252    'content_meta_type': 'Jamb',
253    'factory': 'addJamb',
254    'immediate_view': 'cpsdocument_view',
255    'global_allow': True,
256    'filter_content_types': True,
257    'allowed_content_types': ('Course',),
258    'allow_discussion': False,
259}
260###)
261
262class Jamb(CPSDocument): ###(
263    """
264    WAeUP Jamb containing the courses and students
265    """
266    meta_type = 'Jamb'
267    portal_type = meta_type
268    security = ClassSecurityInfo()
269
270    security.declareProtected(View,"Title")
271    def Title(self):
272        """compose title"""
273        content = self.getContent()
274        return "JAMB Data for %s %s" % (content.firstname,content.lastname)
275
276    security.declareProtected(View,"setOwnership")
277    def setOwnership(self,member_id):
278        """set ownership"""
279        pm = getattr(self,'portal_membership')
280        member = pm.getMemberById(member_id)
281        self.changeOwnership(member)
282
283InitializeClass(Jamb)
284
285def addJamb(container, id, REQUEST=None, **kw):
286    """Add a Jamb."""
287    ob = Jamb(id, **kw)
288    return CPSBase_adder(container, ob, REQUEST=REQUEST)
289###)
290
291study_level_fti = { ###(
292    'title': 'WAeUP StudyLevel',
293    'description': '',
294    'content_icon': '',
295    'content_meta_type': 'StudyLevel',
296    'factory': 'addStudyLevel',
297    'immediate_view': 'cpsdocument_view',
298    'global_allow': True,
299    'filter_content_types': True,
300    'allowed_content_types': ('Course',),
301    'allow_discussion': False,
302}
303###)
304
305class StudyLevel(CPSDocument): ###(
306    """
307    WAeUP StudyLevel containing the courses and students
308    """
309    meta_type = 'StudyLevel'
310    portal_type = meta_type
311    security = ClassSecurityInfo()
312
313InitializeClass(StudyLevel)
314
315def addStudyLevel(container, id, REQUEST=None, **kw):
316    """Add a StudyLevel."""
317    ob = StudyLevel(id, **kw)
318    return CPSBase_adder(container, ob, REQUEST=REQUEST)
319###)
320
321semester_fti = { ###(
322    'title': 'WAeUP Semester',
323    'description': '',
324    'content_icon': '',
325    'content_meta_type': 'Semester',
326    'factory': 'addSemester',
327    'immediate_view': 'cpsdocument_view',
328    'global_allow': True,
329    'filter_content_types': True,
330    'allowed_content_types': ('Course',),
331    'allow_discussion': False,
332}
333###)
334
335class Semester(CPSDocument): ###(
336    """
337    WAeUP Semester containing the courses and students
338    """
339    meta_type = 'Semester'
340    portal_type = meta_type
341    security = ClassSecurityInfo()
342
343InitializeClass(Semester)
344
345def addSemester(container, id, REQUEST=None, **kw):
346    """Add a Semester."""
347    ob = Semester(id, **kw)
348    return CPSBase_adder(container, ob, REQUEST=REQUEST)
349###)
350
Note: See TracBrowser for help on using the repository browser.