source: waeup_product/trunk/Students.py @ 215

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

=removed files not necessary

  • Property svn:keywords set to Id
File size: 7.5 KB
RevLine 
[57]1#-*- mode: python; mode: fold -*-
[200]2# $Id: Students.py 200 2006-05-10 06:58:10Z joachim $
[45]3from Globals import InitializeClass
4from AccessControl import ClassSecurityInfo
[164]5from AccessControl.SecurityManagement import newSecurityManager
[45]6
[47]7from Products.CMFCore.utils import UniqueObject, getToolByName
[45]8from Products.CMFCore.permissions import View
9from Products.CMFCore.permissions import ModifyPortalContent
[154]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
[164]14from Products.CPSCore.CPSMembershipTool import CPSUnrestrictedUser
[200]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)
[154]25
[200]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#####)
[154]31
[57]32class Student(CPSDocument): ###(
33    """
[154]34    WAeUP Student container for the various student data
[57]35    """
36    meta_type = 'Student'
37    portal_type = meta_type
38    security = ClassSecurityInfo()
[154]39
[152]40    security.declareProtected(View,"Title")
41    def Title(self):
42        """compose title"""
[153]43        reg_nr = self.getId()[1:]
[152]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
[154]51
52    def Description(self):
53        """compose description"""
[170]54        data = getattr(self,'PERSONAL',None)
55        if data is None:
[191]56            return "none"
[154]57        if data:
[191]58            content = data.getContent()
59            return "%s" % (content.description)
[154]60        return self.description
61
[164]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'),
[166]68                '%s_date' % ident : ds.get('sc_date'),
[164]69                }
[170]70
[173]71        old_user = self.portal_membership.getAuthenticatedMember()
[166]72        if self.portal_membership.isAnonymousUser():
73            tmp_user = CPSUnrestrictedUser('s%(jamb_id)s' % ds, '',
[164]74                                       ['StudentManager'], '')
[166]75            tmp_user = tmp_user.__of__(self.acl_users)
76            newSecurityManager(None, tmp_user)
77        #print str(dict)
[164]78        self.edit(mapping=dict)
[173]79        newSecurityManager(None, old_user)
[164]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
[166]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"""
[168]100        if self.hostel_fee_sc_pin != '':
[166]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
[57]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###)
[91]120
[89]121class StudentPersonal(CPSDocument): ###(
122    """
[154]123    WAeUP Student container for the various student data
[89]124    """
125    meta_type = 'StudentPersonal'
126    portal_type = meta_type
127    security = ClassSecurityInfo()
[152]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
[154]135
[89]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
[179]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
[181]153    security.declareProtected(View,"Title")
154    def Title(self):
155        """compose title"""
156        return "Eligibility Data"
[179]157
[181]158
[179]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###)
[181]167
[166]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
[89]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()
[154]199
[152]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
[89]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
[139]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()
[154]229
[139]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()
[154]246
[139]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)
[200]253
[139]254###)
255
Note: See TracBrowser for help on using the repository browser.