Changeset 296 for WAeUP_SRP/trunk/Academics.py
- Timestamp:
- 14 Jul 2006, 13:52:50 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Academics.py
r295 r296 71 71 logger.info('Faculty with ID %(FacultyCode)s %(Description)s already exists' % faculty) 72 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.academics.temporary_view_all() 74 return self.getContent().temporary_view_all() 73 return self.academics.academics_contents() 75 74 ###) 76 75 … … 140 139 dict = {'Title': 'Certificates'} 141 140 certificates.getContent().edit(mapping=dict) 142 return self.academics.temporary_view_all() 143 return self.temporary_view_all() 141 return self.academics.academics_contents() 144 142 ###) 145 143 … … 167 165 course_list = [ c.id for c in cl] 168 166 for course in courses: 169 logger.info('Processing %(CourseCode)s %(Description)s %(Credits)s %(Dept)s %(Semester)s %(Session)s %(PassMark)s %(C ourseKey)s %(Category)s %(AdmStatus)s' % course)167 logger.info('Processing %(CourseCode)s %(Description)s %(Credits)s %(Dept)s %(Semester)s %(Session)s %(PassMark)s %(Category)s %(AdmStatus)s' % course) 170 168 ## if course.get("FORMERCODE").endswith('BITS'): 171 169 ## continue … … 179 177 if not no_import: 180 178 no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") 181 no_import.write('"CourseCode","Description","Credits","Dept","Semester","Session","PassMark","C ourseKey","Category","AdmStatus"\n')179 no_import.write('"CourseCode","Description","Credits","Dept","Semester","Session","PassMark","Category","AdmStatus"\n') 182 180 no_import.write("Dep %(Dept)s for Course %(CourseCode)s not found\n" % course) 183 no_import.write('"%(CourseCode)s","%(Description)s","%(Credits)s","%(Dept)s","%(Semester)s","%(Session)s","%(PassMark)s","%(C ourseKey)s","%(Category)s","%(AdmStatus)s"\n' % course)181 no_import.write('"%(CourseCode)s","%(Description)s","%(Credits)s","%(Dept)s","%(Semester)s","%(Session)s","%(PassMark)s","%(Category)s","%(AdmStatus)s"\n' % course) 184 182 continue 185 183 course_id = ''.join(re.split('\W+',course.get('CourseCode'))) … … 198 196 ## logger.info("invalid course_code %(course_id)s renaming to %(tid)s" % vars()) 199 197 ## course_id = tid 200 elif len(course_id) > 7:198 elif len(course_id) > 10: 201 199 logger.info("invalid course_code %(CourseCode)s" % course) 202 200 if not no_import: 203 201 no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") 204 no_import.write('"CourseCode","Description","Credits","Dept","Semester","Session","PassMark","C ourseKey","Category","AdmStatus"\n')202 no_import.write('"CourseCode","Description","Credits","Dept","Semester","Session","PassMark","Category","AdmStatus"\n') 205 203 no_import.write("invalid course_code %(CourseCode)s\n" % course) 206 no_import.write('"%(CourseCode)s","%(Description)s","%(Credits)s","%(Dept)s","%(Semester)s","%(Session)s","%(PassMark)s","%(C ourseKey)s","%(Category)s","%(AdmStatus)s"\n' % course)204 no_import.write('"%(CourseCode)s","%(Description)s","%(Credits)s","%(Dept)s","%(Semester)s","%(Session)s","%(PassMark)s","%(Category)s","%(AdmStatus)s"\n' % course) 207 205 continue 208 206 courses = dept.Courses … … 229 227 dict['passmark'] = 0 230 228 c.getContent().edit(mapping=dict) 231 return self.academics.temporary_view_all() 232 return self.temporary_view_all() 229 return self.academics.academics_contents() 233 230 ###) 234 231 … … 272 269 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) 273 270 continue 274 certificate_id = "%(category)s_%(Admstatus)s_%(Dept)s" % certificate271 #certificate_id = "%(category)s_%(Admstatus)s_%(Dept)s" % certificate 275 272 dep = deps[depid] 276 273 certificates = dep.Certificates 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 certificate_id = code 277 282 c = getattr(certificates,certificate_id,None) 278 283 if c is None: … … 282 287 c = getattr(certificates,certificate_id) 283 288 dict = {'Title': certificate['Description']} 284 code = certificate.get('CertCode')285 code = code.replace('.','')286 code = code.replace('(','')287 code = code.replace(')','')288 code = code.replace('/','')289 code = code.replace(' ','')290 code = code.replace('_','')291 289 dict['code'] = code 292 290 dict['faculty'] = certificate.get('Faculty') … … 308 306 dict['probation_credits'] = certificate.get('ProbationCredits') 309 307 c.getContent().edit(mapping=dict) 310 return self.academics.temporary_view_all() 311 return self.temporary_view_all() 308 return self.academics.academics_contents() 312 309 ###) 313 310 … … 326 323 d_ids = [d.id for d in self.portal_catalog({'meta_type': "Department"})] 327 324 c_ids = [c.id for c in self.portal_catalog({'meta_type': "Course"})] 325 l = self.portal_catalog({'meta_type': "Certificate"}) 326 certs = {} 327 for f in l: 328 certs[f.id] = f.getObject() 328 329 for cert_course in cert_courses: 329 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)330 logger.info('Processing %(CosCode)s %(CertCode)s %(Session)s %(Level)s %(Core)s %(Elective)s %(Mandatory)s %(AdmStatus)s %(Dept)s %(Semester)s' % cert_course) 330 331 depid = cert_course.get('Dept') 331 332 course_code = cert_course.get('CosCode') … … 339 340 ## if cert_course.get('Session') != '2002/2003': 340 341 ## continue 341 certificate = self.portal_catalog({'meta_type': "Certificate", 342 'SearchableText': code}) 343 if not certificate: 342 ## certificate = self.portal_catalog({'meta_type': "Certificate", 343 ## 'SearchableText': code}) 344 ## if not certificate: 345 if not code in certs.keys(): 344 346 #print code 345 347 em = 'CertCode %(CertCode)s for %(CosCode)s not found\n' % cert_course … … 347 349 if not no_import: 348 350 no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") 349 no_import.write('"CosCode","CertCode"," CoreKey","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n')351 no_import.write('"CosCode","CertCode","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n') 350 352 no_import.write(em) 351 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 no_import.write('"%(CosCode)s","%(CertCode)s","%(Session)s","%(Level)s","%(Core)s","%(Elective)s","%(Mandatory)s","%(AdmStatus)s","%(Dept)s","%(Semester)s"\n' % cert_course) 352 354 continue 353 355 certificate = certificate[-1].getObject() … … 358 360 if not no_import: 359 361 no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") 360 no_import.write('"CosCode","CertCode"," CoreKey","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n')362 no_import.write('"CosCode","CertCode","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n') 361 363 no_import.write(em) 362 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)364 no_import.write('"%(CosCode)s","%(CertCode)s","%(Session)s","%(Level)s","%(Core)s","%(Elective)s","%(Mandatory)s","%(AdmStatus)s","%(Dept)s","%(Semester)s"\n' % cert_course) 363 365 continue 364 366 if depid not in d_ids: … … 367 369 if not no_import: 368 370 no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") 369 no_import.write('"CosCode","CertCode"," CoreKey","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n')371 no_import.write('"CosCode","CertCode","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n') 370 372 no_import.write(em) 371 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)373 no_import.write('"%(CosCode)s","%(CertCode)s","%(Session)s","%(Level)s","%(Core)s","%(Elective)s","%(Mandatory)s","%(AdmStatus)s","%(Dept)s","%(Semester)s"\n' % cert_course) 372 374 continue 373 375 level = cert_course.get('Level') … … 391 393 if not no_import: 392 394 no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") 393 no_import.write('"CosCode","CertCode"," CoreKey","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n')395 no_import.write('"CosCode","CertCode","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n') 394 396 ## no_import.write('Duplicate %(CosCode)s in Level %(Level)s' % cert_course) 395 ## 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)397 ## no_import.write('"%(CosCode)s","%(CertCode)s","%(Session)s","%(Level)s","%(Core)s","%(Elective)s","%(Mandatory)s","%(AdmStatus)s","%(Dept)s","%(Semester)s"\n' % cert_course) 396 398 continue 397 399 semester.invokeFactory('CertificateCourse',course_code) … … 410 412 dict['level'] = cert_course.get('Level') 411 413 cc.getContent().edit(mapping=dict) 412 return self.academics. temporary_view_all()414 return self.academics.academics_contents() 413 415 ###) 414 416 … … 483 485 """passmark from course""" 484 486 ce = self.getCourseEntry(self.id) 485 return ce.passmark 487 if ce is not None and hasattr(ce,"passmark"): 488 return ce.passmark 489 486 490 487 491 security.declareProtected(View,"coursepath") … … 517 521 """compose title""" 518 522 return "%s" % (self.title) 523 524 security.declareProtected(View,"LongTitle") 525 def LongTitle(self): 526 """compose long_title""" 527 itype = self.portal_vocabularies.institution_types_voc.get(self.institution_type,default="Faculty of") 528 529 return "%s %s" % (itype,self.title) 519 530 520 531 InitializeClass(Faculty) … … 541 552 ## return "Department of %s" % (self.title) 542 553 554 security.declareProtected(View,"LongTitle") 555 def LongTitle(self): 556 """compose long_title""" 557 if not hasattr(self,'institution_type'): 558 self.institution_type = "department" 559 itype = self.portal_vocabularies.institution_types_voc.get(self.institution_type,default="Department of") 560 561 return "%s %s" % (itype,self.title) 562 543 563 InitializeClass(Department) 544 564 545 565 def addDepartment(container, id, REQUEST=None, **kw): 546 566 """Add a Department.""" 547 ob = Department(id, **kw)567 object = Department(id, **kw) 548 568 id = object.getId() 549 569 container._setObject(id, object) 550 dep = getattr(container,id) 570 dep = getattr(container,id).getContent() 551 571 dep.invokeFactory('CoursesFolder','Courses') 572 o = getattr(dep,'Courses') 573 dict = {'Title': 'Courses'} 574 o.getContent().edit(mapping=dict) 552 575 dep.invokeFactory('CertificatesFolder','Certificates') 576 o = getattr(dep,'Certificates') 577 dict = {'Title': 'Certificates'} 578 o.getContent().edit(mapping=dict) 553 579 if REQUEST is not None: 554 580 url = container.absolute_url()
Note: See TracChangeset for help on using the changeset viewer.