Changeset 278
- Timestamp:
- 28 Jun 2006, 11:04:44 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Academics.py
r256 r278 17 17 #registerDirectory('skins/waeup_faculty', globals()) 18 18 19 ##class SCFolder(CPSDocument): ###( 20 ## """ 21 ## WAeUP StudyCourseFolder containing StudyCourses 22 ## """ 23 ## meta_type = 'SCFolder' 24 ## portal_type = meta_type 25 ## security = ClassSecurityInfo() 26 ## 27 ## def __init__(self, id, **kw): 28 ## CPSDocument.__init__(self, id, **kw) 29 ## 19 class AcademicsFolder(CPSDocument): ###( 20 """ 21 WAeUP AcademicsFolder containing StudyCourses 22 """ 23 meta_type = 'AcademicsFolder' 24 portal_type = meta_type 25 security = ClassSecurityInfo() 26 30 27 ## security.declareProtected(View,"Title") 31 28 ## def Title(self): 32 29 ## """compose title""" 33 ## return "SCFolder of %s" % (self.title) 34 ## 35 ##InitializeClass(SCFolder) 36 ## 37 ##def addSCFolder(container, id, REQUEST=None, **kw): 38 ## """Add a SCFolder.""" 39 ## ob = SCFolder(id, **kw) 40 ## return CPSBase_adder(container, ob, REQUEST=REQUEST) 41 ## 42 #####) 30 ## return "AcademicsFolder of %s" % (self.title) 31 32 security.declareProtected(ModifyPortalContent,"loadFacultiesFromCSV")###( 33 def loadFacultiesFromCSV(self): 34 """install Universityspecific Faculies from CSV values""" 35 #return 36 logger = logging.getLogger('loadfaculties') 37 logger.info('Start loading Faculties') 38 academics = self.portal_catalog({'meta_type': 'AcademicsFolder'})[-1].getObject() 39 try: 40 faculties = csv.DictReader(open("%s/import/faculty.csv" % i_home,"rb")) 41 except: 42 return 43 l = self.portal_catalog({'meta_type': "Faculty"}) 44 facs = {} 45 for f in l: 46 facs[f.id] = f.getObject() 47 for faculty in faculties: 48 logger.info('processing %(Session)s %(FacultyCode)s %(Description)s %(CollegeCode)s %(FacultyKey)s %(Status)s %(degree_grade)s %(Bankcode)s' % faculty) 49 fid = faculty['FacultyCode'] 50 f = facs.get(fid,None) 51 if f is None: 52 #self.log('Creating Faculty %(id)s = %(Title)s' % faculty) 53 logger.info('Creating Faculty with ID %(FacultyCode)s %(Description)s' % faculty) 54 academics.invokeFactory('Faculty', fid) 55 f = getattr(self,fid) 56 d = {'Title': faculty['Description']} 57 f.getContent().edit(mapping=d) 58 ###) 59 60 security.declareProtected(ModifyPortalContent,"yamlDumpFaculties")###( 61 def yamlDumpFaculties(self): 62 """dump Faculies to Yaml""" 63 #return 64 import yaml 65 logger = logging.getLogger('dumpfaculties') 66 logger.info('Start dumping Faculties') 67 academics = self.portal_catalog({'meta_type': 'AcademicsFolder'})[-1].getObject() 68 l = self.portal_catalog({'meta_type': "Faculty"}) 69 facs = {} 70 for f in l: 71 facs[f.id] = f.getObject() 72 for fid in facs.keys(): 73 faculty = facs.get(fid).aq_self 74 logger.info('dumping %s %s ' % (faculty.id, faculty.title)) 75 print yaml.dump(faculty) 76 77 ###) 78 79 80 security.declareProtected(ModifyPortalContent,"loadDepartmentsFromCSV")###( 81 def loadDepartmentsFromCSV(self): 82 """install Universityspecific Faculies from CSV values""" 83 #return 84 logger = logging.getLogger('loaddepartments') 85 try: 86 deps = csv.DictReader(open("%s/import/departments.csv" % i_home,"rb")) 87 except: 88 return 89 l = self.portal_catalog({'meta_type': "Faculty"}) 90 facs = {} 91 for f in l: 92 facs[f.id] = f.getObject() 93 for dep in deps: 94 logger.info('Processing %(Session)s %(DeptCode)s %(Description)s %(FacultyCode)s' % dep) 95 fid = dep['FacultyCode'] 96 f = facs.get(fid,None) 97 if f is None: 98 logger.info( "No Faculty with ID: %s" % fid) 99 else: 100 did = dep.get('DeptCode') 101 d = getattr(f,did,None) 102 if d is None or d.portal_type == "Faculty": 103 #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep) 104 logger.info('Creating Department %(DeptCode)s = %(Description)s' % dep) 105 f.invokeFactory('Department', did) 106 d = getattr(f,did) 107 dict = {'Title': dep['Description']} 108 d.getContent().edit(mapping=dict) 109 ###) 110 111 security.declareProtected(ModifyPortalContent,"loadCoursesFromCSV")###( 112 def loadCoursesFromCSV(self): 113 """install Universityspecific Courses from CSV values""" 114 #return 115 logger = logging.getLogger('loadcourses') 116 try: 117 courses = csv.DictReader(open("%s/import/courses.csv" % i_home,"rb")) 118 except: 119 return 120 l = self.portal_catalog({'meta_type': "Faculty"}) 121 facs = {} 122 for f in l: 123 facs[f.id] = f.getObject() 124 dl = self.portal_catalog({'meta_type': "Department"}) 125 deps = {} 126 for d in dl: 127 deps[d.id] = d.getObject() 128 cl = self.portal_catalog({'meta_type': "Course"}) 129 course_list = [ c.id for c in cl] 130 for course in courses: 131 logger.info('Processing %(CourseCode)s %(Description)s %(Credits)s %(Dept)s %(Semester)s %(Session)s %(PassMark)s %(CourseKey)s %(Category)s %(AdmStatus)s %(FORMERCODE)s' % course) 132 if course.get("FORMERCODE").endswith('BITS'): 133 continue 134 depid = course.get('Dept').upper() 135 if depid in deps.keys(): 136 dept= deps.get(depid) 137 ## elif depid in facs.keys(): 138 ## dept= facs.get(depid) 139 else: 140 logger.info("Dep %(Dept)s for Course %(CourseCode)s not found" % course) 141 continue 142 course_id = ''.join(re.split('\W+',course.get('CourseCode'))) 143 if len(course_id) == 3: 144 course_id = "%s000" % course_id 145 elif len(course_id) != 6: 146 logger.info("invalid course_code %(CourseCode)s" % course) 147 #print course_id,course.get('CourseCode'),course.get('Description') 148 continue 149 ## if course_id in course_list: 150 ## continue 151 c = getattr(dept,course_id,None) 152 if c is None: 153 #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep) 154 logger.info('Creating Course %(CourseCode)s %(Description)s in Department %(Dept)s' % course) 155 dept.invokeFactory('Course', course_id) 156 c = getattr(dept,course_id) 157 dict = {'Title': course['Description']} 158 dict['code'] = course_id 159 dict['org_code'] = course.get('CourseCode') 160 dict['credits'] = course.get('Credits') 161 dict['semester'] = course.get('Semester') 162 dict['session'] = course.get('Session') 163 dict['category'] = course.get('Category') 164 dict['passmark'] = course.get('PassMark') 165 c.getContent().edit(mapping=dict) 166 ###) 167 168 security.declareProtected(ModifyPortalContent,"loadCertificatesFromCSV")###( 169 def loadCertificatesFromCSV(self): 170 """install Universityspecific Certificates from CSV values""" 171 #return 172 logger = logging.getLogger('loadcertificates') 173 try: 174 certificates = csv.DictReader(open("%s/import/certificates.csv" % i_home,"rb")) 175 except: 176 return 177 f_ids = [f.id for f in self.portal_catalog({'meta_type': "Faculty"})] 178 #d_ids = [d.id for d in self.portal_catalog({'meta_type': "Department"})] 179 dl = self.portal_catalog({'meta_type': "Department"}) 180 deps = {} 181 for d in dl: 182 deps[d.id] = d.getObject() 183 for certificate in certificates: 184 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) 185 depid = certificate.get('Dept') 186 facid = certificate.get('Faculty') 187 if facid not in f_ids: 188 logger.info('Faculty %(Faculty)s for %(CertCode)s %(Description)s not found' % certificate) 189 continue 190 if not deps.has_key(depid): 191 logger.info('Department %(Dept)s for %(CertCode)s %(Description)s not found' % certificate) 192 continue 193 certificate_id = "%(category)s_%(Admstatus)s_%(Dept)s" % certificate 194 dep = deps[depid] 195 c = getattr(dep,certificate_id,None) 196 if c is None: 197 #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep) 198 logger.info('Creating certificate %(CertCode)s %(Description)s in Department %(Dept)s' % certificate) 199 dep.invokeFactory('Certificate', certificate_id) 200 c = getattr(dep,certificate_id) 201 dict = {'Title': certificate['Description']} 202 code = certificate.get('CertCode') 203 code = code.replace('.','') 204 code = code.replace('(','') 205 code = code.replace(')','') 206 code = code.replace('/','') 207 code = code.replace(' ','') 208 code = code.replace('_','') 209 dict['code'] = code 210 dict['faculty'] = certificate.get('Faculty') 211 dict['department'] = certificate.get('Dept') 212 dict['max_pass'] = certificate.get('MaxPass') 213 dict['max_load'] = certificate.get('MaxLoad') 214 dict['admin_status'] = certificate.get('Admstatus') 215 dict['category'] = certificate.get('category') 216 dict['m_prefix'] = certificate.get('MPREFIX') 217 dict['nr_years'] = int(certificate.get('Nyears')) 218 nc = certificate.get('Ncore','1') 219 try: 220 dict['n_core'] = int(nc) 221 except: 222 dict['n_core'] = 1 223 dict['start_level'] = certificate.get('StartLevel') 224 dict['end_level'] = certificate.get('endLevel') 225 dict['promotion_credits'] = certificate.get('PromotionCredits') 226 dict['probation_credits'] = certificate.get('ProbationCredits') 227 c.getContent().edit(mapping=dict) 228 ###) 229 230 security.declareProtected(ModifyPortalContent,"loadCertificateCoursesFromCSV")###( 231 def loadCertificateCoursesFromCSV(self): 232 """install Certificate Courses from CSV values""" 233 #return 234 logger = logging.getLogger('loadcertificatecourses') 235 try: 236 cert_courses = csv.DictReader(open("%s/import/course_level_courses.csv" % i_home,"rb")) 237 except: 238 return 239 d_ids = [d.id for d in self.portal_catalog({'meta_type': "Department"})] 240 for cert_course in cert_courses: 241 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) 242 depid = cert_course.get('Dept') 243 code = cert_course.get('CertCode') 244 code = code.replace('.','') 245 code = code.replace('(','') 246 code = code.replace(')','') 247 code = code.replace('/','') 248 code = code.replace(' ','') 249 code = code.replace('_','') 250 if cert_course.get('Session') != '2002/2003': 251 continue 252 certificate = self.portal_catalog({'meta_type': "Certificate", 253 'SearchableText': code}) 254 if not certificate: 255 print code 256 logger.info('CertCode %(CertCode)s for %(CosCode)s not found' % cert_course) 257 continue 258 certificate = certificate[-1].getObject() 259 certificate_code = certificate.getId() 260 if depid not in d_ids: 261 logger.info('Department %(Dept)s for %(CertCode)s not found' % cert_course) 262 continue 263 course_code = cert_course.get('CosCode') 264 level = cert_course.get('Level') 265 l = getattr(certificate,level,None) 266 if l is None: 267 #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep) 268 logger.info('Creating Level %(Level)s in certificate %(CertCode)s' % cert_course) 269 certificate.invokeFactory('StudyLevel', level) 270 l = getattr(certificate, level) 271 l.invokeFactory('Semester','first') 272 l.invokeFactory('Semester','second') 273 first_s = getattr(l,'first') 274 second_s = getattr(l,'second') 275 if cert_course.get('Semester') == '1': 276 semester = first_s 277 else: 278 semester = second_s 279 if hasattr(semester,course_code): 280 logger.info('Duplicate %(CosCode)s in Level %(Level)s' % cert_course) 281 continue 282 283 semester.invokeFactory('CertificateCourse',course_code) 284 cc = getattr(semester,course_code) 285 dict = {} 286 dict['code'] = cert_course.get('CosCode') 287 dict['certificate_code'] = code 288 dict['certificate_code_org'] = cert_course.get('CertCode') 289 dict['department'] = cert_course.get('Dept') 290 dict['admin_status'] = cert_course.get('Admstatus') 291 dict['session'] = cert_course.get('Session') 292 if cert_course.get('Core') != '': 293 dict['core_or_elective'] = True 294 else: 295 dict['core_or_elective'] = False 296 dict['level'] = cert_course.get('Level') 297 cc.getContent().edit(mapping=dict) 298 ###) 299 300 InitializeClass(AcademicsFolder) 301 302 def addAcademicsFolder(container, id, REQUEST=None, **kw): 303 """Add a AcademicsFolder.""" 304 ob = AcademicsFolder(id, **kw) 305 return CPSBase_adder(container, ob, REQUEST=REQUEST) 306 307 ###) 43 308 44 309 class Certificate(CPSDocument): ###( -
WAeUP_SRP/trunk/__init__.py
r274 r278 15 15 16 16 import Products.WAeUP_SRP.WAeUPPermissions 17 from Products.WAeUP_SRP.Academics import AcademicsFolder, addAcademicsFolder 17 18 from Products.WAeUP_SRP.University import University, addUniversity 18 19 from Products.WAeUP_SRP.Accommodation import AccoFolder, addAccoFolder … … 39 40 contentClasses = ( 40 41 University, 41 #SCFolder,42 AcademicsFolder, 42 43 Certificate, 43 44 CertificateCourse, … … 60 61 contentConstructors = ( 61 62 addUniversity, 62 #addSCFolder,63 addAcademicsFolder, 63 64 addCertificate, 64 65 addCertificateCourse, … … 81 82 fti = ( 82 83 {}, # University 83 #{}, #SCFolder84 {}, #AcademicsFolder 84 85 {}, #Certificate 85 86 {}, #CertificateCourse -
WAeUP_SRP/trunk/profiles/default/roots/uniportal.xml
r263 r278 2 2 <object name="uniportal"> 3 3 <property name="title">University Portal</property> 4 <property name=".cpsskins_theme">waeup_plain_theme</property> 4 5 <object name="academics" portal_type="AcademicsFolder" /> 5 6 <object name="accomodation" portal_type="AccoFolder" /> -
WAeUP_SRP/trunk/profiles/default/types/AcademicsFolder.xml
r238 r278 57 57 <permission value="University Manage"/> 58 58 </action> 59 <action title="IMPORT: Faculties" action_id="import_faculties" 60 category="object" condition_expr="" 61 url_expr="string:${object_url}/loadFacultiesFromCSV" visible="True"> 62 <permission value="Modify portal content"/> 63 </action> 64 <action title="Departments" action_id="import_departments" category="object" 65 condition_expr="" url_expr="string:${object_url}/loadDepartmentsFromCSV" 66 visible="True"> 67 <permission value="Modify portal content"/> 68 </action> 69 <action title="Courses" action_id="import_courses" category="object" 70 condition_expr="" url_expr="string:${object_url}/loadCoursesFromCSV" 71 visible="True"> 72 <permission value="Modify portal content"/> 73 </action> 74 <action title="Certificates" action_id="import_certificates" 75 category="object" condition_expr="" 76 url_expr="string:${object_url}/loadCertificatesFromCSV" visible="True"> 77 <permission value="Modify portal content"/> 78 </action> 79 <action title="CertificateCourses" action_id="import_certificate_courses" 80 category="object" condition_expr="" 81 url_expr="string:${object_url}/loadCertificateCoursesFromCSV" 82 visible="True"> 83 <permission value="Modify portal content"/> 84 </action> 85 <action title="EXPORT: Faculties" action_id="export_faculties" 86 category="object" condition_expr="" 87 url_expr="string:${object_url}/yamlDumpFaculties" visible="False"> 88 <permission value="Modify portal content"/> 89 </action> 59 90 </object>
Note: See TracChangeset for help on using the changeset viewer.