Changeset 3233


Ignore:
Timestamp:
26 Feb 2008, 09:11:28 (17 years ago)
Author:
Henrik Bettermann
Message:

Da waren zwei dicke Fehler im Import für Kursergebnisse drin. Bitte schaue dir meine Veränderungen mal an.

Location:
WAeUP_SRP
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/WAeUPImport.py

    r3219 r3233  
    8585        self.layout = self.layout_tool._getOb(iname,None)
    8686        if self.schema is None:
    87             errors.append('No schema %s' % iname)
     87            errors.append('no schema %s' % iname)
    8888        if self.pending_schema is None:
    8989            self.pending_schema = self.schema
    9090        if self.layout is None:
    91             errors.append('No such layout %s' % iname)
     91            errors.append('no such layout %s' % iname)
    9292        self.data_keys = self.pending_schema.keys()
    9393        self.csv_keys = self.pending_schema.keys()
     
    187187            d = self._v_department_certificates.get(did,None)
    188188            if d is None:
    189                 msg =  "No Department with ID: %s" % did
     189                msg =  "no department with id: %s" % did
    190190                break
    191191            certificate_id = mapping.get('code')
    192192            if certificate_id in self._v_certificate_list:
    193                 msg =  "Duplicate Certificate ID: %s" % did
     193                msg =  "duplicate certificate id: %s" % did
    194194                break
    195195            c = getattr(d,certificate_id,None)
    196196            if c is not None:
    197                 msg =  "Duplicate Certificate ID: %s" % did
     197                msg =  "duplicate certificate id: %s" % did
    198198                break
    199199            try:
     
    215215        while True:
    216216            if not res:
    217                 msg =  "No Certificate with ID: %s" % certificate_id
     217                msg =  "no certificate with id: %s" % certificate_id
    218218                break
    219219            c = res[0].getObject()
     
    245245            department_courses = self._v_department_courses.get(department_id,None)
    246246            if department_courses is None:
    247                 msg =  "No Department with ID: %(department_id)s" % vars()
     247                msg =  "no department with id: %(department_id)s" % vars()
    248248                break
    249249            if course_id in self._v_course_list:
    250                 msg =  "Duplicate Course ID: %(course_id)s" % vars()
     250                msg =  "duplicate course id: %(course_id)s" % vars()
    251251                break
    252252            if course_id in department_courses:
    253                 msg =  "Course %(course_id)s already exists in department %(department_id)s" % vars()
     253                msg =  "course %(course_id)s already exists in department %(department_id)s" % vars()
    254254                break
    255255            try:
     
    270270        while True:
    271271            if not res:
    272                 msg =  "No Course with ID: %s" % course_id
     272                msg =  "no course with id: %s" % course_id
    273273                break
    274274            c = res[0].getObject()
     
    284284    plural_name = "%ss" % name
    285285    commit_after = 1000000
    286     required_modes = ('create','edit')
     286    required_modes = ('create','edit','remove')
    287287
    288288    def getStudentRecord(self,mapping): ###(
    289         for id_key in ('student_id','matric_no'):
     289        id_field_found = False
     290        msg = ''
     291        for id_key in ('id','matric_no'):
    290292            id_field = mapping.get(id_key,'')
    291293            if id_field:
     294                if id_field_found:
     295                    msg = "%s must not be provided" % id_key
     296                    break
    292297                search_key = id_key
    293298                search_field = id_field
    294                 break
    295         if search_key == "student_id":
    296             search_key = 'id'
     299                id_field_found = True
     300        #if search_key == "student_id":
     301        #    search_key = 'id'
     302        if not id_field_found:
     303            msg = "neither id nor matric_no provided"
     304            return None,msg
    297305        query = Eq(search_key,search_field)
    298306        res = self.students_catalog.evalAdvancedQuery(query)
    299307        student_record = None
    300         msg = ''
    301308        if res:
    302309            student_record = res[0]
    303310            if search_key == "matric_no":
    304                 mapping['student_id'] = student_record.id
    305             elif search_key == "student_id":
     311                mapping['id'] = student_record.id
     312            elif search_key == "id":
    306313                mapping['matric_no'] = student_record.matric_no
    307314        else:
    308             msg = "No student with %(search_key)s %(search_field)s" % vars()
     315            msg = "no student with %(search_key)s %(search_field)s" % vars()
    309316        return student_record,msg
    310317    ###)
     
    324331            course_id = mapping.get('code')
    325332            if course_id not in self._v_courses.keys():
    326                 msg = "No course with ID: %s" % course_id
     333                msg = "no course with id: %s" % course_id
    327334                break
    328335            student_record,msg = self.getStudentRecord(mapping)
     
    374381            if msg:
    375382                break
     383            if not mapping.get('level_id',''):
     384                msg =  "level_id is missing"
     385                break
     386            if not mapping.get('code',''):
     387                msg =  "code is missing"
     388                break             
    376389            student_id = student_record.id
    377390            level_id = mapping['level_id']
     
    382395            self.course_results.modifyRecord(**mapping)
    383396        except KeyError:
    384             msg = "No course result to edit: %s" % key
     397            msg = "no course result with key %s" % key
    385398        return key,msg,mapping
    386399    ###)
    387400
    388401    def remove(self,mapping):###(
    389         id_key = ''
     402        key = ''
    390403        msg = ''
    391404        while True:
     
    393406            if msg:
    394407                break
     408            if not mapping.get('level_id',''):
     409                msg =  "level_id is missing"
     410                break
     411            if not mapping.get('code',''):
     412                msg =  "code is missing"
     413                break               
    395414            student_id = student_record.id
    396415            level_id = mapping['level_id']
     
    398417            key = "%(student_id)s|%(level_id)s|%(code)s" % vars()
    399418            if self.course_results.getRecordByKey(key) is None:
    400                 msg =  "no course-result with %(key)s" % vars()
     419                msg =  "no course result with key %(key)s" % vars()
    401420                break
    402421            self.course_results.deleteRecord(key)
     
    426445            certificate_course_id = mapping.get('code')
    427446            if certificate_course_id not in self._v_courses:
    428                 msg =  "No Course with ID: %s" % certificate_course_id
     447                msg =  "no course with id: %s" % certificate_course_id
    429448                break
    430449            cert_id = mapping['certificate_code']
    431450            cert = self._v_certificates.get(cert_id,None)
    432451            if cert is None:
    433                 msg =  "No Certificate with ID: %s" % cert_id
     452                msg =  "no certificate with id: %s" % cert_id
    434453                break
    435454            level_id = mapping.get('level')
     
    439458                level = getattr(cert,level_id,None)
    440459            elif hasattr(level,certificate_course_id):
    441                 msg =  "Duplicate CertificateCourse ID: %(certificate_course_id)s " % vars()
     460                msg =  "duplicate certificate course id: %(certificate_course_id)s " % vars()
    442461                msg += "in %(cert_id)s/ %(level_id)s" % vars()
    443462                break
     
    467486            faculty = self._v_faculties.get(faculty_id,None)
    468487            if faculty is None:
    469                 msg =  "No Faculty with ID: %s" % faculty_id
     488                msg =  "no faculty with id: %s" % faculty_id
    470489                break
    471490            else:
     
    501520                d = getattr(getattr(academics_folder,faculty_id),department_id,None)
    502521            except KeyError:
    503                 msg =  "Department %s or Faculty %s wrong" % (department_id,faculty_id)
     522                msg =  "department %s or faculty %s wrong" % (department_id,faculty_id)
    504523                break
    505524            if d is None or d.portal_type == "Faculty":
    506                 msg =  "Department %s not found" % (department_id)
     525                msg =  "department %s not found" % (department_id)
    507526                break
    508527            d.getContent().edit(mapping=mapping)
     
    524543        while True:
    525544            if faculty_id in academics_folder.objectIds():
    526                 msg =  "Faculty with ID: %s exists" % faculty_id
     545                msg =  "faculty with id: %s exists" % faculty_id
    527546                break
    528547            logger.info('Creating Faculty %(code)s, %(title)s' % mapping)
     
    546565            f = getattr(academics_folder,faculty_id,None)
    547566            if f is None:
    548                 msg =  "Faculty with ID: %s does not exist" % faculty_id
     567                msg =  "faculty with id: %s does not exist" % faculty_id
    549568            f.getContent().edit(mapping=mapping)
    550569            break
  • WAeUP_SRP/uniben/profiles/default/layouts/import_course_result.xml

    r3192 r3233  
    11<?xml version="1.0"?>
    22<?xml-stylesheet type="text/xsl" href="layout.xsl"?>
    3 <object name="course" meta_type="CPS Layout">
     3<object name="import_course_result" meta_type="CPS Layout">
    44 <property name="layout_create_method"></property>
    55 <property name="layout_edit_method"></property>
     
    2121  <property name="vocabulary">import_modes</property>
    2222 </widget>
    23   <widget name="student_id" meta_type="String Widget">
     23  <widget name="id" meta_type="String Widget">
    2424    <property name="title">Student Id</property>
    2525    <property name="fields">
    26       <element value="student_id"/>
     26      <element value="id"/>
    2727    </property>
    2828    <property name="is_required">False</property>
  • WAeUP_SRP/uniben/profiles/default/layouts/import_student.xml

    r3191 r3233  
    11<?xml version="1.0"?>
    22<?xml-stylesheet type="text/xsl" href="layout.xsl"?>
    3 <object name="student_create" meta_type="CPS Layout">
     3<object name="import_student" meta_type="CPS Layout">
    44 <property name="layout_create_method"></property>
    55 <property name="layout_edit_method"></property>
     
    282282  <property name="hidden_readonly_layout_modes"/>
    283283 </widget>
    284  
     284
    285285 <widget name="jamb_sex" meta_type="String Widget">
    286286  <property name="title">JAMB Sex</property>
     
    295295  </property>
    296296  <property name="hidden_readonly_layout_modes"/>
    297  </widget> 
     297 </widget>
    298298
    299299 <widget name="jamb_lga" meta_type="String Widget">
  • WAeUP_SRP/uniben/profiles/default/schemas/import_course_result.xml

    r3191 r3233  
    33<object name="course_result" meta_type="CPS Schema">
    44 <field name="import_mode" meta_type="CPS String Field"/>
    5  <field name="student_id" meta_type="CPS String Field"/>
     5 <field name="id" meta_type="CPS String Field"/>
    66 <field name="matric_no" meta_type="CPS String Field"/>
    77 <field name="code" meta_type="CPS String Field"/>
Note: See TracChangeset for help on using the changeset viewer.