[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 |
---|
[319] | 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 |
---|
| 11 | #from Products.CPSCore.CPSBase import CPSBaseBTreeFolder as BaseBTreeFolder |
---|
| 12 | #from Products.CPSCore.CPSBase import CPSBaseBTreeDocument as BaseBTreeDocument |
---|
[200] | 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 | |
---|
[526] | 19 | import DateTime |
---|
[279] | 20 | import csv,re |
---|
| 21 | import logging |
---|
| 22 | import Globals |
---|
| 23 | p_home = Globals.package_home(globals()) |
---|
| 24 | i_home = Globals.INSTANCE_HOME |
---|
| 25 | |
---|
[361] | 26 | def makeCertificateCode(code): |
---|
| 27 | code = code.replace('.','') |
---|
| 28 | code = code.replace('(','') |
---|
| 29 | code = code.replace(')','') |
---|
| 30 | code = code.replace('/','') |
---|
| 31 | code = code.replace(' ','') |
---|
| 32 | code = code.replace('_','') |
---|
| 33 | return code |
---|
| 34 | |
---|
[278] | 35 | class AcademicsFolder(CPSDocument): ###( |
---|
| 36 | """ |
---|
[319] | 37 | WAeUP AcademicsFolder containing StudyCourses |
---|
[278] | 38 | """ |
---|
| 39 | meta_type = 'AcademicsFolder' |
---|
| 40 | portal_type = meta_type |
---|
| 41 | security = ClassSecurityInfo() |
---|
[440] | 42 | use_catalog_for_folder_contents = True |
---|
[278] | 43 | |
---|
[364] | 44 | security.declareProtected(View,"Title") |
---|
| 45 | def Title(self): |
---|
| 46 | """compose title""" |
---|
[382] | 47 | return "Academic Section" |
---|
[256] | 48 | |
---|
[351] | 49 | security.declareProtected(ModifyPortalContent,"loadFacultiesFromCSV")###( |
---|
[319] | 50 | def loadFacultiesFromCSV(self): |
---|
[278] | 51 | """install Universityspecific Faculies from CSV values""" |
---|
| 52 | #return |
---|
[549] | 53 | name = 'Faculties' |
---|
[282] | 54 | no_import = False |
---|
[563] | 55 | logger = logging.getLogger('%s_csv_import' % name) |
---|
| 56 | logger.info('Start loading from %s.csv' % name) |
---|
| 57 | academics = self.portal_catalog({'meta_type': 'AcademicsFolder'})[-1].getObject() |
---|
| 58 | try: |
---|
| 59 | faculties = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) |
---|
| 60 | except: |
---|
| 61 | logger.error('Error reading %s.csv' % name) |
---|
| 62 | return |
---|
| 63 | l = self.portal_catalog({'meta_type': "Faculty"}) |
---|
| 64 | facs = {} |
---|
| 65 | for f in l: |
---|
| 66 | facs[f.id] = f.getObject() |
---|
| 67 | fields = ("code", |
---|
| 68 | "review_state", |
---|
| 69 | "title", |
---|
| 70 | "title_prefix", |
---|
| 71 | "college_code", |
---|
| 72 | "degree_grade", |
---|
| 73 | "bank_code", |
---|
| 74 | ) |
---|
| 75 | format = ' '.join(['%%(%s)s ' % fn for fn in fields]) |
---|
| 76 | for faculty in faculties: |
---|
| 77 | processing = "processing %s" % format |
---|
| 78 | logger.info(processing % faculty) |
---|
| 79 | fid = faculty.get('code') |
---|
| 80 | f = facs.get(fid,None) |
---|
| 81 | if f is None: |
---|
| 82 | #self.log('Creating Faculty %(id)s = %(Title)s' % faculty) |
---|
| 83 | logger.info('Creating Faculty with ID %(code)s %(title)s' % faculty) |
---|
| 84 | academics.invokeFactory('Faculty', fid) |
---|
| 85 | f = getattr(self,fid) |
---|
| 86 | d = {'Title': faculty.get('title')} |
---|
| 87 | else: |
---|
| 88 | d = {} |
---|
| 89 | f.getContent().edit(mapping=faculty) |
---|
| 90 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
| 91 | ###) |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | security.declareProtected(ModifyPortalContent,"loadDepartmentsFromCSV")###( |
---|
| 95 | def loadDepartmentsFromCSV(self): |
---|
| 96 | """install Universityspecific Faculies from CSV values""" |
---|
| 97 | #return |
---|
| 98 | name = 'Departments' |
---|
| 99 | no_import = False |
---|
| 100 | logger = logging.getLogger('loaddepartments') |
---|
| 101 | fields = ("code", |
---|
| 102 | "review_state", |
---|
| 103 | "title", |
---|
| 104 | "title_prefix", |
---|
| 105 | "faculty_code", |
---|
| 106 | ) |
---|
| 107 | format = ' '.join(['%%(%s)s ' % fn for fn in fields]) |
---|
| 108 | try: |
---|
| 109 | deps = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) |
---|
| 110 | except: |
---|
| 111 | logger.error('Error reading %s.csv' % name) |
---|
| 112 | return |
---|
| 113 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
| 114 | heading = ' '.join(['"%s"' % fn for fn in fields]) |
---|
| 115 | no_import.write('%s\n' % heading) |
---|
| 116 | l = self.portal_catalog({'meta_type': "Faculty"}) |
---|
| 117 | facs = {} |
---|
| 118 | for f in l: |
---|
| 119 | facs[f.id] = f.getObject() |
---|
| 120 | for dep in deps: |
---|
| 121 | processing = "processing %s" % format |
---|
| 122 | logger.info(processing % dep) |
---|
| 123 | fid = dep['faculty_code'] |
---|
| 124 | f = facs.get(fid,None) |
---|
| 125 | if f is None: |
---|
| 126 | logger.info( "No Faculty with ID: %s" % fid) |
---|
| 127 | no_import.write( "No Faculty with ID: %s\n" % fid) |
---|
| 128 | no_import.write(format % dep + "\n") |
---|
| 129 | else: |
---|
| 130 | did = dep.get('code') |
---|
| 131 | d = getattr(f,did,None) |
---|
| 132 | if d is None or d.portal_type == "Faculty": |
---|
| 133 | logger.info('Creating Department %(code)s = %(title)s' % dep) |
---|
| 134 | f.invokeFactory('Department', did) |
---|
| 135 | d = getattr(f,did) |
---|
| 136 | d.invokeFactory('CoursesFolder','courses') |
---|
| 137 | courses = getattr(d,'courses') |
---|
| 138 | dict = {'Title': 'Courses'} |
---|
| 139 | courses.getContent().edit(mapping=dict) |
---|
| 140 | d.invokeFactory('CertificatesFolder','certificates') |
---|
| 141 | certificates = getattr(d,'certificates') |
---|
| 142 | dict = {'Title': 'Certificates'} |
---|
| 143 | certificates.getContent().edit(mapping=dict) |
---|
| 144 | d.getContent().edit(mapping=dep) |
---|
| 145 | |
---|
| 146 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
| 147 | ###) |
---|
| 148 | |
---|
| 149 | security.declareProtected(ModifyPortalContent,"loadCoursesFromCSV")###( |
---|
| 150 | def loadCoursesFromCSV(self): |
---|
| 151 | """install Universityspecific Courses from CSV values""" |
---|
| 152 | #return |
---|
| 153 | wf = self.portal_workflow |
---|
| 154 | name = 'Courses' |
---|
| 155 | no_import = False |
---|
| 156 | logger = logging.getLogger('loadcourses') |
---|
| 157 | fields = ("code", |
---|
| 158 | "review_state", |
---|
| 159 | "title", |
---|
| 160 | "faculty_code", |
---|
| 161 | "department_code", |
---|
| 162 | "credits", |
---|
| 163 | "org_code", |
---|
| 164 | "passmark", |
---|
| 165 | "semester", |
---|
| 166 | "session", |
---|
| 167 | ) |
---|
| 168 | format = ' '.join(['%%(%s)s ' % fn for fn in fields]) |
---|
| 169 | try: |
---|
| 170 | courses = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) |
---|
| 171 | except: |
---|
| 172 | logger.error('Error reading %s.csv' % name) |
---|
| 173 | return |
---|
| 174 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
| 175 | heading = ' '.join(['"%s"' % fn for fn in fields]) |
---|
| 176 | no_import.write('%s\n' % heading) |
---|
| 177 | l = self.portal_catalog({'meta_type': "Faculty"}) |
---|
| 178 | facs = {} |
---|
| 179 | for f in l: |
---|
| 180 | facs[f.id] = f.getObject() |
---|
| 181 | dl = self.portal_catalog({'meta_type': "Department"}) |
---|
| 182 | deps = {} |
---|
| 183 | for d in dl: |
---|
| 184 | deps[d.id] = d.getObject() |
---|
| 185 | cl = self.portal_catalog({'meta_type': "Course"}) |
---|
| 186 | course_list = [ c.id for c in cl] |
---|
| 187 | for course in courses: |
---|
| 188 | processing = "processing %s" % format |
---|
| 189 | logger.info(processing % course) |
---|
| 190 | depid = course.get('department_code').upper() |
---|
| 191 | if depid in deps.keys(): |
---|
| 192 | dept= deps.get(depid) |
---|
| 193 | else: |
---|
| 194 | msg = "Department %(department_code)s for Course %(code)s not found" % course |
---|
| 195 | logger.info(msg) |
---|
| 196 | no_import.write(msg) |
---|
| 197 | no_import.write(format % course + "\n") |
---|
| 198 | continue |
---|
| 199 | course_id = course.get('code') |
---|
| 200 | cf = dept.courses |
---|
| 201 | c = getattr(cf,course_id,None) |
---|
| 202 | if c is None: |
---|
| 203 | logger.info('Creating Course %(code)s %(title)s in Department %(department_code)s' % course) |
---|
| 204 | cf.invokeFactory('Course', course_id) |
---|
| 205 | c = getattr(cf,course_id) |
---|
| 206 | c.getContent().edit(mapping=course) |
---|
| 207 | review_state = course.get('review_state') |
---|
| 208 | if review_state == "checked" and wf.getInfoFor(c,'review_state',None) != 'checked': |
---|
| 209 | self.portal_workflow.doActionFor(c,'approve') |
---|
| 210 | |
---|
| 211 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
| 212 | ###) |
---|
| 213 | |
---|
| 214 | security.declareProtected(ModifyPortalContent,"loadCertificatesFromCSV")###( |
---|
| 215 | |
---|
| 216 | def loadCertificatesFromCSV(self): |
---|
| 217 | """install Universityspecific Certificates from CSV values""" |
---|
| 218 | #return |
---|
| 219 | name = 'Certificates' |
---|
| 220 | wf = self.portal_workflow |
---|
| 221 | no_import_list = [] |
---|
| 222 | logger = logging.getLogger('loadcertificates') |
---|
| 223 | fields = ("code", |
---|
| 224 | "review_state", |
---|
| 225 | "title", |
---|
| 226 | "faculty_code", |
---|
| 227 | "department_code", |
---|
| 228 | "category", |
---|
| 229 | "end_level", |
---|
| 230 | "m_prefix", |
---|
| 231 | "max_elect", |
---|
| 232 | "max_pass", |
---|
| 233 | "n_core", |
---|
| 234 | "nr_years", |
---|
| 235 | "original_code", |
---|
| 236 | "probation_credits", |
---|
| 237 | "promotion_credits", |
---|
| 238 | "start_level", |
---|
| 239 | "admin_status", |
---|
| 240 | ) |
---|
| 241 | format = ' '.join(['%%(%s)s ' % fn for fn in fields]) |
---|
| 242 | try: |
---|
| 243 | courses = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) |
---|
| 244 | except: |
---|
| 245 | logger.error('Error reading %s.csv' % name) |
---|
| 246 | return |
---|
| 247 | try: |
---|
| 248 | certificates = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) |
---|
| 249 | except: |
---|
| 250 | logger.error('Error reading %s.csv' % name) |
---|
| 251 | return |
---|
| 252 | f_ids = [f.id for f in self.portal_catalog({'meta_type': "Faculty"})] |
---|
| 253 | dl = self.portal_catalog({'meta_type': "Department"}) |
---|
| 254 | deps = {} |
---|
| 255 | for d in dl: |
---|
| 256 | deps[d.id] = d.getObject() |
---|
| 257 | for certificate in certificates: |
---|
| 258 | processing = "processing %s" % format |
---|
| 259 | logger.info(processing % certificate) |
---|
| 260 | depid = certificate.get('department_code') |
---|
| 261 | facid = certificate.get('faculty_code') |
---|
| 262 | if facid not in f_ids: |
---|
| 263 | msg = 'Faculty %(faculty_code)s for %(code)s %(title)s not found' % certificate |
---|
| 264 | logger.info(msg) |
---|
| 265 | no_import_list.append(msg) |
---|
| 266 | no_import_list.append(format % certificate + "\n") |
---|
| 267 | continue |
---|
| 268 | if not deps.has_key(depid): |
---|
| 269 | msg = 'Department %(department_code)s for %(code)s %(title)s not found' % certificate |
---|
| 270 | logger.info(msg) |
---|
| 271 | no_import_list.append(msg) |
---|
| 272 | no_import_list.append(format % certificate + "\n") |
---|
| 273 | continue |
---|
| 274 | dep = deps[depid] |
---|
| 275 | cf= dep.certificates |
---|
| 276 | code = certificate.get('code') |
---|
| 277 | certificate_id = code |
---|
| 278 | c = getattr(cf,certificate_id,None) |
---|
| 279 | if c is None: |
---|
| 280 | logger.info('Creating certificate %(code)s %(title)s in Department %(department_code)s' % certificate) |
---|
| 281 | cf.invokeFactory('Certificate', certificate_id) |
---|
| 282 | c = getattr(cf,certificate_id) |
---|
| 283 | c.getContent().edit(mapping=certificate) |
---|
| 284 | review_state = c.get('review_state') |
---|
| 285 | if review_state == "checked" and wf.getInfoFor(c,'review_state',None) != 'checked': |
---|
| 286 | self.portal_workflow.doActionFor(c,'approve') |
---|
| 287 | if no_import_list: |
---|
| 288 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
| 289 | heading = ' '.join(['"%s"' % fn for fn in fields]) |
---|
| 290 | no_import.write('%s\n' % heading) |
---|
| 291 | for line in no_import_list: |
---|
| 292 | no_import.write(line) |
---|
| 293 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
| 294 | ###) |
---|
| 295 | |
---|
| 296 | security.declareProtected(ModifyPortalContent,"loadCertificateCoursesFromCSV")###( |
---|
| 297 | def loadCertificateCoursesFromCSV(self): |
---|
| 298 | """install Certificate Courses from CSV values""" |
---|
| 299 | #return |
---|
| 300 | logger = logging.getLogger('loadcertificatecourses') |
---|
| 301 | name = 'CertificateCourses' |
---|
| 302 | wf = self.portal_workflow |
---|
| 303 | no_import_list = [] |
---|
| 304 | logger = logging.getLogger('loadcertificates') |
---|
| 305 | fields = ("code", |
---|
| 306 | "review_state", |
---|
| 307 | "faculty_code", |
---|
| 308 | "department_code", |
---|
| 309 | "certificate_code", |
---|
| 310 | "level", |
---|
| 311 | "semester", |
---|
| 312 | "core_or_elective", |
---|
| 313 | ) |
---|
| 314 | format = ' '.join(['%%(%s)s ' % fn for fn in fields]) |
---|
| 315 | try: |
---|
| 316 | cert_courses = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) |
---|
| 317 | except: |
---|
| 318 | logger.error('Error reading %s.csv' % name) |
---|
| 319 | return |
---|
| 320 | d_ids = [d.id for d in self.portal_catalog({'meta_type': "Department"})] |
---|
| 321 | c_ids = [c.id for c in self.portal_catalog({'meta_type': "Course"})] |
---|
| 322 | l = self.portal_catalog({'meta_type': "Certificate"}) |
---|
| 323 | certs = {} |
---|
| 324 | for f in l: |
---|
| 325 | certs[f.id] = f.getObject() |
---|
| 326 | for cert_course in cert_courses: |
---|
| 327 | processing = "processing %s" % format |
---|
| 328 | logger.info(processing % cert_course) |
---|
| 329 | depid = cert_course.get('department_code') |
---|
| 330 | course_code = cert_course.get('code') |
---|
| 331 | code = cert_course.get('certificate_code') |
---|
| 332 | if not code in certs.keys(): |
---|
| 333 | em = 'CertCode %(certificate_code)s for %(code)s not found\n' % cert_course |
---|
| 334 | logger.info(em) |
---|
| 335 | no_import_list.append(em) |
---|
| 336 | no_import_list.append(format % cert_course + "\n") |
---|
| 337 | continue |
---|
| 338 | certificate = certs[code] |
---|
| 339 | certificate_code = certificate.getId() |
---|
| 340 | if course_code not in c_ids: |
---|
| 341 | em = 'Course %(code)s for %(certificate_code)s Level %(level)s not found in Courses\n' % cert_course |
---|
| 342 | logger.info(em) |
---|
| 343 | no_import_list.append(em) |
---|
| 344 | no_import_list.append(format % cert_course + "\n") |
---|
| 345 | continue |
---|
| 346 | if depid not in d_ids: |
---|
| 347 | em = 'Department %(department_code)s for %(certificate_code)s not found\n' % cert_course |
---|
| 348 | logger.info(em) |
---|
| 349 | no_import_list.append(em) |
---|
| 350 | no_import_list.append(format % cert_course + "\n") |
---|
| 351 | continue |
---|
| 352 | level = cert_course.get('level') |
---|
| 353 | l = getattr(certificate,level,None) |
---|
| 354 | if l is None: |
---|
| 355 | logger.info('Creating Level %(level)s in certificate %(certificate_code)s' % cert_course) |
---|
| 356 | certificate.invokeFactory('StudyLevel', level) |
---|
| 357 | l = getattr(certificate, level) |
---|
| 358 | l.getContent().edit(mapping={'Title': "Level %s" % level}) |
---|
| 359 | certificate.orderObjects('id') |
---|
| 360 | if hasattr(l,course_code): |
---|
| 361 | msg = 'Duplicate %(code)s in Level %(level)s' % cert_course |
---|
| 362 | logger.info(msg) |
---|
| 363 | no_import_list.append(msg + "\n") |
---|
| 364 | no_import_list.append(format % cert_course + "\n") |
---|
| 365 | continue |
---|
| 366 | l.invokeFactory('CertificateCourse',course_code) |
---|
| 367 | logger.info('Creating CertificateCourse %(code)s in certificate %(certificate_code)s Level %(level)s' % cert_course) |
---|
| 368 | cc = getattr(l,course_code) |
---|
| 369 | semester = 'first' |
---|
| 370 | try: |
---|
| 371 | sem = int(cert_course.get('semester')) |
---|
| 372 | cert_course['semester'] = ('first','second')[sem - 1] |
---|
| 373 | except: |
---|
| 374 | pass |
---|
| 375 | cert_course['core_or_elective'] = eval(cert_course['core_or_elective']) |
---|
| 376 | cc.getContent().edit(mapping=cert_course) |
---|
| 377 | review_state = cc.get('review_state') |
---|
| 378 | if review_state == "checked" and wf.getInfoFor(cc,'review_state',None) != 'checked': |
---|
| 379 | self.portal_workflow.doActionFor(cc,'approve') |
---|
| 380 | if no_import_list: |
---|
| 381 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
| 382 | heading = ' '.join(['"%s"' % fn for fn in fields]) |
---|
| 383 | no_import.write('%s\n' % heading) |
---|
| 384 | for line in no_import_list: |
---|
| 385 | no_import.write(line) |
---|
| 386 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
| 387 | ###) |
---|
| 388 | |
---|
| 389 | security.declareProtected(ModifyPortalContent,"loadFacultiesFromOrgCSV")###( |
---|
| 390 | def loadFacultiesFromOrgCSV(self): |
---|
| 391 | """install Universityspecific Faculies from CSV values""" |
---|
| 392 | #return |
---|
| 393 | name = 'Faculties' |
---|
| 394 | no_import = False |
---|
[282] | 395 | logger = logging.getLogger('%s_import' % name) |
---|
| 396 | logger.info('Start loading from %s.csv' % name) |
---|
[278] | 397 | academics = self.portal_catalog({'meta_type': 'AcademicsFolder'})[-1].getObject() |
---|
| 398 | try: |
---|
[282] | 399 | faculties = csv.DictReader(open("%s/import/%s.csv" % (i_home,name),"rb")) |
---|
[278] | 400 | except: |
---|
[282] | 401 | logger.error('Error reading %s.csv' % name) |
---|
[278] | 402 | return |
---|
| 403 | l = self.portal_catalog({'meta_type': "Faculty"}) |
---|
| 404 | facs = {} |
---|
| 405 | for f in l: |
---|
| 406 | facs[f.id] = f.getObject() |
---|
| 407 | for faculty in faculties: |
---|
| 408 | logger.info('processing %(Session)s %(FacultyCode)s %(Description)s %(CollegeCode)s %(FacultyKey)s %(Status)s %(degree_grade)s %(Bankcode)s' % faculty) |
---|
| 409 | fid = faculty['FacultyCode'] |
---|
| 410 | f = facs.get(fid,None) |
---|
| 411 | if f is None: |
---|
| 412 | #self.log('Creating Faculty %(id)s = %(Title)s' % faculty) |
---|
| 413 | logger.info('Creating Faculty with ID %(FacultyCode)s %(Description)s' % faculty) |
---|
| 414 | academics.invokeFactory('Faculty', fid) |
---|
| 415 | f = getattr(self,fid) |
---|
[282] | 416 | d = {'Title': faculty['Description']} |
---|
| 417 | else: |
---|
[369] | 418 | d = {} |
---|
| 419 | d['bank_code'] = faculty.get("Bankcode") |
---|
| 420 | d["degree_grade"] = faculty.get("degree_grade") |
---|
[371] | 421 | d['institution_type'] = 'faculty' |
---|
[379] | 422 | d['Description'] = '' |
---|
| 423 | d['college_code'] = faculty.get('CollegeCode') |
---|
[369] | 424 | f.getContent().edit(mapping=d) |
---|
[526] | 425 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
[278] | 426 | ###) |
---|
| 427 | |
---|
| 428 | security.declareProtected(ModifyPortalContent,"yamlDumpFaculties")###( |
---|
[319] | 429 | def yamlDumpFaculties(self): |
---|
[278] | 430 | """dump Faculies to Yaml""" |
---|
| 431 | #return |
---|
| 432 | import yaml |
---|
| 433 | logger = logging.getLogger('dumpfaculties') |
---|
| 434 | logger.info('Start dumping Faculties') |
---|
| 435 | academics = self.portal_catalog({'meta_type': 'AcademicsFolder'})[-1].getObject() |
---|
| 436 | l = self.portal_catalog({'meta_type': "Faculty"}) |
---|
| 437 | facs = {} |
---|
| 438 | for f in l: |
---|
| 439 | facs[f.id] = f.getObject() |
---|
| 440 | for fid in facs.keys(): |
---|
| 441 | faculty = facs.get(fid).aq_self |
---|
| 442 | logger.info('dumping %s %s ' % (faculty.id, faculty.title)) |
---|
| 443 | print yaml.dump(faculty) |
---|
[526] | 444 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
[319] | 445 | |
---|
[278] | 446 | ###) |
---|
| 447 | |
---|
[563] | 448 | security.declareProtected(ModifyPortalContent,"loadDepartmentsFromOrgCSV")###( |
---|
| 449 | def loadDepartmentsFromOrgCSV(self): |
---|
[278] | 450 | """install Universityspecific Faculies from CSV values""" |
---|
| 451 | #return |
---|
[549] | 452 | name = 'Departments' |
---|
[282] | 453 | no_import = False |
---|
[278] | 454 | logger = logging.getLogger('loaddepartments') |
---|
| 455 | try: |
---|
| 456 | deps = csv.DictReader(open("%s/import/departments.csv" % i_home,"rb")) |
---|
| 457 | except: |
---|
[280] | 458 | logger.error('Error reading departments.csv') |
---|
[278] | 459 | return |
---|
| 460 | l = self.portal_catalog({'meta_type': "Faculty"}) |
---|
| 461 | facs = {} |
---|
| 462 | for f in l: |
---|
| 463 | facs[f.id] = f.getObject() |
---|
| 464 | for dep in deps: |
---|
| 465 | logger.info('Processing %(Session)s %(DeptCode)s %(Description)s %(FacultyCode)s' % dep) |
---|
| 466 | fid = dep['FacultyCode'] |
---|
| 467 | f = facs.get(fid,None) |
---|
| 468 | if f is None: |
---|
| 469 | logger.info( "No Faculty with ID: %s" % fid) |
---|
[282] | 470 | if not no_import: |
---|
| 471 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
[287] | 472 | no_import.write('"Session","DeptCode","Description","FacultyCode"\n') |
---|
| 473 | no_import.write( "No Faculty with ID: %s\n" % fid) |
---|
[282] | 474 | no_import.write('"%(Session)s","%(DeptCode)s","%(Description)s","%(FacultyCode)s"\n' % dep) |
---|
[278] | 475 | else: |
---|
| 476 | did = dep.get('DeptCode') |
---|
| 477 | d = getattr(f,did,None) |
---|
| 478 | if d is None or d.portal_type == "Faculty": |
---|
| 479 | logger.info('Creating Department %(DeptCode)s = %(Description)s' % dep) |
---|
| 480 | f.invokeFactory('Department', did) |
---|
| 481 | d = getattr(f,did) |
---|
[295] | 482 | dict = {'Title': dep['Description']} |
---|
| 483 | d.getContent().edit(mapping=dict) |
---|
[319] | 484 | d.invokeFactory('CoursesFolder','courses') |
---|
[324] | 485 | courses = getattr(d,'courses') |
---|
[295] | 486 | dict = {'Title': 'Courses'} |
---|
| 487 | courses.getContent().edit(mapping=dict) |
---|
[319] | 488 | d.invokeFactory('CertificatesFolder','certificates') |
---|
[321] | 489 | certificates = getattr(d,'certificates') |
---|
[295] | 490 | dict = {'Title': 'Certificates'} |
---|
| 491 | certificates.getContent().edit(mapping=dict) |
---|
[526] | 492 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
[278] | 493 | ###) |
---|
[319] | 494 | |
---|
[563] | 495 | security.declareProtected(ModifyPortalContent,"loadCoursesFromOrgCSV")###( |
---|
| 496 | def loadCoursesFromOrgCSV(self): |
---|
[278] | 497 | """install Universityspecific Courses from CSV values""" |
---|
| 498 | #return |
---|
[549] | 499 | name = 'Courses' |
---|
[282] | 500 | no_import = False |
---|
[278] | 501 | logger = logging.getLogger('loadcourses') |
---|
| 502 | try: |
---|
| 503 | courses = csv.DictReader(open("%s/import/courses.csv" % i_home,"rb")) |
---|
| 504 | except: |
---|
[280] | 505 | logger.error('Error reading courses.csv') |
---|
[278] | 506 | return |
---|
| 507 | l = self.portal_catalog({'meta_type': "Faculty"}) |
---|
| 508 | facs = {} |
---|
| 509 | for f in l: |
---|
| 510 | facs[f.id] = f.getObject() |
---|
| 511 | dl = self.portal_catalog({'meta_type': "Department"}) |
---|
| 512 | deps = {} |
---|
| 513 | for d in dl: |
---|
| 514 | deps[d.id] = d.getObject() |
---|
| 515 | cl = self.portal_catalog({'meta_type': "Course"}) |
---|
| 516 | course_list = [ c.id for c in cl] |
---|
| 517 | for course in courses: |
---|
[296] | 518 | logger.info('Processing %(CourseCode)s %(Description)s %(Credits)s %(Dept)s %(Semester)s %(Session)s %(PassMark)s %(Category)s %(AdmStatus)s' % course) |
---|
[282] | 519 | ## if course.get("FORMERCODE").endswith('BITS'): |
---|
| 520 | ## continue |
---|
[278] | 521 | depid = course.get('Dept').upper() |
---|
| 522 | if depid in deps.keys(): |
---|
| 523 | dept= deps.get(depid) |
---|
| 524 | ## elif depid in facs.keys(): |
---|
| 525 | ## dept= facs.get(depid) |
---|
| 526 | else: |
---|
| 527 | logger.info("Dep %(Dept)s for Course %(CourseCode)s not found" % course) |
---|
[282] | 528 | if not no_import: |
---|
| 529 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
[296] | 530 | no_import.write('"CourseCode","Description","Credits","Dept","Semester","Session","PassMark","Category","AdmStatus"\n') |
---|
[287] | 531 | no_import.write("Dep %(Dept)s for Course %(CourseCode)s not found\n" % course) |
---|
[296] | 532 | no_import.write('"%(CourseCode)s","%(Description)s","%(Credits)s","%(Dept)s","%(Semester)s","%(Session)s","%(PassMark)s","%(Category)s","%(AdmStatus)s"\n' % course) |
---|
[278] | 533 | continue |
---|
| 534 | course_id = ''.join(re.split('\W+',course.get('CourseCode'))) |
---|
| 535 | if len(course_id) == 3: |
---|
| 536 | course_id = "%s000" % course_id |
---|
[296] | 537 | elif len(course_id) > 10: |
---|
[278] | 538 | logger.info("invalid course_code %(CourseCode)s" % course) |
---|
[282] | 539 | if not no_import: |
---|
| 540 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
[296] | 541 | no_import.write('"CourseCode","Description","Credits","Dept","Semester","Session","PassMark","Category","AdmStatus"\n') |
---|
[287] | 542 | no_import.write("invalid course_code %(CourseCode)s\n" % course) |
---|
[296] | 543 | no_import.write('"%(CourseCode)s","%(Description)s","%(Credits)s","%(Dept)s","%(Semester)s","%(Session)s","%(PassMark)s","%(Category)s","%(AdmStatus)s"\n' % course) |
---|
[278] | 544 | continue |
---|
[323] | 545 | courses = dept.courses |
---|
[295] | 546 | c = getattr(courses,course_id,None) |
---|
[278] | 547 | if c is None: |
---|
| 548 | logger.info('Creating Course %(CourseCode)s %(Description)s in Department %(Dept)s' % course) |
---|
[295] | 549 | courses.invokeFactory('Course', course_id) |
---|
| 550 | c = getattr(courses,course_id) |
---|
[278] | 551 | dict = {'Title': course['Description']} |
---|
| 552 | dict['code'] = course_id |
---|
[319] | 553 | dict['org_code'] = course.get('CourseCode') |
---|
[282] | 554 | dict['credits'] = course.get('Credits') |
---|
[278] | 555 | dict['semester'] = course.get('Semester') |
---|
| 556 | dict['session'] = course.get('Session') |
---|
| 557 | dict['category'] = course.get('Category') |
---|
[379] | 558 | dict['adm_status'] = course.get('AdmStatus') |
---|
| 559 | dict['former_code'] = course.get('FORMERCODE') |
---|
[282] | 560 | pm = course.get('PassMark') |
---|
| 561 | if pm.find(',') > -1: |
---|
| 562 | pm.replace(',','.') |
---|
| 563 | elif pm == "": |
---|
| 564 | pm = "0.0" |
---|
| 565 | try: |
---|
| 566 | dict['passmark'] = int(float(pm)) |
---|
| 567 | except: |
---|
| 568 | dict['passmark'] = 0 |
---|
[278] | 569 | c.getContent().edit(mapping=dict) |
---|
[526] | 570 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
[278] | 571 | ###) |
---|
| 572 | |
---|
[563] | 573 | security.declareProtected(ModifyPortalContent,"loadCertificatesFromOrgCSV")###( |
---|
[290] | 574 | |
---|
[563] | 575 | def loadCertificatesFromOrgCSV(self): |
---|
[278] | 576 | """install Universityspecific Certificates from CSV values""" |
---|
| 577 | #return |
---|
[549] | 578 | name = 'Certificates' |
---|
[287] | 579 | no_import = False |
---|
[278] | 580 | logger = logging.getLogger('loadcertificates') |
---|
| 581 | try: |
---|
| 582 | certificates = csv.DictReader(open("%s/import/certificates.csv" % i_home,"rb")) |
---|
| 583 | except: |
---|
[280] | 584 | logger.error('Error reading certificates.csv') |
---|
[278] | 585 | return |
---|
| 586 | f_ids = [f.id for f in self.portal_catalog({'meta_type': "Faculty"})] |
---|
| 587 | #d_ids = [d.id for d in self.portal_catalog({'meta_type': "Department"})] |
---|
| 588 | dl = self.portal_catalog({'meta_type': "Department"}) |
---|
| 589 | deps = {} |
---|
| 590 | for d in dl: |
---|
| 591 | deps[d.id] = d.getObject() |
---|
| 592 | for certificate in certificates: |
---|
| 593 | 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) |
---|
| 594 | depid = certificate.get('Dept') |
---|
| 595 | facid = certificate.get('Faculty') |
---|
| 596 | if facid not in f_ids: |
---|
| 597 | logger.info('Faculty %(Faculty)s for %(CertCode)s %(Description)s not found' % certificate) |
---|
[287] | 598 | if not no_import: |
---|
| 599 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
| 600 | no_import.write('"CertCode","Description","Faculty","MaxPass","MaxLoad","session","PromotionCredits","Probationcredits","StartLevel","endLevel","Nyears","Ncore","MaxElect","MPREFIX","Dept","Admstatus","category"\n') |
---|
| 601 | no_import.write('Faculty %(Faculty)s for %(CertCode)s %(Description)s not found\n' % certificate) |
---|
| 602 | 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] | 603 | continue |
---|
| 604 | if not deps.has_key(depid): |
---|
| 605 | logger.info('Department %(Dept)s for %(CertCode)s %(Description)s not found' % certificate) |
---|
[287] | 606 | if not no_import: |
---|
| 607 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
| 608 | no_import.write('"CertCode","Description","Faculty","MaxPass","MaxLoad","session","PromotionCredits","Probationcredits","StartLevel","endLevel","Nyears","Ncore","MaxElect","MPREFIX","Dept","Admstatus","category"\n') |
---|
| 609 | no_import.write('Department %(Dept)s for %(CertCode)s %(Description)s not found\n' % certificate) |
---|
| 610 | 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] | 611 | continue |
---|
[296] | 612 | #certificate_id = "%(category)s_%(Admstatus)s_%(Dept)s" % certificate |
---|
[278] | 613 | dep = deps[depid] |
---|
[323] | 614 | certificates = dep.certificates |
---|
[361] | 615 | code = makeCertificateCode(certificate.get('CertCode')) |
---|
[296] | 616 | certificate_id = code |
---|
[295] | 617 | c = getattr(certificates,certificate_id,None) |
---|
[278] | 618 | if c is None: |
---|
| 619 | #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep) |
---|
| 620 | logger.info('Creating certificate %(CertCode)s %(Description)s in Department %(Dept)s' % certificate) |
---|
[295] | 621 | certificates.invokeFactory('Certificate', certificate_id) |
---|
| 622 | c = getattr(certificates,certificate_id) |
---|
[370] | 623 | dict = {'Title': certificate['Description']} |
---|
| 624 | dict['code'] = code |
---|
| 625 | dict['faculty'] = certificate.get('Faculty') |
---|
| 626 | dict['department'] = certificate.get('Dept') |
---|
| 627 | dict['max_pass'] = certificate.get('MaxPass') |
---|
| 628 | dict['max_load'] = certificate.get('MaxLoad') |
---|
| 629 | dict['admin_status'] = certificate.get('Admstatus') |
---|
| 630 | dict['category'] = certificate.get('category') |
---|
| 631 | dict['m_prefix'] = certificate.get('MPREFIX') |
---|
| 632 | dict['nr_years'] = int(certificate.get('Nyears')) |
---|
| 633 | nc = certificate.get('Ncore','1') |
---|
| 634 | try: |
---|
| 635 | dict['n_core'] = int(nc) |
---|
| 636 | except: |
---|
| 637 | dict['n_core'] = 1 |
---|
| 638 | dict['start_level'] = certificate.get('StartLevel') |
---|
| 639 | dict['end_level'] = certificate.get('endLevel') |
---|
| 640 | dict['promotion_credits'] = certificate.get('PromotionCredits') |
---|
| 641 | dict['probation_credits'] = certificate.get('ProbationCredits') |
---|
| 642 | else: |
---|
| 643 | dict = {} |
---|
| 644 | dict['original_code'] = certificate.get('CertCode') |
---|
[382] | 645 | print |
---|
[278] | 646 | c.getContent().edit(mapping=dict) |
---|
[526] | 647 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
[278] | 648 | ###) |
---|
| 649 | |
---|
[563] | 650 | security.declareProtected(ModifyPortalContent,"loadCertificateCoursesFromOrgCSV")###( |
---|
| 651 | def loadCertificateCoursesFromOrgCSV(self): |
---|
[278] | 652 | """install Certificate Courses from CSV values""" |
---|
| 653 | #return |
---|
| 654 | logger = logging.getLogger('loadcertificatecourses') |
---|
[549] | 655 | name = 'Certificate_courses' |
---|
[290] | 656 | no_import = False |
---|
[278] | 657 | try: |
---|
| 658 | cert_courses = csv.DictReader(open("%s/import/course_level_courses.csv" % i_home,"rb")) |
---|
| 659 | except: |
---|
[280] | 660 | logger.error('Error reading course_level_courses.csv') |
---|
[278] | 661 | return |
---|
| 662 | d_ids = [d.id for d in self.portal_catalog({'meta_type': "Department"})] |
---|
[290] | 663 | c_ids = [c.id for c in self.portal_catalog({'meta_type': "Course"})] |
---|
[296] | 664 | l = self.portal_catalog({'meta_type': "Certificate"}) |
---|
| 665 | certs = {} |
---|
| 666 | for f in l: |
---|
| 667 | certs[f.id] = f.getObject() |
---|
[278] | 668 | for cert_course in cert_courses: |
---|
[296] | 669 | 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) |
---|
[278] | 670 | depid = cert_course.get('Dept') |
---|
[290] | 671 | course_code = cert_course.get('CosCode') |
---|
[278] | 672 | code = cert_course.get('CertCode') |
---|
| 673 | code = code.replace('.','') |
---|
| 674 | code = code.replace('(','') |
---|
| 675 | code = code.replace(')','') |
---|
| 676 | code = code.replace('/','') |
---|
| 677 | code = code.replace(' ','') |
---|
| 678 | code = code.replace('_','') |
---|
[290] | 679 | ## if cert_course.get('Session') != '2002/2003': |
---|
| 680 | ## continue |
---|
[296] | 681 | ## certificate = self.portal_catalog({'meta_type': "Certificate", |
---|
| 682 | ## 'SearchableText': code}) |
---|
| 683 | ## if not certificate: |
---|
| 684 | if not code in certs.keys(): |
---|
[290] | 685 | #print code |
---|
| 686 | em = 'CertCode %(CertCode)s for %(CosCode)s not found\n' % cert_course |
---|
| 687 | logger.info(em) |
---|
| 688 | if not no_import: |
---|
| 689 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
[296] | 690 | no_import.write('"CosCode","CertCode","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n') |
---|
[290] | 691 | no_import.write(em) |
---|
[296] | 692 | 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) |
---|
[278] | 693 | continue |
---|
[309] | 694 | certificate = certs[code] |
---|
[278] | 695 | certificate_code = certificate.getId() |
---|
[290] | 696 | if course_code not in c_ids: |
---|
| 697 | em = 'CorseCode %(CosCode)s for %(CertCode)s not found in Courses\n' % cert_course |
---|
| 698 | logger.info(em) |
---|
| 699 | if not no_import: |
---|
| 700 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
[296] | 701 | no_import.write('"CosCode","CertCode","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n') |
---|
[290] | 702 | no_import.write(em) |
---|
[296] | 703 | 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) |
---|
[290] | 704 | continue |
---|
[278] | 705 | if depid not in d_ids: |
---|
[290] | 706 | em = 'Department %(Dept)s for %(CertCode)s not found\n' % cert_course |
---|
| 707 | logger.info(em) |
---|
| 708 | if not no_import: |
---|
| 709 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
[296] | 710 | no_import.write('"CosCode","CertCode","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n') |
---|
[290] | 711 | no_import.write(em) |
---|
[296] | 712 | 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) |
---|
[278] | 713 | continue |
---|
| 714 | level = cert_course.get('Level') |
---|
| 715 | l = getattr(certificate,level,None) |
---|
| 716 | if l is None: |
---|
| 717 | #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep) |
---|
| 718 | logger.info('Creating Level %(Level)s in certificate %(CertCode)s' % cert_course) |
---|
| 719 | certificate.invokeFactory('StudyLevel', level) |
---|
| 720 | l = getattr(certificate, level) |
---|
[329] | 721 | l.getContent().edit(mapping={'Title': "Level %s" % level}) |
---|
[278] | 722 | l.invokeFactory('Semester','first') |
---|
| 723 | l.invokeFactory('Semester','second') |
---|
[290] | 724 | certificate.orderObjects('id') |
---|
[278] | 725 | first_s = getattr(l,'first') |
---|
[332] | 726 | first_s.getContent().edit(mapping={'Title': 'First Semester'}) |
---|
[278] | 727 | second_s = getattr(l,'second') |
---|
[332] | 728 | second_s.getContent().edit(mapping={'Title': 'Second Semester'}) |
---|
[278] | 729 | if cert_course.get('Semester') == '1': |
---|
| 730 | semester = first_s |
---|
| 731 | else: |
---|
| 732 | semester = second_s |
---|
| 733 | if hasattr(semester,course_code): |
---|
| 734 | logger.info('Duplicate %(CosCode)s in Level %(Level)s' % cert_course) |
---|
[290] | 735 | if not no_import: |
---|
| 736 | no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w") |
---|
[296] | 737 | no_import.write('"CosCode","CertCode","Session","Level","Core","Elective","Mandatory","AdmStatus","Dept","Semester"\n') |
---|
[295] | 738 | ## no_import.write('Duplicate %(CosCode)s in Level %(Level)s' % cert_course) |
---|
[296] | 739 | ## 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) |
---|
[278] | 740 | continue |
---|
| 741 | semester.invokeFactory('CertificateCourse',course_code) |
---|
| 742 | cc = getattr(semester,course_code) |
---|
| 743 | dict = {} |
---|
| 744 | dict['code'] = cert_course.get('CosCode') |
---|
| 745 | dict['certificate_code'] = code |
---|
[319] | 746 | dict['certificate_code_org'] = cert_course.get('CertCode') |
---|
| 747 | dict['department'] = cert_course.get('Dept') |
---|
[278] | 748 | dict['admin_status'] = cert_course.get('Admstatus') |
---|
| 749 | dict['session'] = cert_course.get('Session') |
---|
| 750 | if cert_course.get('Core') != '': |
---|
| 751 | dict['core_or_elective'] = True |
---|
| 752 | else: |
---|
| 753 | dict['core_or_elective'] = False |
---|
| 754 | dict['level'] = cert_course.get('Level') |
---|
[295] | 755 | cc.getContent().edit(mapping=dict) |
---|
[526] | 756 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
[278] | 757 | ###) |
---|
| 758 | |
---|
[526] | 759 | security.declareProtected(ModifyPortalContent,"exportFacultiesToCSV")###( |
---|
| 760 | def exportFacultiesToCSV(self): |
---|
| 761 | """export Faculies to CSV""" |
---|
| 762 | #return |
---|
[549] | 763 | name = 'Faculties' |
---|
[526] | 764 | no_import = False |
---|
| 765 | logger = logging.getLogger('%s_export' % name) |
---|
| 766 | current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") |
---|
| 767 | logger.info('Start exporting %(name)s to %(name)s_%(current)s.csv' % vars()) |
---|
[557] | 768 | objects = [f.getObject() for f in self.portal_catalog({'meta_type': 'Faculty'})] |
---|
[526] | 769 | export = [] |
---|
| 770 | export.append('"code","review_state","title","title_prefix","college_code","degree_grade","bank_code"') |
---|
| 771 | for obj in objects: |
---|
| 772 | logger.info('exporting %s %s ' % (obj.id, obj.title)) |
---|
| 773 | obj_d = obj.getContent() |
---|
| 774 | di = {} |
---|
| 775 | di['code'] = obj_d.code |
---|
| 776 | di['title'] = obj_d.title |
---|
| 777 | di['title_prefix'] = obj_d.title_prefix |
---|
| 778 | di['college_code'] = obj_d.college_code |
---|
| 779 | di['degree_grade'] = obj_d.degree_grade |
---|
| 780 | di['bank_code'] = obj_d.bank_code |
---|
| 781 | di['code'] = di['code'] or obj.id |
---|
| 782 | di['review_state'] = self.portal_workflow.getInfoFor(obj,'review_state','no_state') |
---|
| 783 | export.append('"%(code)s","%(review_state)s","%(title)s","%(title_prefix)s","%(college_code)s","%(degree_grade)s","%(bank_code)s"' % di) |
---|
| 784 | open("%s/import/%s-%s.csv" % (i_home,name,current),"w+").write('\n'.join(export)) |
---|
| 785 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
| 786 | |
---|
| 787 | ###) |
---|
| 788 | |
---|
| 789 | security.declareProtected(ModifyPortalContent,"exportDepartmentsToCSV")###( |
---|
| 790 | def exportDepartmentsToCSV(self): |
---|
| 791 | """export Faculies to CSV""" |
---|
| 792 | #return |
---|
| 793 | import copy |
---|
[549] | 794 | name = 'Departments' |
---|
[526] | 795 | no_import = False |
---|
| 796 | logger = logging.getLogger('%s_export' % name) |
---|
| 797 | current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") |
---|
| 798 | logger.info('Start exporting %(name)s to %(name)s_%(current)s.csv' % vars()) |
---|
| 799 | faculties = [f.getObject() for f in self.portal_catalog({'meta_type': 'Faculty'})] |
---|
| 800 | export = [] |
---|
| 801 | export.append('"code","review_state","title","title_prefix","faculty_code"') |
---|
| 802 | #import pdb;pdb.set_trace() |
---|
| 803 | for faculty in faculties: |
---|
| 804 | di = {} |
---|
| 805 | di['faculty_code'] = faculty.id |
---|
| 806 | for department in faculty.objectValues(): |
---|
| 807 | department_d = department.getContent() |
---|
| 808 | try: |
---|
| 809 | di['code'] = department_d.code |
---|
| 810 | di['title'] = department_d.title |
---|
| 811 | di['title_prefix'] = department_d.title_prefix |
---|
| 812 | di['code'] = di['code'] or department.id |
---|
| 813 | di['review_state'] = self.portal_workflow.getInfoFor(department,'review_state','no_state') |
---|
[527] | 814 | export.append('"%(code)s","%(review_state)s","%(title)s","%(title_prefix)s","%(faculty_code)s"' % di) |
---|
[526] | 815 | logger.info('exporting %s %s ' % (department.id, department.title)) |
---|
| 816 | except: |
---|
| 817 | logger.info('could not export %s %s ' % (department.id, department.title)) |
---|
| 818 | continue |
---|
| 819 | open("%s/import/%s-%s.csv" % (i_home,name,current),"w+").write('\n'.join(export)) |
---|
| 820 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
| 821 | ###) |
---|
| 822 | |
---|
| 823 | security.declareProtected(ModifyPortalContent,"exportCoursesToCSV")###( |
---|
| 824 | def exportCoursesToCSV(self): |
---|
| 825 | """export Courses to CSV""" |
---|
| 826 | #return |
---|
[549] | 827 | name = 'Courses' |
---|
[526] | 828 | no_import = False |
---|
| 829 | logger = logging.getLogger('%s_export' % name) |
---|
| 830 | current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") |
---|
| 831 | logger.info('Start exporting %(name)s to %(name)s_%(current)s.csv' % vars()) |
---|
| 832 | faculties = [f.getObject() for f in self.portal_catalog({'meta_type': 'Faculty'})] |
---|
| 833 | export = [] |
---|
| 834 | heading = '"code","review_state","title","faculty_code","department_code",' |
---|
| 835 | heading += '"credits","org_code","passmark","semester","session"' |
---|
| 836 | dataline = '"%(code)s","%(review_state)s","%(title)s","%(faculty_code)s","%(department_code)s",' |
---|
| 837 | dataline += '"%(credits)s","%(org_code)s","%(passmark)s","%(semester)s","%(session)s"' |
---|
| 838 | export.append(heading) |
---|
| 839 | #import pdb;pdb.set_trace() |
---|
| 840 | for faculty in faculties: |
---|
| 841 | di = {} |
---|
| 842 | di['faculty_code'] = faculty.id |
---|
| 843 | for department in faculty.objectValues(): |
---|
| 844 | di['department_code'] = department.id |
---|
[527] | 845 | for course in department.courses.objectValues(): |
---|
[526] | 846 | course_d = course.getContent() |
---|
| 847 | try: |
---|
| 848 | di['code'] = course_d.code |
---|
| 849 | di['title'] = course_d.title |
---|
| 850 | di['category'] = course_d.category |
---|
| 851 | di['adm_status'] = course_d.adm_status |
---|
| 852 | di['credits'] = course_d.credits |
---|
| 853 | di['former_code'] = course_d.former_code |
---|
| 854 | di['org_code'] = course_d.org_code |
---|
| 855 | di['passmark'] = course_d.passmark |
---|
| 856 | di['semester'] = course_d.semester |
---|
| 857 | di['session'] = course_d.session |
---|
| 858 | di['code'] = di['code'] or course.id |
---|
| 859 | di['review_state'] = self.portal_workflow.getInfoFor(course,'review_state','no_state') |
---|
| 860 | export.append(dataline % di) |
---|
| 861 | logger.info('exporting %s %s ' % (course.id, course.title)) |
---|
| 862 | except: |
---|
| 863 | logger.info('could not export %s %s ' % (course.id, course.title)) |
---|
| 864 | continue |
---|
| 865 | open("%s/import/%s-%s.csv" % (i_home,name,current),"w+").write('\n'.join(export)) |
---|
| 866 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
| 867 | ###) |
---|
| 868 | |
---|
| 869 | security.declareProtected(ModifyPortalContent,"exportCertificatesToCSV")###( |
---|
| 870 | def exportCertificatesToCSV(self): |
---|
| 871 | """export Certificates to CSV""" |
---|
| 872 | #return |
---|
[549] | 873 | name = 'Certificates' |
---|
[526] | 874 | no_import = False |
---|
| 875 | logger = logging.getLogger('%s_export' % name) |
---|
| 876 | current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") |
---|
| 877 | logger.info('Start exporting %(name)s to %(name)s_%(current)s.csv' % vars()) |
---|
| 878 | faculties = [f.getObject() for f in self.portal_catalog({'meta_type': 'Faculty'})] |
---|
| 879 | export = [] |
---|
| 880 | heading = '"code","review_state","title","faculty_code","department_code",' |
---|
| 881 | heading += '"category","end_level","m_prefix","max_elect","max_pass",' |
---|
| 882 | heading += '"n_core","nr_years","original_code","probation_credits",' |
---|
| 883 | heading += '"promotion_credits","start_level","admin_status"' |
---|
[527] | 884 | dataline = '"%(code)s","%(review_state)s","%(title)s","%(faculty_code)s","%(department_code)s",' |
---|
[526] | 885 | dataline += '"%(category)s","%(end_level)s","%(m_prefix)s","%(max_elect)s","%(max_pass)s",' |
---|
| 886 | dataline += '"%(n_core)s","%(nr_years)s","%(original_code)s","%(probation_credits)s",' |
---|
| 887 | dataline += '"%(promotion_credits)s","%(start_level)s","%(admin_status)s"' |
---|
| 888 | export.append(heading) |
---|
| 889 | #import pdb;pdb.set_trace() |
---|
| 890 | for faculty in faculties: |
---|
| 891 | di = {} |
---|
| 892 | di['faculty_code'] = faculty.id |
---|
| 893 | for department in faculty.objectValues(): |
---|
| 894 | di['department_code'] = department.id |
---|
[527] | 895 | for certificate in department.certificates.objectValues(): |
---|
[526] | 896 | certificate_d = certificate.getContent() |
---|
[529] | 897 | di['code'] = getattr(certificate_d,'code',None) |
---|
| 898 | di['title'] = getattr(certificate_d,'title',None) |
---|
| 899 | di['category'] = getattr(certificate_d,'category',None) |
---|
| 900 | di['admin_status'] = getattr(certificate_d,'admin_status',None) |
---|
| 901 | di['end_level'] = getattr(certificate_d,'end_level',None) |
---|
| 902 | di['m_prefix'] = getattr(certificate_d,'m_prefix',None) |
---|
| 903 | di['max_elect'] = getattr(certificate_d,'max_elect',None) |
---|
| 904 | di['max_load'] = getattr(certificate_d,'max_load',None) |
---|
| 905 | di['max_pass'] = getattr(certificate_d,'max_pass',None) |
---|
| 906 | di['n_core'] = getattr(certificate_d,'n_core',None) |
---|
| 907 | di['nr_years'] = getattr(certificate_d,'nr_years',None) |
---|
| 908 | di['original_code'] = getattr(certificate_d,'original_code',None) |
---|
| 909 | di['probation_credits'] = getattr(certificate_d,'probation_credits',None) |
---|
| 910 | di['promotion_credits'] = getattr(certificate_d,'promotion_credits',None) |
---|
| 911 | di['start_level'] = getattr(certificate_d,'start_level',None) |
---|
[526] | 912 | di['code'] = di['code'] or certificate.id |
---|
| 913 | di['review_state'] = self.portal_workflow.getInfoFor(certificate,'review_state','no_state') |
---|
| 914 | try: |
---|
| 915 | export.append(dataline % di) |
---|
| 916 | logger.info('exporting %s %s ' % (certificate.id, certificate.title)) |
---|
| 917 | except: |
---|
| 918 | logger.info('could not export %s %s ' % (certificate.id, certificate.title)) |
---|
| 919 | continue |
---|
| 920 | open("%s/import/%s-%s.csv" % (i_home,name,current),"w+").write('\n'.join(export)) |
---|
| 921 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
| 922 | ###) |
---|
| 923 | |
---|
| 924 | security.declareProtected(ModifyPortalContent,"exportCertificateCoursesToCSV")###( |
---|
| 925 | def exportCertificateCoursesToCSV(self): |
---|
| 926 | """export CertificateCourses to CSV""" |
---|
| 927 | #return |
---|
[549] | 928 | name = 'CertificateCourses' |
---|
[526] | 929 | no_import = False |
---|
| 930 | logger = logging.getLogger('%s_export' % name) |
---|
| 931 | current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S") |
---|
| 932 | logger.info('Start exporting %(name)s to %(name)s_%(current)s.csv' % vars()) |
---|
| 933 | faculties = [f.getObject() for f in self.portal_catalog({'meta_type': 'Faculty'})] |
---|
| 934 | export = [] |
---|
| 935 | heading = '"code","review_state","faculty_code","department_code",' |
---|
| 936 | heading += '"certificate_code","level","semester","core_or_elective"' |
---|
| 937 | dataline = '"%(code)s","%(review_state)s","%(faculty_code)s","%(department_code)s",' |
---|
[527] | 938 | dataline += '"%(certificate_code)s","%(level)s","%(semester)s","%(core_or_elective)s"' |
---|
[526] | 939 | export.append(heading) |
---|
| 940 | #import pdb;pdb.set_trace() |
---|
| 941 | semesters = ['first','second'] |
---|
| 942 | for faculty in faculties: |
---|
| 943 | di = {} |
---|
| 944 | di['faculty_code'] = faculty.id |
---|
| 945 | for department in faculty.objectValues(): |
---|
| 946 | di['department_code'] = department.id |
---|
[527] | 947 | for certificate in department.certificates.objectValues(): |
---|
[526] | 948 | di['certificate_code'] = certificate.id |
---|
| 949 | for level in certificate.objectValues(): |
---|
| 950 | di['level'] = level.id |
---|
| 951 | for sem in semesters: |
---|
| 952 | semester = getattr(level,sem,None) |
---|
| 953 | if semester is not None: |
---|
[527] | 954 | di['semester'] = semesters.index(sem) + 1 |
---|
[526] | 955 | for course in semester.objectValues(): |
---|
| 956 | course_d = course.getContent() |
---|
| 957 | di['code'] = course_d.get('code',None) |
---|
[529] | 958 | di['core_or_elective'] = getattr(course_d,'core_or_elective',None) |
---|
[526] | 959 | di['code'] = di['code'] or course.id |
---|
| 960 | di['review_state'] = self.portal_workflow.getInfoFor(course,'review_state','no_state') |
---|
| 961 | try: |
---|
| 962 | export.append(dataline % di) |
---|
| 963 | logger.info('exporting %s %s ' % (certificate.id, certificate.title)) |
---|
| 964 | except: |
---|
| 965 | logger.info('could not export %s %s ' % (certificate.id, certificate.title)) |
---|
| 966 | continue |
---|
| 967 | open("%s/import/%s-%s.csv" % (i_home,name,current),"w+").write('\n'.join(export)) |
---|
| 968 | return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) |
---|
| 969 | ###) |
---|
| 970 | |
---|
| 971 | |
---|
[278] | 972 | InitializeClass(AcademicsFolder) |
---|
| 973 | |
---|
| 974 | def addAcademicsFolder(container, id, REQUEST=None, **kw): |
---|
| 975 | """Add a AcademicsFolder.""" |
---|
| 976 | ob = AcademicsFolder(id, **kw) |
---|
| 977 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 978 | |
---|
| 979 | ###) |
---|
| 980 | |
---|
[256] | 981 | class Certificate(CPSDocument): ###( |
---|
[238] | 982 | """ |
---|
[319] | 983 | WAeUP Certificate |
---|
[238] | 984 | """ |
---|
[256] | 985 | meta_type = 'Certificate' |
---|
[238] | 986 | portal_type = meta_type |
---|
| 987 | security = ClassSecurityInfo() |
---|
[319] | 988 | |
---|
[238] | 989 | def __init__(self, id, **kw): |
---|
| 990 | CPSDocument.__init__(self, id, **kw) |
---|
| 991 | |
---|
[256] | 992 | ## security.declareProtected(View,"Title") |
---|
| 993 | ## def Title(self): |
---|
| 994 | ## """compose title""" |
---|
| 995 | ## return "Certificate of %s" % (self.title) |
---|
[238] | 996 | |
---|
[256] | 997 | InitializeClass(Certificate) |
---|
[238] | 998 | |
---|
[256] | 999 | def addCertificate(container, id, REQUEST=None, **kw): |
---|
| 1000 | """Add a Certificate.""" |
---|
| 1001 | ob = Certificate(id, **kw) |
---|
[238] | 1002 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 1003 | |
---|
| 1004 | ###) |
---|
| 1005 | |
---|
[454] | 1006 | class StudyLevel(CPSDocument): ###( |
---|
| 1007 | """ |
---|
| 1008 | WAeUP StudyLevel containing the courses and students |
---|
| 1009 | """ |
---|
| 1010 | meta_type = 'StudyLevel' |
---|
| 1011 | portal_type = meta_type |
---|
| 1012 | security = ClassSecurityInfo() |
---|
| 1013 | |
---|
| 1014 | security.declareProtected(View,"Title") |
---|
| 1015 | def Title(self): |
---|
| 1016 | """compose title""" |
---|
[458] | 1017 | try: |
---|
| 1018 | return "Level %s" % self.aq_parent.getId() |
---|
| 1019 | except: |
---|
| 1020 | return "no Title for %s" % self.getId() |
---|
[454] | 1021 | |
---|
[527] | 1022 | |
---|
[454] | 1023 | InitializeClass(StudyLevel) |
---|
| 1024 | |
---|
| 1025 | def addStudyLevel(container, id, REQUEST=None, **kw): |
---|
| 1026 | """Add a StudyLevel.""" |
---|
| 1027 | ob = StudyLevel(id, **kw) |
---|
| 1028 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 1029 | |
---|
| 1030 | ###) |
---|
| 1031 | |
---|
[256] | 1032 | class CertificateCourse(CPSDocument): ###( |
---|
[238] | 1033 | """ |
---|
[319] | 1034 | WAeUP CertificateCourse |
---|
[238] | 1035 | """ |
---|
[256] | 1036 | meta_type = 'CertificateCourse' |
---|
[238] | 1037 | portal_type = meta_type |
---|
| 1038 | security = ClassSecurityInfo() |
---|
[319] | 1039 | |
---|
[279] | 1040 | def getCourseEntry(self,cid): |
---|
| 1041 | res = self.portal_catalog({'meta_type': "Course", |
---|
| 1042 | 'id': cid}) |
---|
| 1043 | if res: |
---|
[319] | 1044 | return res[-1] |
---|
[279] | 1045 | else: |
---|
| 1046 | return None |
---|
[319] | 1047 | |
---|
[256] | 1048 | security.declareProtected(View,"Title") |
---|
| 1049 | def Title(self): |
---|
| 1050 | """compose title""" |
---|
[368] | 1051 | ce = self.getCourseEntry(self.id.upper()) |
---|
[454] | 1052 | #print self.id, self.aq_parent.id |
---|
[279] | 1053 | if ce: |
---|
| 1054 | return "%s" % ce.Title |
---|
| 1055 | return "No such course" |
---|
[238] | 1056 | |
---|
[279] | 1057 | security.declareProtected(View,"credits") |
---|
| 1058 | def credits(self): |
---|
| 1059 | """credits from course""" |
---|
| 1060 | ce = self.getCourseEntry(self.id) |
---|
| 1061 | if ce: |
---|
| 1062 | return "%s" % ce.credits |
---|
[280] | 1063 | return "0" |
---|
[319] | 1064 | |
---|
[279] | 1065 | security.declareProtected(View,"passmark") |
---|
| 1066 | def passmark(self): |
---|
| 1067 | """passmark from course""" |
---|
| 1068 | ce = self.getCourseEntry(self.id) |
---|
[296] | 1069 | if ce is not None and hasattr(ce,"passmark"): |
---|
| 1070 | return ce.passmark |
---|
[319] | 1071 | |
---|
| 1072 | |
---|
[280] | 1073 | security.declareProtected(View,"coursepath") |
---|
| 1074 | def coursepath(self): |
---|
| 1075 | """coursepath from course""" |
---|
| 1076 | ce = self.getCourseEntry(self.id) |
---|
| 1077 | if ce: |
---|
| 1078 | return ce.getPath() |
---|
| 1079 | return "?" |
---|
[279] | 1080 | |
---|
[319] | 1081 | |
---|
[256] | 1082 | InitializeClass(CertificateCourse) |
---|
[238] | 1083 | |
---|
[256] | 1084 | def addCertificateCourse(container, id, REQUEST=None, **kw): |
---|
| 1085 | """Add a CertificateCourse.""" |
---|
| 1086 | ob = CertificateCourse(id, **kw) |
---|
[238] | 1087 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 1088 | ###) |
---|
| 1089 | |
---|
[68] | 1090 | class Faculty(CPSDocument): ###( |
---|
| 1091 | """ |
---|
[319] | 1092 | WAeUP Faculty containing Departments |
---|
[68] | 1093 | """ |
---|
| 1094 | meta_type = 'Faculty' |
---|
| 1095 | portal_type = meta_type |
---|
| 1096 | security = ClassSecurityInfo() |
---|
[319] | 1097 | |
---|
[238] | 1098 | ## def __init__(self, id, **kw): |
---|
| 1099 | ## CPSDocument.__init__(self, id, **kw) |
---|
[173] | 1100 | |
---|
[200] | 1101 | security.declareProtected(View,"Title") |
---|
| 1102 | def Title(self): |
---|
| 1103 | """compose title""" |
---|
[238] | 1104 | return "%s" % (self.title) |
---|
[319] | 1105 | |
---|
[389] | 1106 | |
---|
[296] | 1107 | security.declareProtected(View,"LongTitle") |
---|
| 1108 | def LongTitle(self): |
---|
| 1109 | """compose long_title""" |
---|
[389] | 1110 | prefix = getattr(self,'title_prefix',None) |
---|
| 1111 | if prefix is None: |
---|
| 1112 | prefix = getattr(self,'institution_type','faculty') |
---|
| 1113 | self.getContent().edit(mapping = {'title_prefix': prefix}) |
---|
| 1114 | itype = self.portal_vocabularies.institution_types_voc.get(prefix,default="Faculty of") |
---|
[296] | 1115 | return "%s %s" % (itype,self.title) |
---|
[200] | 1116 | |
---|
[68] | 1117 | InitializeClass(Faculty) |
---|
| 1118 | |
---|
| 1119 | def addFaculty(container, id, REQUEST=None, **kw): |
---|
| 1120 | """Add a Faculty.""" |
---|
| 1121 | ob = Faculty(id, **kw) |
---|
| 1122 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 1123 | |
---|
| 1124 | ###) |
---|
| 1125 | |
---|
| 1126 | class Department(CPSDocument): ###( |
---|
| 1127 | """ |
---|
| 1128 | WAeUP Department containing the courses and students |
---|
| 1129 | """ |
---|
| 1130 | meta_type = 'Department' |
---|
| 1131 | portal_type = meta_type |
---|
| 1132 | security = ClassSecurityInfo() |
---|
[173] | 1133 | |
---|
[296] | 1134 | security.declareProtected(View,"LongTitle") |
---|
| 1135 | def LongTitle(self): |
---|
| 1136 | """compose long_title""" |
---|
[389] | 1137 | prefix = getattr(self,'title_prefix',None) |
---|
| 1138 | if prefix is None: |
---|
| 1139 | prefix = getattr(self,'institution_type','department') |
---|
| 1140 | self.getContent().edit(mapping = {'title_prefix': prefix}) |
---|
| 1141 | itype = self.portal_vocabularies.institution_types_voc.get(prefix,default="Department of") |
---|
[296] | 1142 | return "%s %s" % (itype,self.title) |
---|
| 1143 | |
---|
[68] | 1144 | InitializeClass(Department) |
---|
| 1145 | |
---|
| 1146 | def addDepartment(container, id, REQUEST=None, **kw): |
---|
| 1147 | """Add a Department.""" |
---|
[296] | 1148 | object = Department(id, **kw) |
---|
[295] | 1149 | id = object.getId() |
---|
[319] | 1150 | container._setObject(id, object) |
---|
[309] | 1151 | ## dep = getattr(container,id).getEditableContent() #getContent() |
---|
| 1152 | ## dep.invokeFactory('CoursesFolder','Courses') |
---|
| 1153 | ## o = getattr(dep,'Courses') |
---|
| 1154 | ## dict = {'Title': 'Courses'} |
---|
| 1155 | ## o.getContent().edit(mapping=dict) |
---|
| 1156 | ## dep.invokeFactory('CertificatesFolder','Certificates') |
---|
| 1157 | ## o = getattr(dep,'Certificates') |
---|
| 1158 | ## dict = {'Title': 'Certificates'} |
---|
| 1159 | ## o.geetContent().edit(mapping=dict) |
---|
[295] | 1160 | if REQUEST is not None: |
---|
| 1161 | url = container.absolute_url() |
---|
| 1162 | REQUEST.RESPONSE.redirect('%s/manage_main' % url) |
---|
[309] | 1163 | |
---|
[68] | 1164 | ###) |
---|
| 1165 | |
---|
| 1166 | class Course(CPSDocument): ###( |
---|
| 1167 | """ |
---|
[319] | 1168 | WAeUP Course |
---|
[68] | 1169 | """ |
---|
| 1170 | meta_type = 'Course' |
---|
| 1171 | portal_type = meta_type |
---|
| 1172 | security = ClassSecurityInfo() |
---|
[152] | 1173 | |
---|
| 1174 | security.declareProtected(View,"Title") |
---|
| 1175 | def Title(self): |
---|
| 1176 | """compose title""" |
---|
[238] | 1177 | return self.title |
---|
[319] | 1178 | |
---|
[68] | 1179 | InitializeClass(Course) |
---|
| 1180 | |
---|
| 1181 | def addCourse(container, id, REQUEST=None, **kw): |
---|
| 1182 | """Add a Course.""" |
---|
| 1183 | ob = Course(id, **kw) |
---|
| 1184 | return CPSBase_adder(container, ob, REQUEST=REQUEST) |
---|
| 1185 | ###) |
---|
[139] | 1186 | |
---|
[319] | 1187 | |
---|