source: WAeUP_SRP/trunk/Academics.py @ 294

Last change on this file since 294 was 290, checked in by joachim, 18 years ago

=add actions changed

  • Property svn:keywords set to Id
File size: 25.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
11#from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder
12#from Products.CPSCore.CPSBase import CPSBaseBTreeDocument as BaseBTreeDocument
13#from Products.CMFCore.DirectoryView import registerDirectory
14
15#registerDirectory('skins', globals())
16#registerDirectory('skins/waeup_default', globals())
17#registerDirectory('skins/waeup_faculty', globals())
18
19import csv,re
20import logging
21import Globals
22p_home = Globals.package_home(globals())
23i_home = Globals.INSTANCE_HOME
24
25class AcademicsFolder(CPSDocument): ###(
26    """
27    WAeUP AcademicsFolder containing StudyCourses
28    """
29    meta_type = 'AcademicsFolder'
30    portal_type = meta_type
31    security = ClassSecurityInfo()
32
33##    security.declareProtected(View,"Title")
34##    def Title(self):
35##        """compose title"""
36##        return "AcademicsFolder of %s" % (self.title)
37
38    security.declareProtected(View,"loadFacultiesFromCSV")###(
39    def loadFacultiesFromCSV(self):
40        """install Universityspecific Faculies from CSV values"""
41        #return
42        name = 'faculty'
43        no_import = False
44        logger = logging.getLogger('%s_import' % name)
45        logger.info('Start loading from %s.csv' % name)
46        academics = self.portal_catalog({'meta_type': 'AcademicsFolder'})[-1].getObject()
47        try:
48            faculties = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb"))
49        except:
50            logger.error('Error reading %s.csv' % name)
51            return
52        l = self.portal_catalog({'meta_type': "Faculty"})
53        facs = {}
54        for f in l:
55            facs[f.id] = f.getObject()
56        for faculty in faculties:
57            logger.info('processing %(Session)s %(FacultyCode)s %(Description)s %(CollegeCode)s %(FacultyKey)s %(Status)s %(degree_grade)s %(Bankcode)s' % faculty)
58            fid = faculty['FacultyCode']
59            f = facs.get(fid,None)
60            if f is None:
61                #self.log('Creating Faculty %(id)s = %(Title)s' % faculty)
62                logger.info('Creating Faculty with ID %(FacultyCode)s %(Description)s' % faculty)
63                academics.invokeFactory('Faculty', fid)
64                f = getattr(self,fid)
65                d = {'Title': faculty['Description']}
66                f.getContent().edit(mapping=d)
67            else:
68                if not no_import:
69                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
70                    no_import.write('"Session","FacultyCode","Description","CollegeCode","FacultyKey","Status","degree_grade","Bankcode"\n')
71                logger.info('Faculty with ID %(FacultyCode)s %(Description)s already exists' % faculty)
72                no_import.write('"%(Session)s","%(FacultyCode)s","%(Description)s","%(CollegeCode)s","%(FacultyKey)s","%(Status)s","%(degree_grade)s","%(Bankcode)s"\n' % faculty)
73        return self.getContent().temporary_view_all()
74    ###)
75
76    security.declareProtected(ModifyPortalContent,"yamlDumpFaculties")###(
77    def yamlDumpFaculties(self):
78        """dump Faculies to Yaml"""
79        #return
80        import yaml
81        logger = logging.getLogger('dumpfaculties')
82        logger.info('Start dumping Faculties')
83        academics = self.portal_catalog({'meta_type': 'AcademicsFolder'})[-1].getObject()
84        l = self.portal_catalog({'meta_type': "Faculty"})
85        facs = {}
86        for f in l:
87            facs[f.id] = f.getObject()
88        for fid in facs.keys():
89            faculty = facs.get(fid).aq_self
90            logger.info('dumping %s %s ' % (faculty.id, faculty.title))
91            print yaml.dump(faculty)
92        return self.academics.temporary_view_all()
93        return self.temporary_view_all()
94           
95    ###)
96
97    security.declareProtected(ModifyPortalContent,"loadDepartmentsFromCSV")###(
98    def loadDepartmentsFromCSV(self):
99        """install Universityspecific Faculies from CSV values"""
100        #return
101        name = 'departments'
102        no_import = False
103        logger = logging.getLogger('loaddepartments')
104        try:
105            deps = csv.DictReader(open("%s/import/departments.csv" % i_home,"rb"))
106        except:
107            logger.error('Error reading departments.csv')
108            return
109        l = self.portal_catalog({'meta_type': "Faculty"})
110        facs = {}
111        for f in l:
112            facs[f.id] = f.getObject()
113        for dep in deps:
114            logger.info('Processing %(Session)s %(DeptCode)s %(Description)s %(FacultyCode)s' % dep)
115            fid = dep['FacultyCode']
116            f = facs.get(fid,None)
117            if f is None:
118                logger.info( "No Faculty with ID: %s" % fid)
119                if not no_import:
120                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
121                    no_import.write('"Session","DeptCode","Description","FacultyCode"\n')
122                no_import.write( "No Faculty with ID: %s\n" % fid)
123                no_import.write('"%(Session)s","%(DeptCode)s","%(Description)s","%(FacultyCode)s"\n' % dep)
124            else:
125                did = dep.get('DeptCode')
126                d = getattr(f,did,None)
127                if d is None or d.portal_type == "Faculty":
128                    #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep)
129                    logger.info('Creating Department %(DeptCode)s = %(Description)s' % dep)
130                    f.invokeFactory('Department', did)
131                    d = getattr(f,did)
132                dict = {'Title': dep['Description']}
133                d.getContent().edit(mapping=dict)
134        return self.academics.temporary_view_all()
135        return self.temporary_view_all()
136    ###)
137   
138    security.declareProtected(ModifyPortalContent,"loadCoursesFromCSV")###(
139    def loadCoursesFromCSV(self):
140        """install Universityspecific Courses from CSV values"""
141        #return
142        name = 'courses'
143        no_import = False
144        logger = logging.getLogger('loadcourses')
145        try:
146            courses = csv.DictReader(open("%s/import/courses.csv" % i_home,"rb"))
147        except:
148            logger.error('Error reading courses.csv')
149            return
150        l = self.portal_catalog({'meta_type': "Faculty"})
151        facs = {}
152        for f in l:
153            facs[f.id] = f.getObject()
154        dl = self.portal_catalog({'meta_type': "Department"})
155        deps = {}
156        for d in dl:
157            deps[d.id] = d.getObject()
158        cl = self.portal_catalog({'meta_type': "Course"})
159        course_list = [ c.id for c in cl]
160        for course in courses:
161            logger.info('Processing %(CourseCode)s %(Description)s %(Credits)s %(Dept)s %(Semester)s %(Session)s %(PassMark)s %(CourseKey)s %(Category)s %(AdmStatus)s' % course)
162##            if course.get("FORMERCODE").endswith('BITS'):
163##                continue
164            depid = course.get('Dept').upper()
165            if depid in deps.keys():
166                dept= deps.get(depid)
167    ##        elif depid in facs.keys():
168    ##            dept= facs.get(depid)
169            else:
170                logger.info("Dep %(Dept)s for Course %(CourseCode)s not found" % course)
171                if not no_import:
172                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
173                    no_import.write('"CourseCode","Description","Credits","Dept","Semester","Session","PassMark","CourseKey","Category","AdmStatus"\n')
174                no_import.write("Dep %(Dept)s for Course %(CourseCode)s not found\n" % course)
175                no_import.write('"%(CourseCode)s","%(Description)s","%(Credits)s","%(Dept)s","%(Semester)s","%(Session)s","%(PassMark)s","%(CourseKey)s","%(Category)s","%(AdmStatus)s"\n' % course)
176                continue
177            course_id = ''.join(re.split('\W+',course.get('CourseCode')))
178            if len(course_id) == 3:
179                course_id = "%s000" % course_id
180##            elif course_id.startswith('CHEM'):
181##                tid = course_id.replace('CHEM','CHE')
182##                logger.info("invalid course_code %(course_id)s renaming to %(tid)s" % vars())
183##                course_id = tid
184##            elif course_id.startswith('DAIC'):
185##                tid = course_id.replace('DAIC','DAC')
186##                logger.info("invalid course_code %(course_id)s renaming to %(tid)s" % vars())
187##                course_id = tid
188##            elif course_id.startswith('DAIM'):
189##                tid = course_id.replace('DAIM','DAM')
190##                logger.info("invalid course_code %(course_id)s renaming to %(tid)s" % vars())
191##                course_id = tid
192            elif len(course_id) != 6:
193                logger.info("invalid course_code %(CourseCode)s" % course)
194                if not no_import:
195                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
196                    no_import.write('"CourseCode","Description","Credits","Dept","Semester","Session","PassMark","CourseKey","Category","AdmStatus"\n')
197                no_import.write("invalid course_code %(CourseCode)s\n" % course)
198                no_import.write('"%(CourseCode)s","%(Description)s","%(Credits)s","%(Dept)s","%(Semester)s","%(Session)s","%(PassMark)s","%(CourseKey)s","%(Category)s","%(AdmStatus)s"\n' % course)
199                continue
200            c = getattr(dept,course_id,None)
201            if c is None:
202                logger.info('Creating Course %(CourseCode)s  %(Description)s in Department %(Dept)s' % course)
203                dept.invokeFactory('Course', course_id)
204                c = getattr(dept,course_id)
205            dict = {'Title': course['Description']}
206            dict['code'] = course_id
207            dict['org_code'] = course.get('CourseCode')
208            dict['credits'] = course.get('Credits')
209            dict['semester'] = course.get('Semester')
210            dict['session'] = course.get('Session')
211            dict['category'] = course.get('Category')
212            pm = course.get('PassMark')
213            if pm.find(',') > -1:
214                pm.replace(',','.')
215            elif pm == "":
216                pm = "0.0"
217            try:
218                dict['passmark'] = int(float(pm))
219            except:
220                dict['passmark'] = 0
221            c.getContent().edit(mapping=dict)
222        return self.academics.temporary_view_all()
223        return self.temporary_view_all()
224    ###)
225
226    security.declareProtected(ModifyPortalContent,"loadCertificatesFromCSV")###(
227
228    def loadCertificatesFromCSV(self):
229        """install Universityspecific Certificates from CSV values"""
230        #return
231        name = 'certificates'
232        no_import = False
233        logger = logging.getLogger('loadcertificates')
234        try:
235            certificates = csv.DictReader(open("%s/import/certificates.csv" % i_home,"rb"))
236        except:
237            logger.error('Error reading certificates.csv')
238            return
239        f_ids = [f.id for f in self.portal_catalog({'meta_type': "Faculty"})]
240        #d_ids = [d.id for d in self.portal_catalog({'meta_type': "Department"})]
241        dl = self.portal_catalog({'meta_type': "Department"})
242        deps = {}
243        for d in dl:
244            deps[d.id] = d.getObject()
245        for certificate in certificates:
246            logger.info('Processing %(CertCode)s %(Description)s %(Faculty)s %(MaxPass)s %(MaxLoad)s %(session)s %(PromotionCredits)s %(Probationcredits)s %(StartLevel)s %(endLevel)s %(Nyears)s %(Ncore)s %(MaxElect)s %(MPREFIX)s %(Dept)s %(Admstatus)s %(category)s' % certificate)
247            depid = certificate.get('Dept')
248            facid = certificate.get('Faculty')
249            if facid not in f_ids:
250                logger.info('Faculty %(Faculty)s for %(CertCode)s %(Description)s not found' % certificate)
251                if not no_import:
252                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
253                    no_import.write('"CertCode","Description","Faculty","MaxPass","MaxLoad","session","PromotionCredits","Probationcredits","StartLevel","endLevel","Nyears","Ncore","MaxElect","MPREFIX","Dept","Admstatus","category"\n')
254                no_import.write('Faculty %(Faculty)s for %(CertCode)s %(Description)s not found\n' % certificate)
255                no_import.write('"%(CertCode)s","%(Description)s","%(Faculty)s","%(MaxPass)s","%(MaxLoad)s","%(session)s","%(PromotionCredits)s","%(Probationcredits)s","%(StartLevel)s","%(endLevel)s","%(Nyears)s","%(Ncore)s","%(MaxElect)s","%(MPREFIX)s","%(Dept)s","%(Admstatus)s","%(category)s"\n' % certificate)
256                continue
257            if not deps.has_key(depid):
258                logger.info('Department %(Dept)s for %(CertCode)s %(Description)s not found' % certificate)
259                if not no_import:
260                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
261                    no_import.write('"CertCode","Description","Faculty","MaxPass","MaxLoad","session","PromotionCredits","Probationcredits","StartLevel","endLevel","Nyears","Ncore","MaxElect","MPREFIX","Dept","Admstatus","category"\n')
262                no_import.write('Department %(Dept)s for %(CertCode)s %(Description)s not found\n' % certificate)
263                no_import.write('"%(CertCode)s","%(Description)s","%(Faculty)s","%(MaxPass)s","%(MaxLoad)s","%(session)s","%(PromotionCredits)s","%(Probationcredits)s","%(StartLevel)s","%(endLevel)s","%(Nyears)s","%(Ncore)s","%(MaxElect)s","%(MPREFIX)s","%(Dept)s","%(Admstatus)s","%(category)s"\n' % certificate)
264                continue
265            certificate_id = "%(category)s_%(Admstatus)s_%(Dept)s" % certificate
266            dep = deps[depid]
267            c = getattr(dep,certificate_id,None)
268            if c is None:
269                #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep)
270                logger.info('Creating certificate %(CertCode)s  %(Description)s in Department %(Dept)s' % certificate)
271                dep.invokeFactory('Certificate', certificate_id)
272                c = getattr(dep,certificate_id)
273            dict = {'Title': certificate['Description']}
274            code = certificate.get('CertCode')
275            code = code.replace('.','')
276            code = code.replace('(','')
277            code = code.replace(')','')
278            code = code.replace('/','')
279            code = code.replace(' ','')
280            code = code.replace('_','')
281            dict['code'] = code
282            dict['faculty'] = certificate.get('Faculty')
283            dict['department'] = certificate.get('Dept')
284            dict['max_pass'] = certificate.get('MaxPass')
285            dict['max_load'] = certificate.get('MaxLoad')
286            dict['admin_status'] = certificate.get('Admstatus')
287            dict['category'] = certificate.get('category')
288            dict['m_prefix'] = certificate.get('MPREFIX')
289            dict['nr_years'] = int(certificate.get('Nyears'))
290            nc = certificate.get('Ncore','1')
291            try:
292                dict['n_core'] = int(nc)
293            except:
294                dict['n_core'] = 1
295            dict['start_level'] = certificate.get('StartLevel')
296            dict['end_level'] = certificate.get('endLevel')
297            dict['promotion_credits'] = certificate.get('PromotionCredits')
298            dict['probation_credits'] = certificate.get('ProbationCredits')
299            c.getContent().edit(mapping=dict)
300        return self.academics.temporary_view_all()
301        return self.temporary_view_all()
302    ###)
303
304    security.declareProtected(ModifyPortalContent,"loadCertificateCoursesFromCSV")###(
305    def loadCertificateCoursesFromCSV(self):
306        """install Certificate Courses from CSV values"""
307        #return
308        logger = logging.getLogger('loadcertificatecourses')
309        name = 'certificate_courses'
310        no_import = False
311        try:
312            cert_courses = csv.DictReader(open("%s/import/course_level_courses.csv" % i_home,"rb"))
313        except:
314            logger.error('Error reading course_level_courses.csv')
315            return
316        d_ids = [d.id for d in self.portal_catalog({'meta_type': "Department"})]
317        c_ids = [c.id for c in self.portal_catalog({'meta_type': "Course"})]
318        for cert_course in cert_courses:
319            logger.info('Processing %(CosCode)s %(CertCode)s %(CoreKey)s %(Session)s %(Level)s %(Core)s %(Elective)s %(Mandatory)s %(AdmStatus)s %(Dept)s %(Semester)s' % cert_course)
320            depid = cert_course.get('Dept')
321            course_code = cert_course.get('CosCode')
322            code = cert_course.get('CertCode')
323            code = code.replace('.','')
324            code = code.replace('(','')
325            code = code.replace(')','')
326            code = code.replace('/','')
327            code = code.replace(' ','')
328            code = code.replace('_','')
329##            if cert_course.get('Session') != '2002/2003':
330##                continue
331            certificate = self.portal_catalog({'meta_type': "Certificate",
332                                               'SearchableText': code})
333            if not certificate:
334                #print code
335                em = 'CertCode %(CertCode)s for %(CosCode)s not found\n' % cert_course
336                logger.info(em)
337                if not no_import:
338                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
339                    no_import.write('"CosCode","CertCode","CoreKey","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n')
340                no_import.write(em)
341                no_import.write('"%(CosCode)s","%(CertCode)s","%(CoreKey)s","%(Session)s","%(Level)s","%(Core)s","%(Elective)s","%(Mandatory)s","%(AdmStatus)s","%(Dept)s","%(Semester)s"\n' % cert_course)
342                continue
343            certificate = certificate[-1].getObject()
344            certificate_code = certificate.getId()
345            if course_code not in c_ids:
346                em = 'CorseCode %(CosCode)s for %(CertCode)s not found in Courses\n' % cert_course
347                logger.info(em)
348                if not no_import:
349                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
350                    no_import.write('"CosCode","CertCode","CoreKey","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n')
351                no_import.write(em)
352                no_import.write('"%(CosCode)s","%(CertCode)s","%(CoreKey)s","%(Session)s","%(Level)s","%(Core)s","%(Elective)s","%(Mandatory)s","%(AdmStatus)s","%(Dept)s","%(Semester)s"\n' % cert_course)
353                continue
354            if depid not in d_ids:
355                em = 'Department %(Dept)s for %(CertCode)s not found\n' % cert_course
356                logger.info(em)
357                if not no_import:
358                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
359                    no_import.write('"CosCode","CertCode","CoreKey","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n')
360                no_import.write(em)
361                no_import.write('"%(CosCode)s","%(CertCode)s","%(CoreKey)s","%(Session)s","%(Level)s","%(Core)s","%(Elective)s","%(Mandatory)s","%(AdmStatus)s","%(Dept)s","%(Semester)s"\n' % cert_course)
362                continue
363            level = cert_course.get('Level')
364            l = getattr(certificate,level,None)
365            if l is None:
366                #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep)
367                logger.info('Creating Level %(Level)s in certificate %(CertCode)s' % cert_course)
368                certificate.invokeFactory('StudyLevel', level)
369                l = getattr(certificate, level)
370                l.invokeFactory('Semester','first')
371                l.invokeFactory('Semester','second')
372            certificate.orderObjects('id')
373            first_s = getattr(l,'first')
374            second_s = getattr(l,'second')
375            if cert_course.get('Semester') == '1':
376                semester = first_s
377            else:
378                semester = second_s
379            if hasattr(semester,course_code):
380                logger.info('Duplicate %(CosCode)s in Level %(Level)s' % cert_course)
381                if not no_import:
382                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
383                    no_import.write('"CosCode","CertCode","CoreKey","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n')
384                no_import.write('Duplicate %(CosCode)s in Level %(Level)s' % cert_course)
385                no_import.write('"%(CosCode)s","%(CertCode)s","%(CoreKey)s","%(Session)s","%(Level)s","%(Core)s","%(Elective)s","%(Mandatory)s","%(AdmStatus)s","%(Dept)s","%(Semester)s"\n' % cert_course)
386                continue
387            semester.invokeFactory('CertificateCourse',course_code)
388            cc = getattr(semester,course_code)
389            dict = {}
390            dict['code'] = cert_course.get('CosCode')
391            dict['certificate_code'] = code
392            dict['certificate_code_org'] = cert_course.get('CertCode')
393            dict['department'] = cert_course.get('Dept')
394            dict['admin_status'] = cert_course.get('Admstatus')
395            dict['session'] = cert_course.get('Session')
396            if cert_course.get('Core') != '':
397                dict['core_or_elective'] = True
398            else:
399                dict['core_or_elective'] = False
400            dict['level'] = cert_course.get('Level')
401            cc.academics.edit(mapping=dict)
402    ###)
403
404InitializeClass(AcademicsFolder)
405
406def addAcademicsFolder(container, id, REQUEST=None, **kw):
407    """Add a AcademicsFolder."""
408    ob = AcademicsFolder(id, **kw)
409    return CPSBase_adder(container, ob, REQUEST=REQUEST)
410
411###)
412
413class Certificate(CPSDocument): ###(
414    """
415    WAeUP Certificate
416    """
417    meta_type = 'Certificate'
418    portal_type = meta_type
419    security = ClassSecurityInfo()
420   
421    def __init__(self, id, **kw):
422        CPSDocument.__init__(self, id, **kw)
423
424##    security.declareProtected(View,"Title")
425##    def Title(self):
426##        """compose title"""
427##        return "Certificate of %s" % (self.title)
428
429InitializeClass(Certificate)
430
431def addCertificate(container, id, REQUEST=None, **kw):
432    """Add a Certificate."""
433    ob = Certificate(id, **kw)
434    return CPSBase_adder(container, ob, REQUEST=REQUEST)
435
436###)
437
438class CertificateCourse(CPSDocument): ###(
439    """
440    WAeUP CertificateCourse 
441    """
442    meta_type = 'CertificateCourse'
443    portal_type = meta_type
444    security = ClassSecurityInfo()
445   
446    def getCourseEntry(self,cid):
447        res = self.portal_catalog({'meta_type': "Course",
448                                           'id': cid})
449        if res:
450            return res[-1] 
451        else:
452            return None
453       
454    security.declareProtected(View,"Title")
455    def Title(self):
456        """compose title"""
457        ce = self.getCourseEntry(self.id)
458        if ce:
459            return "%s" % ce.Title
460        return "No such course"
461
462    security.declareProtected(View,"credits")
463    def credits(self):
464        """credits from course"""
465        ce = self.getCourseEntry(self.id)
466        if ce:
467            return "%s" % ce.credits
468        return "0"
469   
470    security.declareProtected(View,"passmark")
471    def passmark(self):
472        """passmark from course"""
473        ce = self.getCourseEntry(self.id)
474        return ce.passmark
475   
476    security.declareProtected(View,"coursepath")
477    def coursepath(self):
478        """coursepath from course"""
479        ce = self.getCourseEntry(self.id)
480        if ce:
481            return ce.getPath()
482        return "?"
483   
484
485InitializeClass(CertificateCourse)
486
487def addCertificateCourse(container, id, REQUEST=None, **kw):
488    """Add a CertificateCourse."""
489    ob = CertificateCourse(id, **kw)
490    return CPSBase_adder(container, ob, REQUEST=REQUEST)
491###)
492
493class Faculty(CPSDocument): ###(
494    """
495    WAeUP Faculty containing Departments
496    """
497    meta_type = 'Faculty'
498    portal_type = meta_type
499    security = ClassSecurityInfo()
500   
501##    def __init__(self, id, **kw):
502##        CPSDocument.__init__(self, id, **kw)
503
504    security.declareProtected(View,"Title")
505    def Title(self):
506        """compose title"""
507        return "%s" % (self.title)
508
509InitializeClass(Faculty)
510
511def addFaculty(container, id, REQUEST=None, **kw):
512    """Add a Faculty."""
513    ob = Faculty(id, **kw)
514    return CPSBase_adder(container, ob, REQUEST=REQUEST)
515
516###)
517
518class Department(CPSDocument): ###(
519    """
520    WAeUP Department containing the courses and students
521    """
522    meta_type = 'Department'
523    portal_type = meta_type
524    security = ClassSecurityInfo()
525
526##    security.declareProtected(View,"Title")
527##    def Title(self):
528##        """compose title"""
529##        reg_nr = self.getId()[1:]
530##        return "Department of %s" % (self.title)
531
532InitializeClass(Department)
533
534def addDepartment(container, id, REQUEST=None, **kw):
535    """Add a Department."""
536    ob = Department(id, **kw)
537    return CPSBase_adder(container, ob, REQUEST=REQUEST)
538###)
539
540class Course(CPSDocument): ###(
541    """
542    WAeUP Course 
543    """
544    meta_type = 'Course'
545    portal_type = meta_type
546    security = ClassSecurityInfo()
547
548    security.declareProtected(View,"Title")
549    def Title(self):
550        """compose title"""
551        return self.title
552   
553InitializeClass(Course)
554
555def addCourse(container, id, REQUEST=None, **kw):
556    """Add a Course."""
557    ob = Course(id, **kw)
558    return CPSBase_adder(container, ob, REQUEST=REQUEST)
559###)
560
561class CourseTicket(CPSDocument): ###(
562    """
563    WAeUP CourseTicket 
564    """
565    meta_type = 'CourseTicket'
566    portal_type = meta_type
567    security = ClassSecurityInfo()
568   
569InitializeClass(CourseTicket)
570
571def addCourseTicket(container, id, REQUEST=None, **kw):
572    """Add a CourseTicket."""
573    ob = CourseTicket(id, **kw)
574    return CPSBase_adder(container, ob, REQUEST=REQUEST)
575###)
576
Note: See TracBrowser for help on using the repository browser.