Changeset 8615


Ignore:
Timestamp:
3 Jun 2012, 13:33:47 (13 years ago)
Author:
uli
Message:

Check application_category of cert 'course1' when batching.

File:
1 edited

Legend:

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

    r8581 r8615  
    154154
    155155    def getParent(self, row, site):
     156        result = None
    156157        if self.getLocator(row) == 'container_code':
    157             return site['applicants'].get(row['container_code'], None)
    158         if self.getLocator(row) == 'reg_number':
     158            result = site['applicants'].get(row['container_code'], None)
     159        elif self.getLocator(row) == 'reg_number':
    159160            reg_number = row['reg_number']
    160161            cat = queryUtility(ICatalog, name='applicants_catalog')
     
    162163                cat.searchResults(reg_number=(reg_number, reg_number)))
    163164            if results:
    164                 return results[0].__parent__
    165         if self.getLocator(row) == 'applicant_id':
     165                result = results[0].__parent__
     166        elif self.getLocator(row) == 'applicant_id':
    166167            applicant_id = row['applicant_id']
    167168            cat = queryUtility(ICatalog, name='applicants_catalog')
     
    169170                cat.searchResults(applicant_id=(applicant_id, applicant_id)))
    170171            if results:
    171                 return results[0].__parent__
    172         return None
     172                result = results[0].__parent__
     173        return result
    173174
    174175    def parentsExist(self, row, site):
     
    301302        errs, inv_errs, conv_dict =  converter.fromStringDict(
    302303            row, self.factory_name, mode=mode)
     304        cert = conv_dict.get('course1', None)
     305        if cert is not None and (mode in ('create', 'update')):
     306            # course1 application category must match container's.  We
     307            # could move that check into addApplicant, as it is
     308            # expensive.
     309            #
     310            # XXX: getSite() should be avoided here.
     311            parent = self.getParent(row, grok.getSite())
     312            if cert.application_category != parent.application_category:
     313                errs.append(('course1', 'wrong application category'))
    303314        if row.has_key('state') and \
    304315            not row['state'] in IMPORTABLE_STATES:
Note: See TracChangeset for help on using the changeset viewer.