source: waeup_product/trunk/Students.py @ 178

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

=added Faculties and Departments in install + other cosmetics

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