- Timestamp:
- 22 Mar 2012, 07:21:20 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py
r7933 r7951 31 31 from zope.event import notify 32 32 from zope.catalog.interfaces import ICatalog 33 from hurry.workflow.interfaces import IWorkflowState 33 from hurry.workflow.interfaces import IWorkflowState, IWorkflowInfo 34 34 from waeup.kofa.interfaces import ( 35 35 IBatchProcessor, FatalCSVError, IObjectConverter, IUserAccount, 36 IObjectHistory )36 IObjectHistory, VALIDATED) 37 37 from waeup.kofa.students.interfaces import ( 38 38 IStudent, IStudentStudyCourse, 39 39 IStudentUpdateByRegNo, IStudentUpdateByMatricNo, 40 40 IStudentStudyLevel, ICourseTicket, 41 IStudentOnlinePayment )41 IStudentOnlinePayment, IStudentVerdictUpdate) 42 42 from waeup.kofa.students.workflow import IMPORTABLE_STATES 43 43 from waeup.kofa.utils.batching import BatchProcessor … … 639 639 return errs, inv_errs, conv_dict 640 640 return errs, inv_errs, conv_dict 641 642 class StudentVerdictProcessor(StudentStudyCourseProcessor): 643 """A batch processor for verdicts. 644 645 Import verdicts and perform workflow transitions. 646 """ 647 648 util_name = 'verdictupdater' 649 grok.name(util_name) 650 651 name = u'Verdict Processor (update only)' 652 iface = IStudentVerdictUpdate 653 factory_name = 'waeup.StudentStudyCourse' 654 655 @property 656 def available_fields(self): 657 return sorted(list(set( 658 ['student_id','reg_number','matric_number', 659 'current_session', 'current_level'] + getFields( 660 self.iface).keys()))) 661 662 def checkUpdateRequirements(self, obj, row, site): 663 """Checks requirements the studycourse and the student must fulfill 664 before being updated. 665 """ 666 # Check if current_levels correspond 667 if obj.current_level != row['current_level']: 668 return 'Current level does not correspond.' 669 # Check if current_sessions correspond 670 if obj.current_session != row['current_session']: 671 return 'Current session does not correspond.' 672 # Check if student is in state REGISTERED 673 if obj.getStudent().state != VALIDATED: 674 return 'Student in wrong state.' 675 return None 676 677 def updateEntry(self, obj, row, site): 678 """Update obj to the values given in row. 679 """ 680 items_changed = '' 681 for key, value in row.items(): 682 # Skip fields not declared in interface plus 683 # current_verdict and current_level 684 if hasattr(obj, key) and not key in [ 685 'current_verdict','current_level']: 686 setattr(obj, key, value) 687 items_changed += '%s=%s, ' % (key,value) 688 parent = self.getParent(row, site) 689 parent.__parent__.logger.info( 690 '%s - Verdict updated: %s' 691 % (parent.student_id, items_changed)) 692 # Fire transition 693 IWorkflowInfo(obj.__parent__).fireTransition('return') 694 # Update the students_catalog 695 notify(grok.ObjectModifiedEvent(obj.__parent__)) 696 return 697 698 def checkConversion(self, row, mode='ignore'): 699 """Validates all values in row. 700 """ 701 converter = IObjectConverter(self.iface) 702 errs, inv_errs, conv_dict = converter.fromStringDict( 703 row, self.factory_name) 704 return errs, inv_errs, conv_dict
Note: See TracChangeset for help on using the changeset viewer.