source: waeup_product/trunk/Students.py @ 168

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

=some fixes

  • Property svn:keywords set to Id
File size: 8.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,'JAMB',None)
69        if data:
70            content = data.getContent()
71            return "%s %s is studying %s" % (content.firstname,content.lastname,content.course)
72        return self.description
73
74    security.declareProtected(View,"setScratchCardData")
75    def setScratchCardData(self,ident,ds):
76        """set this data """
77        dict = {'%s_sc_pin' % ident : ds.get('sc_pin'),
78                '%s_sc_id' % ident : ds.get('sc_id'),
79                '%s_sc_value' % ident : ds.get('sc_value'),
80                '%s_date' % ident : ds.get('sc_date'),
81                }
82               
83        if self.portal_membership.isAnonymousUser():
84            tmp_user = CPSUnrestrictedUser('s%(jamb_id)s' % ds, '',
85                                       ['StudentManager'], '')
86            tmp_user = tmp_user.__of__(self.acl_users)
87            newSecurityManager(None, tmp_user)
88        #print str(dict)
89        self.edit(mapping=dict)
90
91    security.declareProtected(View,"memberIsOwner")
92    def memberIsOwner(self):
93        """is the current user the owner"""
94        member = self.portal_membership.getAuthenticatedMember()
95        #print member, self.getId(),self.aq_parent.getId()
96        if self.aq_parent.getId() == str(member):
97            return True
98        return False
99
100    security.declareProtected(View,"accommodationIsBooked")
101    def accommodationIsBooked(self):
102        """is the accommodation booked"""
103        if self.accommodation_sc_pin != '':
104            return True
105        return False
106
107    security.declareProtected(View,"accommodationIsPayed")
108    def accommodationIsPayed(self):
109        """is the accommodation payed"""
110        if self.hostel_fee_sc_pin != '':
111            return True
112        return False
113
114    security.declareProtected(View,"isRegisteredForCurrentLevel")
115    def isRegisteredForCurrentLevel(self):
116        """is the student registered for the current level"""
117        for l in  self.aq_parent.objectValues():
118            if l.portal_type == 'StudyLevel':
119                return True
120        return False
121
122InitializeClass(Student)
123
124def addStudent(container, id, REQUEST=None, **kw):
125    """Add a Student."""
126    ob = Student(id, **kw)
127    return CPSBase_adder(container, ob, REQUEST=REQUEST)
128
129###)
130
131studentpersonal_fti = { ###(
132    'title': 'WAeUP StudentPersonal',
133    'description': '',
134    'content_icon': 'student.gif',
135    'content_meta_type': 'StudentPersonal',
136    'factory': 'addStudent',
137    'immediate_view': 'student_personal_index_html',
138    'global_allow': True,
139    'filter_content_types': True,
140    'allowed_content_types': (),
141    'allow_discussion': False,
142}
143
144###)
145
146class StudentPersonal(CPSDocument): ###(
147    """
148    WAeUP Student container for the various student data
149    """
150    meta_type = 'StudentPersonal'
151    portal_type = meta_type
152    security = ClassSecurityInfo()
153
154    security.declareProtected(View,"Title")
155    def Title(self):
156        """compose title"""
157        content = self.getContent()
158        return "Personal Data for %s %s" % (content.firstname,content.lastname)
159
160
161InitializeClass(StudentPersonal)
162
163def addStudentPersonal(container, id, REQUEST=None, **kw):
164    """Add a Students personal data."""
165    ob = StudentPersonal(id, **kw)
166    return CPSBase_adder(container, ob, REQUEST=REQUEST)
167
168###)
169
170studentdocuments_fti = { ###(
171    'title': 'WAeUP StudentDocuments',
172    'description': '',
173    'content_icon': 'student.gif',
174    'content_meta_type': 'StudentDocuments',
175    'factory': 'addStudent',
176    'immediate_view': 'temporary_view_all',
177    'global_allow': True,
178    'filter_content_types': True,
179    'allowed_content_types': (),
180    'allow_discussion': False,
181}
182
183###)
184
185class StudentDocuments(CPSDocument): ###(
186    """
187    WAeUP Student container for the various student data
188    """
189    meta_type = 'StudentDocuments'
190    portal_type = meta_type
191    security = ClassSecurityInfo()
192
193    security.declareProtected(View,"Title")
194    def Title(self):
195        """compose title"""
196        content = self.getContent()
197        return "Scanned Documents"
198
199
200InitializeClass(StudentDocuments)
201
202def addStudentDocuments(container, id, REQUEST=None, **kw):
203    """Add a Students documents"""
204    ob = StudentDocuments(id, **kw)
205    return CPSBase_adder(container, ob, REQUEST=REQUEST)
206
207###)
208
209jamb_fti = { ###(
210    'title': 'WAeUP Jamb',
211    'description': '',
212    'content_icon': '',
213    'content_meta_type': 'Jamb',
214    'factory': 'addJamb',
215    'immediate_view': 'cpsdocument_view',
216    'global_allow': True,
217    'filter_content_types': True,
218    'allowed_content_types': ('Course',),
219    'allow_discussion': False,
220}
221###)
222
223class Jamb(CPSDocument): ###(
224    """
225    WAeUP Jamb containing the courses and students
226    """
227    meta_type = 'Jamb'
228    portal_type = meta_type
229    security = ClassSecurityInfo()
230
231    security.declareProtected(View,"Title")
232    def Title(self):
233        """compose title"""
234        content = self.getContent()
235        return "JAMB Data for %s %s" % (content.firstname,content.lastname)
236
237    security.declareProtected(View,"setOwnership")
238    def setOwnership(self,member_id):
239        """set ownership"""
240        pm = getattr(self,'portal_membership')
241        member = pm.getMemberById(member_id)
242        self.changeOwnership(member)
243
244InitializeClass(Jamb)
245
246def addJamb(container, id, REQUEST=None, **kw):
247    """Add a Jamb."""
248    ob = Jamb(id, **kw)
249    return CPSBase_adder(container, ob, REQUEST=REQUEST)
250###)
251
252study_level_fti = { ###(
253    'title': 'WAeUP StudyLevel',
254    'description': '',
255    'content_icon': '',
256    'content_meta_type': 'StudyLevel',
257    'factory': 'addStudyLevel',
258    'immediate_view': 'cpsdocument_view',
259    'global_allow': True,
260    'filter_content_types': True,
261    'allowed_content_types': ('Course',),
262    'allow_discussion': False,
263}
264###)
265
266class StudyLevel(CPSDocument): ###(
267    """
268    WAeUP StudyLevel containing the courses and students
269    """
270    meta_type = 'StudyLevel'
271    portal_type = meta_type
272    security = ClassSecurityInfo()
273
274InitializeClass(StudyLevel)
275
276def addStudyLevel(container, id, REQUEST=None, **kw):
277    """Add a StudyLevel."""
278    ob = StudyLevel(id, **kw)
279    return CPSBase_adder(container, ob, REQUEST=REQUEST)
280###)
281
282semester_fti = { ###(
283    'title': 'WAeUP Semester',
284    'description': '',
285    'content_icon': '',
286    'content_meta_type': 'Semester',
287    'factory': 'addSemester',
288    'immediate_view': 'cpsdocument_view',
289    'global_allow': True,
290    'filter_content_types': True,
291    'allowed_content_types': ('Course',),
292    'allow_discussion': False,
293}
294###)
295
296class Semester(CPSDocument): ###(
297    """
298    WAeUP Semester containing the courses and students
299    """
300    meta_type = 'Semester'
301    portal_type = meta_type
302    security = ClassSecurityInfo()
303
304InitializeClass(Semester)
305
306def addSemester(container, id, REQUEST=None, **kw):
307    """Add a Semester."""
308    ob = Semester(id, **kw)
309    return CPSBase_adder(container, ob, REQUEST=REQUEST)
310###)
311
Note: See TracBrowser for help on using the repository browser.