Ignore:
Timestamp:
2 Oct 2011, 07:57:57 (13 years ago)
Author:
Henrik Bettermann
Message:

Use matric_number for location of studycourses as well.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/batching.py

    r6841 r6843  
    4747
    4848    # The entry never exists in create mode.
     49    # To do: Use reg_number and matric_number for locating as well.
    4950    def entryExists(self, row, site):
    5051        if row.has_key('student_id'):
     
    9091        result = []
    9192        return sorted(list(set(
    92             ['student_id','reg_number'] + getFields(self.iface).keys())))
     93            ['student_id','reg_number','matric_number'] + getFields(
     94                self.iface).keys())))
    9395
    9496    def checkHeaders(self, headerfields, mode='ignore'):
    95         if not 'reg_number' in headerfields and not 'student_id' in headerfields:
     97        if not 'reg_number' in headerfields and not 'student_id' in headerfields and not 'matric_number' in headerfields:
    9698            raise FatalCSVError(
    97                 "Need at least columns student_id or reg_number for import!")
     99                "Need at least columns student_id or reg_number or matric_number for import!")
    98100        # Check for fields to be ignored...
    99101        not_ignored_fields = [x for x in headerfields
     
    105107
    106108    def parentsExist(self, row, site):
    107         if not 'students' in site.keys():
     109        if not 'students' in site.keys() and row['student_id']:
    108110            return False
    109111        if 'student_id' in row.keys():
     
    111113                student = site['students'][row['student_id']]
    112114                return student
    113         else:
    114             # Here we know that the reg_number is in row
     115        elif 'reg_number' in row.keys() and row['reg_number']:
    115116            reg_number = row['reg_number']
    116117            cat = queryUtility(ICatalog, name='students_catalog')
    117118            results = list(
    118119                cat.searchResults(reg_number=(reg_number, reg_number)))
     120            if results:
     121                return results[0]
     122        elif 'matric_number' in row.keys() and row['matric_number']:
     123            #import pdb; pdb.set_trace()
     124            matric_number = row['matric_number']
     125            cat = queryUtility(ICatalog, name='students_catalog')
     126            results = list(
     127                cat.searchResults(matric_number=(matric_number, matric_number)))
    119128            if results:
    120129                return results[0]
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_batching.py

    r6840 r6843  
    133133        num, num_warns, fin_file, fail_file = self.importer.doImport(
    134134            self.csv_file, STUDENT_HEADER_FIELDS)
     135        self.assertEqual(num_warns,0)
    135136        assert len(self.app['students'].keys()) == 4
    136137        shutil.rmtree(os.path.dirname(fin_file))
     
    203204            self.csv_file, STUDYCOURSE_HEADER_FIELDS,'update')
    204205        studycourse = self.importer.getEntry(dict(reg_number='1'), self.app)
     206        self.assertEqual(num_warns,0)
    205207        self.assertEqual(studycourse.certificate.code, u'CERT1')
    206208        shutil.rmtree(os.path.dirname(fin_file))
Note: See TracChangeset for help on using the changeset viewer.