source: waeup_product/trunk/Students.py @ 171

Last change on this file since 171 was 170, checked in by Henrik Bettermann, 19 years ago

minor modifications

  • Property svn:keywords set to Id
File size: 9.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        if self.portal_membership.isAnonymousUser():
88            tmp_user = CPSUnrestrictedUser('s%(jamb_id)s' % ds, '',
89                                       ['StudentManager'], '')
90            tmp_user = tmp_user.__of__(self.acl_users)
91            newSecurityManager(None, tmp_user)
92        #print str(dict)
93        self.edit(mapping=dict)
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
174studentdocuments_fti = { ###(
175    'title': 'WAeUP StudentDocuments',
176    'description': '',
177    'content_icon': 'student.gif',
178    'content_meta_type': 'StudentDocuments',
179    'factory': 'addStudent',
180    'immediate_view': 'temporary_view_all',
181    'global_allow': True,
182    'filter_content_types': True,
183    'allowed_content_types': (),
184    'allow_discussion': False,
185}
186
187###)
188
189class StudentDocuments(CPSDocument): ###(
190    """
191    WAeUP Student container for the various student data
192    """
193    meta_type = 'StudentDocuments'
194    portal_type = meta_type
195    security = ClassSecurityInfo()
196
197    security.declareProtected(View,"Title")
198    def Title(self):
199        """compose title"""
200        content = self.getContent()
201        return "Scanned Documents"
202
203
204InitializeClass(StudentDocuments)
205
206def addStudentDocuments(container, id, REQUEST=None, **kw):
207    """Add a Students documents"""
208    ob = StudentDocuments(id, **kw)
209    return CPSBase_adder(container, ob, REQUEST=REQUEST)
210
211###)
212
213jamb_fti = { ###(
214    'title': 'WAeUP Jamb',
215    'description': '',
216    'content_icon': '',
217    'content_meta_type': 'Jamb',
218    'factory': 'addJamb',
219    'immediate_view': 'cpsdocument_view',
220    'global_allow': True,
221    'filter_content_types': True,
222    'allowed_content_types': ('Course',),
223    'allow_discussion': False,
224}
225###)
226
227class Jamb(CPSDocument): ###(
228    """
229    WAeUP Jamb containing the courses and students
230    """
231    meta_type = 'Jamb'
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 "JAMB Data for %s %s" % (content.firstname,content.lastname)
240
241    security.declareProtected(View,"setOwnership")
242    def setOwnership(self,member_id):
243        """set ownership"""
244        pm = getattr(self,'portal_membership')
245        member = pm.getMemberById(member_id)
246        self.changeOwnership(member)
247
248InitializeClass(Jamb)
249
250def addJamb(container, id, REQUEST=None, **kw):
251    """Add a Jamb."""
252    ob = Jamb(id, **kw)
253    return CPSBase_adder(container, ob, REQUEST=REQUEST)
254###)
255
256study_level_fti = { ###(
257    'title': 'WAeUP StudyLevel',
258    'description': '',
259    'content_icon': '',
260    'content_meta_type': 'StudyLevel',
261    'factory': 'addStudyLevel',
262    'immediate_view': 'cpsdocument_view',
263    'global_allow': True,
264    'filter_content_types': True,
265    'allowed_content_types': ('Course',),
266    'allow_discussion': False,
267}
268###)
269
270class StudyLevel(CPSDocument): ###(
271    """
272    WAeUP StudyLevel containing the courses and students
273    """
274    meta_type = 'StudyLevel'
275    portal_type = meta_type
276    security = ClassSecurityInfo()
277
278InitializeClass(StudyLevel)
279
280def addStudyLevel(container, id, REQUEST=None, **kw):
281    """Add a StudyLevel."""
282    ob = StudyLevel(id, **kw)
283    return CPSBase_adder(container, ob, REQUEST=REQUEST)
284###)
285
286semester_fti = { ###(
287    'title': 'WAeUP Semester',
288    'description': '',
289    'content_icon': '',
290    'content_meta_type': 'Semester',
291    'factory': 'addSemester',
292    'immediate_view': 'cpsdocument_view',
293    'global_allow': True,
294    'filter_content_types': True,
295    'allowed_content_types': ('Course',),
296    'allow_discussion': False,
297}
298###)
299
300class Semester(CPSDocument): ###(
301    """
302    WAeUP Semester containing the courses and students
303    """
304    meta_type = 'Semester'
305    portal_type = meta_type
306    security = ClassSecurityInfo()
307
308InitializeClass(Semester)
309
310def addSemester(container, id, REQUEST=None, **kw):
311    """Add a Semester."""
312    ob = Semester(id, **kw)
313    return CPSBase_adder(container, ob, REQUEST=REQUEST)
314###)
315
Note: See TracBrowser for help on using the repository browser.