- Timestamp:
- 17 May 2019, 15:13:53 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py
r15409 r15414 1035 1035 1036 1036 We expect uploadfile to be a regular CSV file with columns 1037 ``student_id``, ``score`` and ``ca`` (other cols are ignored). 1037 ``student_id``, ``score``, ``imported_ts`` 1038 and ``ca`` (other cols are ignored). 1038 1039 """ 1039 1040 result = dict() … … 1041 1042 reader = csv.DictReader(data) 1042 1043 for row in reader: 1043 if not ('student_id' in row and 'score' in row and 'ca' in row): 1044 if not ('student_id' in row and 'score' in row and 'ca' in row and 1045 'imported_ts' in row): 1044 1046 continue 1045 result[row['student_id']] = (row['score'], row['ca']) 1047 result[row['student_id']] = ( 1048 row['score'], row['ca'], row['imported_ts']) 1046 1049 return result 1047 1050 … … 1063 1066 return False 1064 1067 else: 1065 formvals = dict(zip(form['sids'], zip(form['scores'], form['cas']))) 1068 formvals = dict(zip(form['sids'], zip( 1069 form['scores'], form['cas'], form['imported_tss']))) 1066 1070 for ticket in self.editable_tickets: 1067 1071 ticket_error = False 1068 1072 score = ticket.score 1069 1073 ca = ticket.ca 1074 imported_ts = ticket.imported_ts 1070 1075 sid = ticket.student.student_id 1071 1076 if formvals[sid][0] == '': … … 1073 1078 if formvals[sid][1] == '': 1074 1079 ca = None 1080 if formvals[sid][2] == '': 1081 imported_ts = None 1075 1082 try: 1076 1083 if formvals[sid][0]: … … 1078 1085 if formvals[sid][1]: 1079 1086 ca = int(formvals[sid][1]) 1087 if formvals[sid][2]: 1088 imported_ts = int(formvals[sid][2]) 1080 1089 except ValueError: 1081 1090 error += '%s, ' % ticket.student.display_fullname … … 1102 1111 (ob_class, ticket.student.student_id, 1103 1112 ticket.level, ticket.code, ca)) 1113 if not ticket_error and ticket.imported_ts != imported_ts: 1114 try: 1115 ticket.imported_ts = imported_ts 1116 except TooBig: 1117 error += '%s, ' % ticket.student.display_fullname 1118 pass 1119 ticket.student.__parent__.logger.info( 1120 '%s - %s %s/%s imported_ts updated (%s)' % 1121 (ob_class, ticket.student.student_id, 1122 ticket.level, ticket.code, imported_ts)) 1104 1123 if error: 1105 self.flash(_('Error: Score(s) and CA(s) of %s have not be updated. '1124 self.flash(_('Error: Score(s), CA(s) and Imported TS(s) of %s have not be updated. ' 1106 1125 % error.strip(', ')), type="danger") 1107 1126 return True
Note: See TracChangeset for help on using the changeset viewer.