source: waeup_product/trunk/Students.py @ 153

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

=corrected some typos

  • Property svn:keywords set to Id
File size: 5.7 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       
64InitializeClass(Student)
65
66def addStudent(container, id, REQUEST=None, **kw):
67    """Add a Student."""
68    ob = Student(id, **kw)
69    return CPSBase_adder(container, ob, REQUEST=REQUEST)
70
71###)
72
73studentpersonal_fti = { ###(
74    'title': 'WAeUP StudentPersonal',
75    'description': '',
76    'content_icon': 'student.gif',
77    'content_meta_type': 'StudentPersonal',
78    'factory': 'addStudent',
79    'immediate_view': 'student_personal_index_html',
80    'global_allow': True,
81    'filter_content_types': True,
82    'allowed_content_types': (),
83    'allow_discussion': False,
84}
85
86###)
87
88class StudentPersonal(CPSDocument): ###(
89    """
90    WAeUP Student container for the various student data
91    """
92    meta_type = 'StudentPersonal'
93    portal_type = meta_type
94    security = ClassSecurityInfo()
95
96    security.declareProtected(View,"Title")
97    def Title(self):
98        """compose title"""
99        content = self.getContent()
100        return "Personal Data for %s %s" % (content.firstname,content.lastname)
101
102   
103InitializeClass(StudentPersonal)
104
105def addStudentPersonal(container, id, REQUEST=None, **kw):
106    """Add a Students personal data."""
107    ob = StudentPersonal(id, **kw)
108    return CPSBase_adder(container, ob, REQUEST=REQUEST)
109
110###)
111
112jamb_fti = { ###(
113    'title': 'WAeUP Jamb',
114    'description': '',
115    'content_icon': '',
116    'content_meta_type': 'Jamb',
117    'factory': 'addJamb',
118    'immediate_view': 'cpsdocument_view',
119    'global_allow': True,
120    'filter_content_types': True,
121    'allowed_content_types': ('Course',),
122    'allow_discussion': False,
123}
124###)
125
126class Jamb(CPSDocument): ###(
127    """
128    WAeUP Jamb containing the courses and students
129    """
130    meta_type = 'Jamb'
131    portal_type = meta_type
132    security = ClassSecurityInfo()
133   
134    security.declareProtected(View,"Title")
135    def Title(self):
136        """compose title"""
137        content = self.getContent()
138        return "JAMB Data for %s %s" % (content.firstname,content.lastname)
139
140    security.declareProtected(View,"setOwnership")
141    def setOwnership(self,member_id):
142        """set ownership"""
143        pm = getattr(self,'portal_membership')
144        member = pm.getMemberById(member_id)
145        self.changeOwnership(member)
146
147InitializeClass(Jamb)
148
149def addJamb(container, id, REQUEST=None, **kw):
150    """Add a Jamb."""
151    ob = Jamb(id, **kw)
152    return CPSBase_adder(container, ob, REQUEST=REQUEST)
153###)
154
155study_level_fti = { ###(
156    'title': 'WAeUP StudyLevel',
157    'description': '',
158    'content_icon': '',
159    'content_meta_type': 'StudyLevel',
160    'factory': 'addStudyLevel',
161    'immediate_view': 'cpsdocument_view',
162    'global_allow': True,
163    'filter_content_types': True,
164    'allowed_content_types': ('Course',),
165    'allow_discussion': False,
166}
167###)
168
169class StudyLevel(CPSDocument): ###(
170    """
171    WAeUP StudyLevel containing the courses and students
172    """
173    meta_type = 'StudyLevel'
174    portal_type = meta_type
175    security = ClassSecurityInfo()
176   
177InitializeClass(StudyLevel)
178
179def addStudyLevel(container, id, REQUEST=None, **kw):
180    """Add a StudyLevel."""
181    ob = StudyLevel(id, **kw)
182    return CPSBase_adder(container, ob, REQUEST=REQUEST)
183###)
184
185semester_fti = { ###(
186    'title': 'WAeUP Semester',
187    'description': '',
188    'content_icon': '',
189    'content_meta_type': 'Semester',
190    'factory': 'addSemester',
191    'immediate_view': 'cpsdocument_view',
192    'global_allow': True,
193    'filter_content_types': True,
194    'allowed_content_types': ('Course',),
195    'allow_discussion': False,
196}
197###)
198
199class Semester(CPSDocument): ###(
200    """
201    WAeUP Semester containing the courses and students
202    """
203    meta_type = 'Semester'
204    portal_type = meta_type
205    security = ClassSecurityInfo()
206   
207InitializeClass(Semester)
208
209def addSemester(container, id, REQUEST=None, **kw):
210    """Add a Semester."""
211    ob = Semester(id, **kw)
212    return CPSBase_adder(container, ob, REQUEST=REQUEST)
213###)
214
Note: See TracBrowser for help on using the repository browser.