- Timestamp:
- 27 Feb 2008, 06:56:25 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/WAeUPImport.py
r3233 r3243 386 386 if not mapping.get('code',''): 387 387 msg = "code is missing" 388 break 388 break 389 389 student_id = student_record.id 390 390 level_id = mapping['level_id'] … … 411 411 if not mapping.get('code',''): 412 412 msg = "code is missing" 413 break 413 break 414 414 student_id = student_record.id 415 415 level_id = mapping['level_id'] … … 859 859 commit_after = 100000 860 860 required_modes = ('create','edit') 861 862 def edit(self,mapping):863 "edit student verdicts "861 862 def create(self,mapping): 863 "edit student verdicts and create StudentStudyLevel object if not existent" 864 864 wftool = self.portal_workflow 865 865 logger = logging.getLogger('WAeUPTool.mass_edit_verdict') … … 928 928 break 929 929 level_obj = getattr(study_course_obj,current_level,None) 930 930 931 if level_obj is None: 931 msg = 'student %s: no study_level object for level %s' % (student_id, 932 current_level) 933 break 932 # The only difference to the edit method is that we create a StudentStudyLevel object 933 try: 934 study_course_obj.invokeFactory('StudentStudyLevel',"%s" % current_level) 935 level_obj = getattr(context,"%s" % current_level) 936 level_obj.portal_workflow.doActionFor(level,'open') 937 except: 938 continue 939 #msg = 'student %s: no study_level object for level %s' % (student_id, 940 # current_level) 941 #break 942 934 943 verdict = d['verdict'] = d['current_verdict'] = mapping.get('current_verdict','') 935 944 … … 953 962 # pass 954 963 break 964 return student_id,msg,mapping 965 966 967 def edit(self,mapping): 968 "edit student verdicts" 969 wftool = self.portal_workflow 970 logger = logging.getLogger('WAeUPTool.mass_edit_verdict') 971 students_folder = self.portal_url.getPortalObject().campus.students 972 student_id = mapping.get('id',None) 973 matric_no = mapping.get('matric_no',None) 974 editable_keys = mapping.keys() 975 while True: 976 key = '' 977 msg = '' 978 if student_id: 979 student_record = self.students_catalog.getRecordByKey(student_id) 980 if student_record is None: 981 #return '',"no student with id %s" % student_id 982 msg = "no student with id %s" % student_id 983 break 984 if matric_no and student_record.matric_no and matric_no != student_record.matric_no: 985 msg = 'student %s: matric_no %s does not match %s' % (student_record.id, 986 student_record.matric_no, 987 matric_no) 988 break 989 mapping['matric_no'] = student_record.matric_no 990 elif matric_no: 991 res = self.students_catalog(matric_no = matric_no) 992 if not res: 993 msg = "no student with matric_no %s" % matric_no 994 break 995 student_record = res[0] 996 editable_keys.remove('matric_no') 997 else: 998 msg = "no id or matric_no specified" 999 break 1000 student_id = student_record.id 1001 mapping['id'] = student_id 1002 d = {} 1003 #import pdb;pdb.set_trace() 1004 any_change = False 1005 #special treatment for StudentStudyLevel 1006 current_session = d['session'] = mapping.get('current_session','') 1007 if current_session and student_record.session != current_session: 1008 msg = 'student %s: imported session %s does not match current_session %s' % (student_id, 1009 current_session, 1010 student_record.session) 1011 break 1012 current_level = mapping.get('current_level','') 1013 if not current_level.isdigit(): 1014 msg = 'student %s: imported level is empty' % (student_id,) 1015 break 1016 if current_level and student_record.level != current_level: 1017 msg = 'student %s: imported level %s does not match current_level %s' % (student_id, 1018 current_level, 1019 student_record.level) 1020 break 1021 student_review_state = student_record.review_state 1022 if student_review_state == 'deactivated': 1023 msg = "student %s in review_state %s" % (student_id, student_review_state) 1024 break 1025 if student_review_state not in ('courses_validated','returning'): 1026 msg = "student %s in wrong review_state %s" % (student_id, student_review_state) 1027 break 1028 student_obj = getattr(students_folder,student_id) 1029 # f2t = self.field2types_student 1030 study_course_obj = getattr(student_obj,'study_course',None) 1031 if study_course_obj is None: 1032 msg = 'student %s: no study_course object' % student_id 1033 break 1034 level_obj = getattr(study_course_obj,current_level,None) 1035 if level_obj is None: 1036 msg = 'student %s: no study_level object for level %s' % (student_id, 1037 current_level) 1038 break 1039 verdict = d['verdict'] = d['current_verdict'] = mapping.get('current_verdict','') 1040 1041 #if verdict == student_record.verdict: 1042 # msg = 'student %s: verdict already set to %s' % (student_id, 1043 # verdict) 1044 1045 level_review_state = wftool.getInfoFor(level_obj,'review_state',None) 1046 if level_review_state != "closed": 1047 wftool.doActionFor(level_obj,'close') 1048 # msg = 'student %s: level %s is not closed' % (student_id, 1049 # current_level) 1050 1051 study_course_obj.getContent().edit(mapping = d) 1052 level_obj.getContent().edit(mapping = d) 1053 if student_review_state != "returning": 1054 wftool.doActionFor(student_obj,'return') 1055 # try: 1056 # wftool.doActionFor(level_obj,'close') 1057 # except: 1058 # pass 1059 break 955 1060 return student_id,msg,mapping 956 1061 ###)
Note: See TracChangeset for help on using the changeset viewer.