source: waeup_product/trunk/Students.py @ 158

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

minor changes

  • Property svn:keywords set to Id
File size: 6.0 KB
Line 
1#-*- mode: python; mode: fold -*-
2from Globals import InitializeClass
3from AccessControl import ClassSecurityInfo
4
5from Products.CMFCore.utils import UniqueObject, getToolByName
6from Products.CMFCore.permissions import View
7from Products.CMFCore.permissions import ModifyPortalContent
8from Products.CPSCore.CPSBase import CPSBase_adder, CPSBaseFolder
9#from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument
10from Products.CPSDocument.CPSDocument import CPSDocument
11from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder
12class StudentsFolder(BaseBTreeFolder): ###(
13    """
14    WAeUP container for the various WAeUP containers data
15    """
16    meta_type = 'Students Folder'
17    portal_type = meta_type
18    security = ClassSecurityInfo()
19
20
21InitializeClass(StudentsFolder)
22
23def addStudentsFolder(container, id, REQUEST=None, **kw):
24    """Add a Student."""
25    ob = StudentsFolder(id, **kw)
26    return CPSBase_adder(container, ob, REQUEST=REQUEST)
27###)
28
29student_fti = { ###(
30    'title': 'WAeUP Student',
31    'description': '',
32    'content_icon': 'student.gif',
33    'content_meta_type': 'Student',
34    'factory': 'addStudent',
35    'immediate_view': 'cpsdocument_view',
36    'global_allow': True,
37    'filter_content_types': True,
38    'allowed_content_types': ('Jamb','StudentPersonal'),
39    'allow_discussion': False,
40}
41
42###)
43
44class Student(CPSDocument): ###(
45    """
46    WAeUP Student container for the various student data
47    """
48    meta_type = 'Student'
49    portal_type = meta_type
50    security = ClassSecurityInfo()
51
52    security.declareProtected(View,"Title")
53    def Title(self):
54        """compose title"""
55        reg_nr = self.getId()[1:]
56        data = getattr(self,'PERSONAL',None)
57        if data is None:
58            data = getattr(self,'JAMB',None)
59        if data:
60            content = data.getContent()
61            return "%s %s" % (content.firstname,content.lastname)
62        return self.title
63
64    def Description(self):
65        """compose description"""
66        data = getattr(self,'JAMB',None)
67        if data:
68            content = data.getContent()
69            return "%s %s is studying %s" % (content.firstname,content.lastname,content.course)
70        return self.description
71
72InitializeClass(Student)
73
74def addStudent(container, id, REQUEST=None, **kw):
75    """Add a Student."""
76    ob = Student(id, **kw)
77    return CPSBase_adder(container, ob, REQUEST=REQUEST)
78
79###)
80
81studentpersonal_fti = { ###(
82    'title': 'WAeUP StudentPersonal',
83    'description': '',
84    'content_icon': 'student.gif',
85    'content_meta_type': 'StudentPersonal',
86    'factory': 'addStudent',
87    'immediate_view': 'student_personal_index_html',
88    'global_allow': True,
89    'filter_content_types': True,
90    'allowed_content_types': (),
91    'allow_discussion': False,
92}
93
94###)
95
96class StudentPersonal(CPSDocument): ###(
97    """
98    WAeUP Student container for the various student data
99    """
100    meta_type = 'StudentPersonal'
101    portal_type = meta_type
102    security = ClassSecurityInfo()
103
104    security.declareProtected(View,"Title")
105    def Title(self):
106        """compose title"""
107        content = self.getContent()
108        return "Personal Data for %s %s" % (content.firstname,content.lastname)
109
110
111InitializeClass(StudentPersonal)
112
113def addStudentPersonal(container, id, REQUEST=None, **kw):
114    """Add a Students personal data."""
115    ob = StudentPersonal(id, **kw)
116    return CPSBase_adder(container, ob, REQUEST=REQUEST)
117
118###)
119
120jamb_fti = { ###(
121    'title': 'WAeUP Jamb',
122    'description': '',
123    'content_icon': '',
124    'content_meta_type': 'Jamb',
125    'factory': 'addJamb',
126    'immediate_view': 'cpsdocument_view',
127    'global_allow': True,
128    'filter_content_types': True,
129    'allowed_content_types': ('Course',),
130    'allow_discussion': False,
131}
132###)
133
134class Jamb(CPSDocument): ###(
135    """
136    WAeUP Jamb containing the courses and students
137    """
138    meta_type = 'Jamb'
139    portal_type = meta_type
140    security = ClassSecurityInfo()
141
142    security.declareProtected(View,"Title")
143    def Title(self):
144        """compose title"""
145        content = self.getContent()
146        return "JAMB Data for %s %s" % (content.firstname,content.lastname)
147
148    security.declareProtected(View,"setOwnership")
149    def setOwnership(self,member_id):
150        """set ownership"""
151        pm = getattr(self,'portal_membership')
152        member = pm.getMemberById(member_id)
153        self.changeOwnership(member)
154
155InitializeClass(Jamb)
156
157def addJamb(container, id, REQUEST=None, **kw):
158    """Add a Jamb."""
159    ob = Jamb(id, **kw)
160    return CPSBase_adder(container, ob, REQUEST=REQUEST)
161###)
162
163study_level_fti = { ###(
164    'title': 'WAeUP StudyLevel',
165    'description': '',
166    'content_icon': '',
167    'content_meta_type': 'StudyLevel',
168    'factory': 'addStudyLevel',
169    'immediate_view': 'cpsdocument_view',
170    'global_allow': True,
171    'filter_content_types': True,
172    'allowed_content_types': ('Course',),
173    'allow_discussion': False,
174}
175###)
176
177class StudyLevel(CPSDocument): ###(
178    """
179    WAeUP StudyLevel containing the courses and students
180    """
181    meta_type = 'StudyLevel'
182    portal_type = meta_type
183    security = ClassSecurityInfo()
184
185InitializeClass(StudyLevel)
186
187def addStudyLevel(container, id, REQUEST=None, **kw):
188    """Add a StudyLevel."""
189    ob = StudyLevel(id, **kw)
190    return CPSBase_adder(container, ob, REQUEST=REQUEST)
191###)
192
193semester_fti = { ###(
194    'title': 'WAeUP Semester',
195    'description': '',
196    'content_icon': '',
197    'content_meta_type': 'Semester',
198    'factory': 'addSemester',
199    'immediate_view': 'cpsdocument_view',
200    'global_allow': True,
201    'filter_content_types': True,
202    'allowed_content_types': ('Course',),
203    'allow_discussion': False,
204}
205###)
206
207class Semester(CPSDocument): ###(
208    """
209    WAeUP Semester containing the courses and students
210    """
211    meta_type = 'Semester'
212    portal_type = meta_type
213    security = ClassSecurityInfo()
214
215InitializeClass(Semester)
216
217def addSemester(container, id, REQUEST=None, **kw):
218    """Add a Semester."""
219    ob = Semester(id, **kw)
220    return CPSBase_adder(container, ob, REQUEST=REQUEST)
221###)
222
Note: See TracBrowser for help on using the repository browser.