Ignore:
Timestamp:
16 Feb 2013, 18:22:16 (12 years ago)
Author:
Henrik Bettermann
Message:

Re-use the student's transfer method for batch processing.

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

Legend:

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

    r9960 r9962  
    428428        entry_mode = row.get('entry_mode', None)
    429429        certificate = row.get('certificate', None)
    430         # If students are being transferred a new studycourse is created and
    431         # the old one is moved.
     430        current_session = row.get('current_session', None)
     431        student = self.getParent(row, site)
    432432        if entry_mode == 'transfer':
    433             studycourse = createObject(u'waeup.StudentStudyCourse')
    434             student = obj.__parent__
    435             studycourse.entry_session = obj.entry_session
    436             if 'studycourse_1' in student.keys():
    437                 student['studycourse_2'] = obj
    438             else:
    439                 student['studycourse_1'] = obj
    440             del student['studycourse']
    441             student['studycourse'] = studycourse
    442             student.__parent__.logger.info(
    443                 '%s - transferred from %s to %s' % (
    444                 student.student_id, obj.certificate.code, certificate.code))
    445             history = IObjectHistory(student)
    446             history.addMessage('Transferred from %s to %s' % (
    447                 obj.certificate.code, certificate.code))
     433            # We do not expect any error here since we
     434            # checked all constraints in checkConversion and
     435            # in checkUpdateRequirements
     436            student.transfer(
     437                certificate=certificate, current_session=current_session)
    448438            obj = student['studycourse']
    449439        items_changed = super(StudentStudyCourseProcessor, self).updateEntry(
    450440            obj, row, site, filename)
    451         parent = self.getParent(row, site)
    452         parent.__parent__.logger.info(
     441        student.__parent__.logger.info(
    453442            '%s - %s - %s - updated: %s'
    454             % (self.name, filename, parent.student_id, items_changed))
     443            % (self.name, filename, student.student_id, items_changed))
    455444        # Update the students_catalog
    456         notify(grok.ObjectModifiedEvent(obj.__parent__))
     445        notify(grok.ObjectModifiedEvent(student))
    457446        return
    458447
  • main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py

    r9960 r9962  
    460460        )
    461461
    462     entry_mode = schema.Choice(
    463         title = _(u'Entry Mode'),
    464         source = StudyModeSource(),
    465         required = False,
    466         readonly = False,
    467         )
    468 
    469462    entry_session = schema.Choice(
    470463        title = _(u'Entry Session'),
  • main/waeup.kofa/trunk/src/waeup/kofa/students/student.py

    r9761 r9962  
    225225
    226226        """
    227         studycourse = createObject(u'waeup.StudentStudyCourse')
     227        newcourse = createObject(u'waeup.StudentStudyCourse')
    228228        try:
    229             studycourse.certificate = certificate
    230             studycourse.entry_mode = 'transfer'
    231             studycourse.current_session = current_session
    232             studycourse.current_level = current_level
    233             studycourse.current_verdict = current_verdict
    234             studycourse.previous_verdict = previous_verdict
     229            newcourse.certificate = certificate
     230            newcourse.entry_mode = 'transfer'
     231            newcourse.current_session = current_session
     232            newcourse.current_level = current_level
     233            newcourse.current_verdict = current_verdict
     234            newcourse.previous_verdict = previous_verdict
    235235        except ConstraintNotSatisfied:
    236236            return -1
    237         old = self['studycourse']
    238         if getattr(old, 'entry_session', None) is None or\
    239             getattr(old, 'certificate', None) is None:
     237        oldcourse = self['studycourse']
     238        if getattr(oldcourse, 'entry_session', None) is None or\
     239            getattr(oldcourse, 'certificate', None) is None:
    240240            return -2
    241         studycourse.entry_session = old.entry_session
     241        newcourse.entry_session = oldcourse.entry_session
    242242        # Students can be transferred only two times.
    243243        if 'studycourse_1' in self.keys():
    244244            if 'studycourse_2' in self.keys():
    245245                return -3
    246             self['studycourse_2'] = old
     246            self['studycourse_2'] = oldcourse
    247247        else:
    248             self['studycourse_1'] = old
     248            self['studycourse_1'] = oldcourse
    249249        del self['studycourse']
    250         self['studycourse'] = studycourse
     250        self['studycourse'] = newcourse
    251251        self.__parent__.logger.info(
    252252            '%s - transferred from %s to %s' % (
    253             self.student_id, old.certificate.code, studycourse.certificate.code))
     253            self.student_id, oldcourse.certificate.code, newcourse.certificate.code))
    254254        history = IObjectHistory(self)
    255255        history.addMessage('Transferred from %s to %s' % (
    256             old.certificate.code, studycourse.certificate.code))
     256            oldcourse.certificate.code, newcourse.certificate.code))
    257257        return
    258258
Note: See TracChangeset for help on using the changeset viewer.