- Timestamp:
- 17 Nov 2016, 14:16:13 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r14251 r14283 3132 3132 return result 3133 3133 3134 def update(self, *args, **kw): 3135 form = self.request.form 3134 def _update_scores(self, form, editable_tickets): 3136 3135 ob_class = self.__implemented__.__name__.replace('waeup.kofa.', '') 3137 self.current_academic_session = grok.getSite()[3138 'configuration'].current_academic_session3139 if self.context.__parent__.__parent__.score_editing_disabled:3140 self.flash(_('Score editing disabled.'), type="warning")3141 self.redirect(self.url(self.context))3142 return3143 if not self.current_academic_session:3144 self.flash(_('Current academic session not set.'), type="warning")3145 self.redirect(self.url(self.context))3146 return3147 self.session_title = academic_sessions_vocab.getTerm(3148 self.current_academic_session).title3149 self.tickets = self._searchCatalog(self.current_academic_session)3150 editable_tickets = [3151 ticket for ticket in self.tickets if ticket.editable_by_lecturer]3152 if not self.tickets:3153 self.flash(_('No student found.'), type="warning")3154 self.redirect(self.url(self.context))3155 return3156 if not 'UPDATE_TABLE' in form and not 'UPDATE_FILE' in form:3157 return3158 3136 error = '' 3159 if not editable_tickets:3160 return3161 3137 if 'UPDATE_FILE' in form: 3162 3138 if form['uploadfile']: … … 3167 3143 _('Uploaded file contains illegal data. Ignored'), 3168 3144 type="danger") 3169 return 3145 return False 3170 3146 else: 3171 3147 self.flash( 3172 3148 _('No file provided.'), type="danger") 3173 return 3149 return False 3174 3150 else: 3175 3151 formvals = dict(zip(form['sids'], form['scores'])) … … 3198 3174 'updated (only integers are allowed): %s.' % error.strip(', ')), 3199 3175 type="danger") 3200 return 3201 self.flash(_('You successfully updated course results.')) 3176 return True 3177 3178 def update(self, *args, **kw): 3179 form = self.request.form 3180 self.current_academic_session = grok.getSite()[ 3181 'configuration'].current_academic_session 3182 if self.context.__parent__.__parent__.score_editing_disabled: 3183 self.flash(_('Score editing disabled.'), type="warning") 3184 self.redirect(self.url(self.context)) 3185 return 3186 if not self.current_academic_session: 3187 self.flash(_('Current academic session not set.'), type="warning") 3188 self.redirect(self.url(self.context)) 3189 return 3190 self.session_title = academic_sessions_vocab.getTerm( 3191 self.current_academic_session).title 3192 self.tickets = self._searchCatalog(self.current_academic_session) 3193 editable_tickets = [ 3194 ticket for ticket in self.tickets if ticket.editable_by_lecturer] 3195 if not self.tickets: 3196 self.flash(_('No student found.'), type="warning") 3197 self.redirect(self.url(self.context)) 3198 return 3199 if not 'UPDATE_TABLE' in form and not 'UPDATE_FILE' in form: 3200 return 3201 if not editable_tickets: 3202 return 3203 success = self._update_scores(form, editable_tickets) 3204 if success: 3205 self.flash(_('You successfully updated course results.')) 3202 3206 return 3203 3207
Note: See TracChangeset for help on using the changeset viewer.