Ignore:
Timestamp:
3 Jul 2012, 09:47:27 (12 years ago)
Author:
Henrik Bettermann
Message:

Add delEntry method to StudentOnlinePaymentProcessor?.

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

Legend:

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

    r8884 r8885  
    363363        return errs, inv_errs, conv_dict
    364364
     365    def getMapping(self, path, headerfields, mode):
     366        """Get a mapping from CSV file headerfields to actually used fieldnames.
     367        """
     368        result = dict()
     369        reader = csv.reader(open(path, 'rb'))
     370        raw_header = reader.next()
     371        for num, field in enumerate(headerfields):
     372            if field not in ['student_id', 'reg_number', 'matric_number', 'p_id'
     373                             ] and mode == 'remove':
     374                continue
     375            if field == u'--IGNORE--':
     376                # Skip ignored columns in failed and finished data files.
     377                continue
     378            result[raw_header[num]] = field
     379        return result
     380
    365381
    366382class StudentStudyCourseProcessor(StudentProcessorBase):
     
    564580    def checkHeaders(self, headerfields, mode='ignore'):
    565581        super(StudentOnlinePaymentProcessor, self).checkHeaders(headerfields)
    566         if mode == 'update' and not 'p_id' in headerfields:
     582        if mode in ('update', 'remove') and not 'p_id' in headerfields:
    567583            raise FatalCSVError(
    568                 "Need p_id for import in update mode!")
     584                "Need p_id for import in update and remove modes!")
    569585        return True
    570586
     
    602618        student = self.getParent(row, site).__parent__
    603619        student.__parent__.logger.info(
    604             '%s - Payment ticket updated: %s'
    605             % (student.student_id, items_changed))
     620            '%s - %s - updated: %s'
     621            % (student.student_id, obj.p_id, items_changed))
    606622        return
    607623
     
    616632            parent[p_id] = obj
    617633        return
     634
     635    def delEntry(self, row, site):
     636        payment = self.getEntry(row, site)
     637        parent = self.getParent(row, site)
     638        if payment is not None:
     639            student = self._getStudent(row, site)
     640            student.__parent__.logger.info('%s - removed: %s'
     641                % (student.student_id, payment.p_id))
     642            del parent[payment.p_id]
     643        pass
    618644
    619645    def checkConversion(self, row, mode='ignore'):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r8858 r8885  
    10301030                mapping = {'a': ', '.join(deleted)}))
    10311031            self.context.writeLogMessage(
    1032                 self,'removed: % s' % ', '.join(deleted))
     1032                self,'removed: %s' % ', '.join(deleted))
    10331033        self.redirect(self.url(self.context))
    10341034        return
Note: See TracChangeset for help on using the changeset viewer.