- Timestamp:
- 13 Jun 2016, 01:45:27 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/uli-scores-upload/src/waeup/kofa/students/browser.py
r13929 r13930 3136 3136 self.redirect(self.url(self.context)) 3137 3137 return 3138 if 'UPDATE' in form: 3139 error = '' 3140 if not editable_tickets: 3141 return 3142 formvals = dict(zip(form['sids'], form['scores'])) 3143 if form['uploadfile']: 3144 formvals = self._extract_uploadfile(form['uploadfile']) 3145 for ticket in editable_tickets: 3146 score = ticket.score 3147 sid = ticket.student.student_id 3148 if sid not in formvals: 3149 continue 3150 if formvals[sid] == '': 3151 score = None 3152 else: 3153 try: 3154 score = int(formvals[sid]) 3155 except ValueError: 3156 error += '%s, ' % ticket.student.display_fullname 3157 if ticket.score != score: 3158 ticket.score = score 3159 ticket.student.__parent__.logger.info( 3160 '%s - %s %s/%s score updated (%s)' % 3161 (ob_class, ticket.student.student_id, 3162 ticket.level, ticket.code, score)) 3163 #notify(grok.ObjectModifiedEvent(ticket)) 3164 if error: 3165 self.flash(_('Error: Score(s) of %s have not be updated. ' 3166 'Only integers are allowed.' % error.strip(', ')), 3167 type="danger") 3168 return 3138 if not 'UPDATE' in form: 3139 return 3140 error = '' 3141 if not editable_tickets: 3142 return 3143 formvals = dict(zip(form['sids'], form['scores'])) 3144 if form['uploadfile']: 3145 formvals = self._extract_uploadfile(form['uploadfile']) 3146 for ticket in editable_tickets: 3147 score = ticket.score 3148 sid = ticket.student.student_id 3149 if sid not in formvals: 3150 continue 3151 if formvals[sid] == '': 3152 score = None 3153 else: 3154 try: 3155 score = int(formvals[sid]) 3156 except ValueError: 3157 error += '%s, ' % ticket.student.display_fullname 3158 if ticket.score != score: 3159 ticket.score = score 3160 ticket.student.__parent__.logger.info( 3161 '%s - %s %s/%s score updated (%s)' % 3162 (ob_class, ticket.student.student_id, 3163 ticket.level, ticket.code, score)) 3164 if error: 3165 self.flash(_('Error: Score(s) of %s have not be updated. ' 3166 'Only integers are allowed.' % error.strip(', ')), 3167 type="danger") 3168 return 3169 3169 3170 3170 3171 class DownloadScoresView(UtilityView, grok.View):
Note: See TracChangeset for help on using the changeset viewer.