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