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