Ignore:
Timestamp:
14 Jul 2006, 13:52:50 (18 years ago)
Author:
joachim
Message:

=backoffice enhencements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Academics.py

    r295 r296  
    7171                logger.info('Faculty with ID %(FacultyCode)s %(Description)s already exists' % faculty)
    7272                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()
    7574    ###)
    7675
     
    140139                    dict = {'Title': 'Certificates'}
    141140                    certificates.getContent().edit(mapping=dict)
    142         return self.academics.temporary_view_all()
    143         return self.temporary_view_all()
     141        return self.academics.academics_contents()
    144142    ###)
    145143   
     
    167165        course_list = [ c.id for c in cl]
    168166        for course in courses:
    169             logger.info('Processing %(CourseCode)s %(Description)s %(Credits)s %(Dept)s %(Semester)s %(Session)s %(PassMark)s %(CourseKey)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)
    170168##            if course.get("FORMERCODE").endswith('BITS'):
    171169##                continue
     
    179177                if not no_import:
    180178                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
    181                     no_import.write('"CourseCode","Description","Credits","Dept","Semester","Session","PassMark","CourseKey","Category","AdmStatus"\n')
     179                    no_import.write('"CourseCode","Description","Credits","Dept","Semester","Session","PassMark","Category","AdmStatus"\n')
    182180                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","%(CourseKey)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)
    184182                continue
    185183            course_id = ''.join(re.split('\W+',course.get('CourseCode')))
     
    198196##                logger.info("invalid course_code %(course_id)s renaming to %(tid)s" % vars())
    199197##                course_id = tid
    200             elif len(course_id) > 7:
     198            elif len(course_id) > 10:
    201199                logger.info("invalid course_code %(CourseCode)s" % course)
    202200                if not no_import:
    203201                    no_import = open("%s/import/%s_not_imported.csv" % (i_home,name),"w")
    204                     no_import.write('"CourseCode","Description","Credits","Dept","Semester","Session","PassMark","CourseKey","Category","AdmStatus"\n')
     202                    no_import.write('"CourseCode","Description","Credits","Dept","Semester","Session","PassMark","Category","AdmStatus"\n')
    205203                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","%(CourseKey)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)
    207205                continue
    208206            courses = dept.Courses
     
    229227                dict['passmark'] = 0
    230228            c.getContent().edit(mapping=dict)
    231         return self.academics.temporary_view_all()
    232         return self.temporary_view_all()
     229        return self.academics.academics_contents()
    233230    ###)
    234231
     
    272269                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)
    273270                continue
    274             certificate_id = "%(category)s_%(Admstatus)s_%(Dept)s" % certificate
     271            #certificate_id = "%(category)s_%(Admstatus)s_%(Dept)s" % certificate
    275272            dep = deps[depid]
    276273            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
    277282            c = getattr(certificates,certificate_id,None)
    278283            if c is None:
     
    282287                c = getattr(certificates,certificate_id)
    283288            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('_','')
    291289            dict['code'] = code
    292290            dict['faculty'] = certificate.get('Faculty')
     
    308306            dict['probation_credits'] = certificate.get('ProbationCredits')
    309307            c.getContent().edit(mapping=dict)
    310         return self.academics.temporary_view_all()
    311         return self.temporary_view_all()
     308        return self.academics.academics_contents()
    312309    ###)
    313310
     
    326323        d_ids = [d.id for d in self.portal_catalog({'meta_type': "Department"})]
    327324        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()
    328329        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)
    330331            depid = cert_course.get('Dept')
    331332            course_code = cert_course.get('CosCode')
     
    339340##            if cert_course.get('Session') != '2002/2003':
    340341##                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():
    344346                #print code
    345347                em = 'CertCode %(CertCode)s for %(CosCode)s not found\n' % cert_course
     
    347349                if not no_import:
    348350                    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')
    350352                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)
    352354                continue
    353355            certificate = certificate[-1].getObject()
     
    358360                if not no_import:
    359361                    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')
    361363                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)
    363365                continue
    364366            if depid not in d_ids:
     
    367369                if not no_import:
    368370                    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')
    370372                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)
    372374                continue
    373375            level = cert_course.get('Level')
     
    391393                if not no_import:
    392394                    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')
    394396##                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)
    396398                continue
    397399            semester.invokeFactory('CertificateCourse',course_code)
     
    410412            dict['level'] = cert_course.get('Level')
    411413            cc.getContent().edit(mapping=dict)
    412         return self.academics.temporary_view_all()
     414        return self.academics.academics_contents()
    413415    ###)
    414416
     
    483485        """passmark from course"""
    484486        ce = self.getCourseEntry(self.id)
    485         return ce.passmark
     487        if ce is not None and hasattr(ce,"passmark"):
     488            return ce.passmark
     489       
    486490   
    487491    security.declareProtected(View,"coursepath")
     
    517521        """compose title"""
    518522        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)
    519530
    520531InitializeClass(Faculty)
     
    541552##        return "Department of %s" % (self.title)
    542553
     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
    543563InitializeClass(Department)
    544564
    545565def addDepartment(container, id, REQUEST=None, **kw):
    546566    """Add a Department."""
    547     ob = Department(id, **kw)
     567    object = Department(id, **kw)
    548568    id = object.getId()
    549569    container._setObject(id, object)
    550     dep = getattr(container,id)
     570    dep = getattr(container,id).getContent()
    551571    dep.invokeFactory('CoursesFolder','Courses')
     572    o = getattr(dep,'Courses')
     573    dict = {'Title': 'Courses'}
     574    o.getContent().edit(mapping=dict)
    552575    dep.invokeFactory('CertificatesFolder','Certificates')
     576    o = getattr(dep,'Certificates')
     577    dict = {'Title': 'Certificates'}
     578    o.getContent().edit(mapping=dict)
    553579    if REQUEST is not None:
    554580        url = container.absolute_url()
Note: See TracChangeset for help on using the changeset viewer.