Changeset 13607


Ignore:
Timestamp:
13 Jan 2016, 06:34:05 (9 years ago)
Author:
Henrik Bettermann
Message:

Fix certificate course importer. Empty mandatory fields were imported as <IGNORE>.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/university
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/university/batching.py

    r13271 r13607  
    416416    def addEntry(self, obj, row, site):
    417417        parent = self.getParent(row, site)
    418         parent.addCertCourse(row['course'],
    419                             row['level'], row.get('mandatory',None))
    420                             # mandatory is not a required and might be missing
     418        # mandatory is not a required and might be missing or can be
     419        # the ignore-marker.
     420        mandatory = row.get('mandatory', None)
     421        if mandatory in (None, IGNORE_MARKER):
     422            parent.addCertCourse(row['course'], row['level'])
     423            return
     424        parent.addCertCourse(row['course'], row['level'], mandatory)
    421425        return
    422426
  • main/waeup.kofa/trunk/src/waeup/kofa/university/tests/sample_certificatecourse_data.csv

    r11790 r13607  
    1 certificate_code,course,department_code,faculty_code,level
    2 CRT1,CRS1,DEP1,FAC1,200
    3 CRT1,CRS1,DEP1,FAC1,100
    4 CRT2,CRS1,DEP1,FAC1,100
     1certificate_code,course,department_code,faculty_code,level,mandatory
     2CRT1,CRS1,DEP1,FAC1,200,1
     3CRT1,CRS1,DEP1,FAC1,300,nonsense
     4CRT1,CRS1,DEP1,FAC1,400,<IGNORE>
     5CRT1,CRS1,DEP1,FAC1,100,
     6CRT2,CRS1,DEP1,FAC1,100,
  • main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_batching.py

    r13431 r13607  
    732732            self.csv_file_certificatecourse, CERTIFICATECOURSE_HEADER_FIELDS)
    733733        content = open(fail_file).read()
    734         self.assertEqual(num_warns,2)
     734        self.assertEqual(num_warns,2) # the last two
    735735        self.assertEqual(
    736736            content,
    737             'faculty_code,course,level,department_code,certificate_code,'
    738             '--ERRORS--\r\nFAC1,CRS1,100,DEP1,CRT1,'
    739             'This object already exists.\r\nFAC1,CRS1,100,DEP1,CRT2,'
    740             'Not all parents do exist yet.\r\n'
    741 
     737            'mandatory,level,faculty_code,course,department_code,'
     738            'certificate_code,--ERRORS--\r\n'
     739            '<IGNORE>,100,FAC1,CRS1,'
     740            'DEP1,CRT1,This object already exists.\r\n'
     741            '<IGNORE>,100,FAC1,CRS1,DEP1,CRT2,Not all parents do exist yet.\r\n'
    742742            )
    743743        logcontent = open(self.logfile).read()
     
    746746            'INFO - system - CertificateCourse Processor - '
    747747            'sample_certificatecourse_data - CRT1 - updated: '
    748             'course=CRS1, level=200\n'
     748            'mandatory=True, level=200, course=CRS1\n'
    749749            in logcontent)
    750 
    751         return
     750        return
Note: See TracChangeset for help on using the changeset viewer.