Exemplo n.º 1
0
 def _process(self):
     form_class = make_competences_form(self.event)
     user_competences = self.event.cfp.user_competences
     defaults = {
         'competences_{}'.format(user_id): competences.competences
         for user_id, competences in user_competences.iteritems()
     }
     form = form_class(obj=FormDefaults(defaults))
     if form.validate_on_submit():
         key_prefix = 'competences_'
         form_data = {
             int(key[len(key_prefix):]): value
             for key, value in form.data.iteritems()
         }
         users = {
             u.id: u
             for u in User.query.filter(User.id.in_(form_data),
                                        ~User.is_deleted)
         }
         for user_id, competences in form_data.iteritems():
             if user_id in user_competences:
                 update_competences(user_competences[user_id], competences)
             elif competences:
                 create_competences(self.event, users[user_id], competences)
         flash(_("Team competences were updated successfully"), 'success')
         return jsonify_data()
     return jsonify_template('events/papers/management/competences.html',
                             event=self.event,
                             form=form)
Exemplo n.º 2
0
 def _process(self):
     form_class = make_competences_form(self.event)
     user_competences = self.event.cfp.user_competences
     defaults = {'competences_{}'.format(user_id): competences.competences
                 for user_id, competences in user_competences.iteritems()}
     form = form_class(obj=FormDefaults(defaults))
     if form.validate_on_submit():
         key_prefix = 'competences_'
         form_data = {int(key[len(key_prefix):]): value for key, value in form.data.iteritems()}
         users = {u.id: u for u in User.query.filter(User.id.in_(form_data), ~User.is_deleted)}
         for user_id, competences in form_data.iteritems():
             if user_id in user_competences:
                 update_competences(user_competences[user_id], competences)
             elif competences:
                 create_competences(self.event, users[user_id], competences)
         flash(_("Team competences were updated successfully"), 'success')
         return jsonify_data()
     return jsonify_template('events/papers/management/competences.html', event=self.event, form=form)