Changeset 14283 for main


Ignore:
Timestamp:
17 Nov 2016, 14:16:13 (8 years ago)
Author:
Henrik Bettermann
Message:

Split update method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r14251 r14283  
    31323132        return result
    31333133
    3134     def update(self,  *args, **kw):
    3135         form = self.request.form
     3134    def _update_scores(self, form, editable_tickets):
    31363135        ob_class = self.__implemented__.__name__.replace('waeup.kofa.', '')
    3137         self.current_academic_session = grok.getSite()[
    3138             'configuration'].current_academic_session
    3139         if self.context.__parent__.__parent__.score_editing_disabled:
    3140             self.flash(_('Score editing disabled.'), type="warning")
    3141             self.redirect(self.url(self.context))
    3142             return
    3143         if not self.current_academic_session:
    3144             self.flash(_('Current academic session not set.'), type="warning")
    3145             self.redirect(self.url(self.context))
    3146             return
    3147         self.session_title = academic_sessions_vocab.getTerm(
    3148             self.current_academic_session).title
    3149         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             return
    3156         if not 'UPDATE_TABLE' in form and not 'UPDATE_FILE' in form:
    3157             return
    31583136        error = ''
    3159         if not editable_tickets:
    3160             return
    31613137        if 'UPDATE_FILE' in form:
    31623138            if form['uploadfile']:
     
    31673143                        _('Uploaded file contains illegal data. Ignored'),
    31683144                        type="danger")
    3169                     return
     3145                    return False
    31703146            else:
    31713147                self.flash(
    31723148                    _('No file provided.'), type="danger")
    3173                 return
     3149                return False
    31743150        else:
    31753151            formvals = dict(zip(form['sids'], form['scores']))
     
    31983174                    'updated (only integers are allowed): %s.' % error.strip(', ')),
    31993175                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.'))
    32023206        return
    32033207
Note: See TracChangeset for help on using the changeset viewer.