source: waeup_product/trunk/Students.py @ 164

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

=clearence + eligibility added

  • Property svn:keywords set to Id
File size: 7.0 KB
RevLine 
[57]1#-*- mode: python; mode: fold -*-
[45]2from Globals import InitializeClass
3from AccessControl import ClassSecurityInfo
[164]4from AccessControl.SecurityManagement import newSecurityManager
[45]5
[47]6from Products.CMFCore.utils import UniqueObject, getToolByName
[45]7from Products.CMFCore.permissions import View
8from Products.CMFCore.permissions import ModifyPortalContent
[154]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
[164]13from Products.CPSCore.CPSMembershipTool import CPSUnrestrictedUser
[57]14class StudentsFolder(BaseBTreeFolder): ###(
[45]15    """
[154]16    WAeUP container for the various WAeUP containers data
[45]17    """
18    meta_type = 'Students Folder'
19    portal_type = meta_type
20    security = ClassSecurityInfo()
[154]21
22
[45]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)
[57]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    """
[154]48    WAeUP Student container for the various student data
[57]49    """
50    meta_type = 'Student'
51    portal_type = meta_type
52    security = ClassSecurityInfo()
[154]53
[152]54    security.declareProtected(View,"Title")
55    def Title(self):
56        """compose title"""
[153]57        reg_nr = self.getId()[1:]
[152]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
[154]65
66    def Description(self):
67        """compose description"""
68        data = getattr(self,'JAMB',None)
69        if data:
70            content = data.getContent()
[156]71            return "%s %s is studying %s" % (content.firstname,content.lastname,content.course)
[154]72        return self.description
73
[164]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                }
81        tmp_user = CPSUnrestrictedUser('pseudo', '',
82                                       ['StudentManager'], '')
83        tmp_user = tmp_user.__of__(self.acl_users)
84        newSecurityManager(None, tmp_user)
85        self.edit(mapping=dict)
86
87    security.declareProtected(View,"memberIsOwner")
88    def memberIsOwner(self):
89        """is the current user the owner"""
90        member = self.portal_membership.getAuthenticatedMember()
91        #print member, self.getId(),self.aq_parent.getId()
92        if self.aq_parent.getId() == str(member):
93            return True
94        return False
95
[57]96InitializeClass(Student)
97
98def addStudent(container, id, REQUEST=None, **kw):
99    """Add a Student."""
100    ob = Student(id, **kw)
101    return CPSBase_adder(container, ob, REQUEST=REQUEST)
102
103###)
[91]104
[89]105studentpersonal_fti = { ###(
106    'title': 'WAeUP StudentPersonal',
107    'description': '',
108    'content_icon': 'student.gif',
109    'content_meta_type': 'StudentPersonal',
110    'factory': 'addStudent',
111    'immediate_view': 'student_personal_index_html',
112    'global_allow': True,
113    'filter_content_types': True,
114    'allowed_content_types': (),
115    'allow_discussion': False,
116}
117
118###)
119
120class StudentPersonal(CPSDocument): ###(
121    """
[154]122    WAeUP Student container for the various student data
[89]123    """
124    meta_type = 'StudentPersonal'
125    portal_type = meta_type
126    security = ClassSecurityInfo()
[152]127
128    security.declareProtected(View,"Title")
129    def Title(self):
130        """compose title"""
131        content = self.getContent()
132        return "Personal Data for %s %s" % (content.firstname,content.lastname)
133
[154]134
[89]135InitializeClass(StudentPersonal)
136
137def addStudentPersonal(container, id, REQUEST=None, **kw):
138    """Add a Students personal data."""
139    ob = StudentPersonal(id, **kw)
140    return CPSBase_adder(container, ob, REQUEST=REQUEST)
141
142###)
143
144jamb_fti = { ###(
145    'title': 'WAeUP Jamb',
146    'description': '',
147    'content_icon': '',
148    'content_meta_type': 'Jamb',
149    'factory': 'addJamb',
150    'immediate_view': 'cpsdocument_view',
151    'global_allow': True,
152    'filter_content_types': True,
153    'allowed_content_types': ('Course',),
154    'allow_discussion': False,
155}
156###)
157
158class Jamb(CPSDocument): ###(
159    """
160    WAeUP Jamb containing the courses and students
161    """
162    meta_type = 'Jamb'
163    portal_type = meta_type
164    security = ClassSecurityInfo()
[154]165
[152]166    security.declareProtected(View,"Title")
167    def Title(self):
168        """compose title"""
169        content = self.getContent()
170        return "JAMB Data for %s %s" % (content.firstname,content.lastname)
171
172    security.declareProtected(View,"setOwnership")
173    def setOwnership(self,member_id):
174        """set ownership"""
175        pm = getattr(self,'portal_membership')
176        member = pm.getMemberById(member_id)
177        self.changeOwnership(member)
178
[89]179InitializeClass(Jamb)
180
181def addJamb(container, id, REQUEST=None, **kw):
182    """Add a Jamb."""
183    ob = Jamb(id, **kw)
184    return CPSBase_adder(container, ob, REQUEST=REQUEST)
185###)
186
[139]187study_level_fti = { ###(
188    'title': 'WAeUP StudyLevel',
189    'description': '',
190    'content_icon': '',
191    'content_meta_type': 'StudyLevel',
192    'factory': 'addStudyLevel',
193    'immediate_view': 'cpsdocument_view',
194    'global_allow': True,
195    'filter_content_types': True,
196    'allowed_content_types': ('Course',),
197    'allow_discussion': False,
198}
199###)
200
201class StudyLevel(CPSDocument): ###(
202    """
203    WAeUP StudyLevel containing the courses and students
204    """
205    meta_type = 'StudyLevel'
206    portal_type = meta_type
207    security = ClassSecurityInfo()
[154]208
[139]209InitializeClass(StudyLevel)
210
211def addStudyLevel(container, id, REQUEST=None, **kw):
212    """Add a StudyLevel."""
213    ob = StudyLevel(id, **kw)
214    return CPSBase_adder(container, ob, REQUEST=REQUEST)
215###)
216
217semester_fti = { ###(
218    'title': 'WAeUP Semester',
219    'description': '',
220    'content_icon': '',
221    'content_meta_type': 'Semester',
222    'factory': 'addSemester',
223    'immediate_view': 'cpsdocument_view',
224    'global_allow': True,
225    'filter_content_types': True,
226    'allowed_content_types': ('Course',),
227    'allow_discussion': False,
228}
229###)
230
231class Semester(CPSDocument): ###(
232    """
233    WAeUP Semester containing the courses and students
234    """
235    meta_type = 'Semester'
236    portal_type = meta_type
237    security = ClassSecurityInfo()
[154]238
[139]239InitializeClass(Semester)
240
241def addSemester(container, id, REQUEST=None, **kw):
242    """Add a Semester."""
243    ob = Semester(id, **kw)
244    return CPSBase_adder(container, ob, REQUEST=REQUEST)
245###)
246
Note: See TracBrowser for help on using the repository browser.