Changeset 2282 for WAeUP_SRP


Ignore:
Timestamp:
27 Sep 2007, 16:52:41 (17 years ago)
Author:
joachim
Message:

add import for courses, certificates, certificate_courses

Location:
WAeUP_SRP
Files:
4 added
11 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/Academics.py

    r2190 r2282  
    687687        export = []
    688688        heading = '"code","review_state","faculty_code","department_code",'
    689         heading += '"certificate_code","level","semester","core_or_elective"'
     689        heading += '"certificate_code","level","core_or_elective"'
    690690        dataline = '"%(code)s","%(review_state)s","%(faculty_code)s","%(department_code)s",'
    691         dataline += '"%(certificate_code)s","%(level)s","%(semester)s","%(core_or_elective)s"'
     691        dataline += '"%(certificate_code)s","%(level)s","%(core_or_elective)s"'
    692692        export.append(heading)
    693693        #import pdb;pdb.set_trace()
     
    702702                    for level in certificate.objectValues():
    703703                        di['level'] = level.id
    704                         for sem in semesters:
    705                             semester = getattr(level,sem,None)
    706                             if semester is not None:
    707                                 di['semester'] = semesters.index(sem) + 1
    708                                 for course in semester.objectValues():
    709                                     di['code'] = course.getId()
    710                                     course_d = course.getContent()
    711                                     di['core_or_elective'] = getattr(course_d,'core_or_elective',None)
    712                                     di['review_state'] = self.portal_workflow.getInfoFor(course,'review_state','no_state')
    713                                     try:
    714                                         export.append(dataline % di)
    715                                         logger.info('Exporting %s %s ' % (certificate.id, certificate.title))
    716                                     except:
    717                                         logger.info('Could not export %s %s ' % (certificate.id, certificate.title))
    718                                         continue
     704                        for course in level.objectValues():
     705                            di['code'] = course.getId()
     706                            course_d = course.getContent()
     707                            di['core_or_elective'] = getattr(course_d,'core_or_elective',None)
     708                            di['review_state'] = self.portal_workflow.getInfoFor(course,'review_state','no_state')
     709                            try:
     710                                export.append(dataline % di)
     711                                logger.info('Exporting %s %s ' % (certificate.id, certificate.title))
     712                            except:
     713                                logger.info('Could not export %s %s ' % (certificate.id, certificate.title))
     714                                continue
    719715        open("%s/export/%s-%s.csv" % (i_home,name,current),"w+").write('\n'.join(export))
    720716        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
  • WAeUP_SRP/base/WAeUPTool.py

    r2268 r2282  
    998998            self._v_departments = {}
    999999            for d in res:
    1000                 self._v_departments[d.getId] = d.getObject()
     1000                self._v_departments[d.getId] = getattr(d.getObject(),"courses",None)
    10011001        did = mapping['department_code']
    10021002        d = self._v_departments.get(did,None)
    10031003        if d is None:
    1004             return '', "No Department with ID: %s" % fid
     1004            return '', "No Department with ID: %s" % did
    10051005        course_id = mapping.get('code')
    10061006        if course_id in self._v_course_list:
     
    10141014        c.getContent().edit(mapping=mapping)
    10151015        return course_id,''
     1016    ###)
     1017
     1018    security.declareProtected(ModifyPortalContent,'mass_edit_course') ###(
     1019    def mass_edit_course(self,mapping):
     1020        #import pdb;pdb.set_trace()
     1021        course_id = mapping.get('code')
     1022        res = self.portal_catalog(id=course_id)
     1023        if not res:
     1024            return '', "No Course with ID: %s" % did
     1025        c = res[0].getObject()
     1026        c.getContent().edit(mapping=mapping)
     1027        return course_id,''
     1028    ###)
     1029
     1030    security.declareProtected(ModifyPortalContent,'mass_create_certificate') ###(
     1031    def mass_create_certificate(self,mapping):
     1032        if getattr(self,'_v_certificate_list',None) is None:
     1033            self._v_certificate_list = []
     1034        if getattr(self,'_v_departments',None) is None:
     1035            res = self.portal_catalog(portal_type = "Department")
     1036            self._v_departments = {}
     1037            for d in res:
     1038                self._v_departments[d.getId] = getattr(d.getObject(),"certificates",None)
     1039        did = mapping['department_code']
     1040        d = self._v_departments.get(did,None)
     1041        if d is None:
     1042            return '', "No Department with ID: %s" % did
     1043        certificate_id = mapping.get('code')
     1044        if certificate_id in self._v_certificate_list:
     1045            return '', "Duplicate Department ID: %s" % did
     1046        c = getattr(d,certificate_id,None)
     1047        if c is not None:
     1048            return '', "Duplicate Department ID: %s" % did
     1049        d.invokeFactory('Certificate', certificate_id)
     1050        self._v_certificate_list.append(certificate_id)
     1051        c = getattr(d,certificate_id)
     1052        c.getContent().edit(mapping=mapping)
     1053        return certificate_id,''
     1054    ###)
     1055
     1056    security.declareProtected(ModifyPortalContent,'mass_edit_certificate') ###(
     1057    def mass_edit_certificate(self,mapping):
     1058        #import pdb;pdb.set_trace()
     1059        certificate_id = mapping.get('code')
     1060        res = self.portal_catalog(id=certificate_id)
     1061        if not res:
     1062            return '', "No Certificate with ID: %s" % did
     1063        c = res[0].getObject()
     1064        c.getContent().edit(mapping=mapping)
     1065        return certificate_id,''
     1066    ###)
     1067
     1068    security.declareProtected(ModifyPortalContent,'mass_create_certificate_course') ###(
     1069    def mass_create_certificate_course(self,mapping):
     1070        if getattr(self,'_v_certificate_course_list',None) is None:
     1071            self._v_certificate_course_list = []
     1072        if getattr(self,'_v_ceritficates',None) is None:
     1073            res = self.portal_catalog(portal_type = "Certificate")
     1074            self._v_certificates = {}
     1075            for cert in res:
     1076                self._v_certificates[cert.getId] = cert.getObject()
     1077        cert_id = mapping['certificate_code']
     1078        cert = self._v_certificates.get(cert_id,None)
     1079        if cert is None:
     1080            return '', "No Certificate with ID: %s" % did
     1081        certificate_course_id = mapping.get('code')
     1082        if certificate_course_id in self._v_certificate_course_list:
     1083            return '', "Duplicate CertificateCourse ID: %s" % certificate_course_id
     1084        level_id = mapping.get('level')
     1085        level = getattr(cert,level_id,None)
     1086        if level is None:
     1087            cert.invokeFactory('StudyLevel', level_id)
     1088            level = getattr(cert,level_id,None)
     1089        elif hasattr(level,certificate_course_id):
     1090            return '', "Duplicate CertificateCourse ID: %s in %s/ %s" %\
     1091            (certificate_course_id,cert_id,level_id)
     1092        level.invokeFactory('CertificateCourse', certificate_course_id)
     1093        self._v_certificate_course_list.append(certificate_course_id)
     1094        c = getattr(level,certificate_course_id)
     1095        c.getContent().edit(mapping=mapping)
     1096        return certificate_course_id,''
    10161097    ###)
    10171098
     
    13001381                diff2layout = set(import_keys).difference(set(layout.keys()))
    13011382                if diff2schema:
    1302                     em = "not ignorable key(s) %s found in heading" % diff2schema
     1383                    em = 'not ignorable key(s): "%s" found in heading' % ", ".join(diff2schema)
    13031384                    return em
    13041385                s = ','.join(['"%s"' % fn for fn in import_keys])
  • WAeUP_SRP/base/Widgets.py

    r2271 r2282  
    165165            value = datastructure[widget_id].upper()
    166166            err = 0
    167             res = self.portal_catalog(meta_type= "Course",id = value)
     167            res = self.courses_catalog(code = value)
    168168            if len(res) > 0:
    169169                err = 'Course already exists'
  • WAeUP_SRP/base/skins/waeup_academics/getFacultiesInfo.py

    r2273 r2282  
    4343    except AttributeError:
    4444        continue
    45            
    4645items.sort(cmp_id)
    4746info['items'] = items
  • WAeUP_SRP/base/skins/waeup_default/get_csv_names.py

    r1756 r2282  
    77files = context.waeup_tool.get_csv_filenames()
    88if key is None:
    9     return [(f[:-4],f) for f in files]
     9    l = [(f[:-4],f) for f in files]
     10    l.sort(cmp=lambda x,y: cmp(x[0].lower(), y[0].lower()))
     11    return l
    1012
    1113return files[files.index("%s.csv" % key)]
  • WAeUP_SRP/fceokene/profiles/default/layouts.xml

    r2265 r2282  
    99  <object name="application_manage" meta_type="CPS Layout"/>
    1010  <object name="certificate" meta_type="CPS Layout"/>
     11  <object name="import_certificate" meta_type="CPS Layout"/>
    1112  <object name="certificate_course" meta_type="CPS Layout"/>
     13  <object name="import_certificate_course" meta_type="CPS Layout"/>
    1214  <object name="course" meta_type="CPS Layout"/>
    1315  <object name="import_course" meta_type="CPS Layout"/>
  • WAeUP_SRP/fceokene/profiles/default/layouts/course.xml

    r1449 r2282  
    4444  <property name="hidden_layout_modes"/>
    4545  <property name="hidden_readonly_layout_modes"/>
     46 </widget>
     47  <widget name="level" meta_type="String Widget">
     48  <property name="title">Level</property>
     49  <property name="fields">
     50   <element value="level"/>
     51  </property>
     52  <property name="label">Level</property>
     53  <property name="label_edit">Level</property>
     54  <property name="readonly_layout_modes"/>
     55  <property name="hidden_layout_modes"/>
     56  <property name="hidden_readonly_layout_modes"/>
     57  <property name="display_width">60</property>
    4658 </widget>
    4759 <widget name="credits" meta_type="Int Widget">
     
    121133  </row>
    122134  <row>
     135   <cell name="level"/>
     136  </row>
     137  <row>
    123138   <cell name="semester"/>
    124139  </row>
  • WAeUP_SRP/fceokene/profiles/default/layouts/import_course.xml

    r2265 r2282  
    88 <property name="flexible_widgets"/>
    99 <property name="validate_values_expr"></property>
    10 <widget name="code" meta_type="CourseId Widget">
     10<widget name="code" meta_type="String Widget">
    1111 <property name="title">Course Id</property>
    1212 <property name="fields">
     
    6969  <property name="display_width">60</property>
    7070 </widget>
    71  <widget name="department_code" meta_type="String Widget">
     71  <widget name="department_code" meta_type="String Widget">
    7272  <property name="title">Department Code</property>
    7373  <property name="fields">
     
    7676  <property name="label">Department Code</property>
    7777  <property name="label_edit">Department Code</property>
     78  <property name="readonly_layout_modes"/>
     79  <property name="hidden_layout_modes"/>
     80  <property name="hidden_readonly_layout_modes"/>
     81  <property name="display_width">60</property>
     82 </widget>
     83  <widget name="level" meta_type="String Widget">
     84  <property name="title">Level</property>
     85  <property name="fields">
     86   <element value="level"/>
     87  </property>
     88  <property name="label">Level</property>
     89  <property name="label_edit">Level</property>
    7890  <property name="readonly_layout_modes"/>
    7991  <property name="hidden_layout_modes"/>
  • WAeUP_SRP/fceokene/profiles/default/schemas.xml

    r2265 r2282  
    99 <object name="application" meta_type="CPS Schema"/>
    1010 <object name="certificate" meta_type="CPS Schema"/>
     11 <object name="import_certificate" meta_type="CPS Schema"/>
    1112 <object name="certificate_course" meta_type="CPS Schema"/>
     13 <object name="import_certificate_course" meta_type="CPS Schema"/>
    1214 <object name="import_course" meta_type="CPS Schema"/>
    1315 <object name="course" meta_type="CPS Schema"/>
  • WAeUP_SRP/fceokene/profiles/default/schemas/import_course.xml

    r2265 r2282  
    66 <field name="code" meta_type="CPS String Field"/>
    77 <field name="credits" meta_type="CPS Int Field"/>
    8  <field name="org_code" meta_type="CPS String Field"/>
    98 <field name="passmark" meta_type="CPS Int Field">
    109  <property name="default_expr">python:40</property>
  • WAeUP_SRP/fceokene/profiles/default/vocabularies/import_names.xml

    r2264 r2282  
    99 <item key="faculty" msgid="">Faculty Data</item>
    1010 <item key="department" msgid="">Department Data</item>
     11 <item key="course" msgid="">Course Data</item>
     12 <item key="certificate" msgid="">Certificate Data</item>
     13 <item key="certificate_course" msgid="">Certificate Course Data</item>
    1114</object>
Note: See TracChangeset for help on using the changeset viewer.