source: WAeUP_SRP/trunk/Students.py @ 348

Last change on this file since 348 was 200, checked in by joachim, 18 years ago

=removed files not necessary

  • Property svn:keywords set to Id
File size: 7.5 KB
Line 
1#-*- mode: python; mode: fold -*-
2# $Id: Students.py 200 2006-05-10 06:58:10Z joachim $
3from Globals import InitializeClass
4from AccessControl import ClassSecurityInfo
5from AccessControl.SecurityManagement import newSecurityManager
6
7from Products.CMFCore.utils import UniqueObject, getToolByName
8from Products.CMFCore.permissions import View
9from Products.CMFCore.permissions import ModifyPortalContent
10from Products.CPSCore.CPSBase import CPSBase_adder, CPSBaseFolder
11#from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument
12from Products.CPSDocument.CPSDocument import CPSDocument
13from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder
14from Products.CPSCore.CPSMembershipTool import CPSUnrestrictedUser
15##class StudentsFolder(BaseBTreeFolder): ###(
16##    """
17##    WAeUP container for the various WAeUP containers data
18##    """
19##    meta_type = 'Students Folder'
20##    portal_type = meta_type
21##    security = ClassSecurityInfo()
22##
23##
24##InitializeClass(StudentsFolder)
25
26##def addStudentsFolder(container, id, REQUEST=None, **kw):
27##    """Add a Student."""
28##    ob = StudentsFolder(id, **kw)
29##    return CPSBase_adder(container, ob, REQUEST=REQUEST)
30#####)
31
32class Student(CPSDocument): ###(
33    """
34    WAeUP Student container for the various student data
35    """
36    meta_type = 'Student'
37    portal_type = meta_type
38    security = ClassSecurityInfo()
39
40    security.declareProtected(View,"Title")
41    def Title(self):
42        """compose title"""
43        reg_nr = self.getId()[1:]
44        data = getattr(self,'PERSONAL',None)
45        if data is None:
46            data = getattr(self,'JAMB',None)
47        if data:
48            content = data.getContent()
49            return "%s %s" % (content.firstname,content.lastname)
50        return self.title
51
52    def Description(self):
53        """compose description"""
54        data = getattr(self,'PERSONAL',None)
55        if data is None:
56            return "none"
57        if data:
58            content = data.getContent()
59            return "%s" % (content.description)
60        return self.description
61
62    security.declareProtected(View,"setScratchCardData")
63    def setScratchCardData(self,ident,ds):
64        """set this data """
65        dict = {'%s_sc_pin' % ident : ds.get('sc_pin'),
66                '%s_sc_id' % ident : ds.get('sc_id'),
67                '%s_sc_value' % ident : ds.get('sc_value'),
68                '%s_date' % ident : ds.get('sc_date'),
69                }
70
71        old_user = self.portal_membership.getAuthenticatedMember()
72        if self.portal_membership.isAnonymousUser():
73            tmp_user = CPSUnrestrictedUser('s%(jamb_id)s' % ds, '',
74                                       ['StudentManager'], '')
75            tmp_user = tmp_user.__of__(self.acl_users)
76            newSecurityManager(None, tmp_user)
77        #print str(dict)
78        self.edit(mapping=dict)
79        newSecurityManager(None, old_user)
80
81    security.declareProtected(View,"memberIsOwner")
82    def memberIsOwner(self):
83        """is the current user the owner"""
84        member = self.portal_membership.getAuthenticatedMember()
85        #print member, self.getId(),self.aq_parent.getId()
86        if self.aq_parent.getId() == str(member):
87            return True
88        return False
89
90    security.declareProtected(View,"accommodationIsBooked")
91    def accommodationIsBooked(self):
92        """is the accommodation booked"""
93        if self.accommodation_sc_pin != '':
94            return True
95        return False
96
97    security.declareProtected(View,"accommodationIsPayed")
98    def accommodationIsPayed(self):
99        """is the accommodation payed"""
100        if self.hostel_fee_sc_pin != '':
101            return True
102        return False
103
104    security.declareProtected(View,"isRegisteredForCurrentLevel")
105    def isRegisteredForCurrentLevel(self):
106        """is the student registered for the current level"""
107        for l in  self.aq_parent.objectValues():
108            if l.portal_type == 'StudyLevel':
109                return True
110        return False
111
112InitializeClass(Student)
113
114def addStudent(container, id, REQUEST=None, **kw):
115    """Add a Student."""
116    ob = Student(id, **kw)
117    return CPSBase_adder(container, ob, REQUEST=REQUEST)
118
119###)
120
121class StudentPersonal(CPSDocument): ###(
122    """
123    WAeUP Student container for the various student data
124    """
125    meta_type = 'StudentPersonal'
126    portal_type = meta_type
127    security = ClassSecurityInfo()
128
129    security.declareProtected(View,"Title")
130    def Title(self):
131        """compose title"""
132        content = self.getContent()
133        return "Personal Data for %s %s" % (content.firstname,content.lastname)
134
135
136InitializeClass(StudentPersonal)
137
138def addStudentPersonal(container, id, REQUEST=None, **kw):
139    """Add a Students personal data."""
140    ob = StudentPersonal(id, **kw)
141    return CPSBase_adder(container, ob, REQUEST=REQUEST)
142
143###)
144
145class StudentEligibility(CPSDocument): ###(
146    """
147    WAeUP Student container for the various student data
148    """
149    meta_type = 'StudentEligibility'
150    portal_type = meta_type
151    security = ClassSecurityInfo()
152
153    security.declareProtected(View,"Title")
154    def Title(self):
155        """compose title"""
156        return "Eligibility Data"
157
158
159InitializeClass(StudentEligibility)
160
161def addStudentEligibility(container, id, REQUEST=None, **kw):
162    """Add a Students eligibility data."""
163    ob = StudentEligibility(id, **kw)
164    return CPSBase_adder(container, ob, REQUEST=REQUEST)
165
166###)
167
168class StudentDocuments(CPSDocument): ###(
169    """
170    WAeUP Student container for the various student data
171    """
172    meta_type = 'StudentDocuments'
173    portal_type = meta_type
174    security = ClassSecurityInfo()
175
176    security.declareProtected(View,"Title")
177    def Title(self):
178        """compose title"""
179        content = self.getContent()
180        return "Scanned Documents"
181
182
183InitializeClass(StudentDocuments)
184
185def addStudentDocuments(container, id, REQUEST=None, **kw):
186    """Add a Students documents"""
187    ob = StudentDocuments(id, **kw)
188    return CPSBase_adder(container, ob, REQUEST=REQUEST)
189
190###)
191
192class Jamb(CPSDocument): ###(
193    """
194    WAeUP Jamb containing the courses and students
195    """
196    meta_type = 'Jamb'
197    portal_type = meta_type
198    security = ClassSecurityInfo()
199
200    security.declareProtected(View,"Title")
201    def Title(self):
202        """compose title"""
203        content = self.getContent()
204        return "JAMB Data for %s %s" % (content.firstname,content.lastname)
205
206    security.declareProtected(View,"setOwnership")
207    def setOwnership(self,member_id):
208        """set ownership"""
209        pm = getattr(self,'portal_membership')
210        member = pm.getMemberById(member_id)
211        self.changeOwnership(member)
212
213InitializeClass(Jamb)
214
215def addJamb(container, id, REQUEST=None, **kw):
216    """Add a Jamb."""
217    ob = Jamb(id, **kw)
218    return CPSBase_adder(container, ob, REQUEST=REQUEST)
219
220###)
221
222class StudyLevel(CPSDocument): ###(
223    """
224    WAeUP StudyLevel containing the courses and students
225    """
226    meta_type = 'StudyLevel'
227    portal_type = meta_type
228    security = ClassSecurityInfo()
229
230InitializeClass(StudyLevel)
231
232def addStudyLevel(container, id, REQUEST=None, **kw):
233    """Add a StudyLevel."""
234    ob = StudyLevel(id, **kw)
235    return CPSBase_adder(container, ob, REQUEST=REQUEST)
236
237###)
238
239class Semester(CPSDocument): ###(
240    """
241    WAeUP Semester containing the courses and students
242    """
243    meta_type = 'Semester'
244    portal_type = meta_type
245    security = ClassSecurityInfo()
246
247InitializeClass(Semester)
248
249def addSemester(container, id, REQUEST=None, **kw):
250    """Add a Semester."""
251    ob = Semester(id, **kw)
252    return CPSBase_adder(container, ob, REQUEST=REQUEST)
253
254###)
255
Note: See TracBrowser for help on using the repository browser.