def _process(self): has_ratings = (AbstractReviewRating.query.join( AbstractReviewRating.review).join(AbstractReview.abstract).filter( ~Abstract.is_deleted, Abstract.event_new == self.event_new).has_rows()) defaults = FormDefaults( abstract_review_questions=self.event_new.abstract_review_questions, **abstracts_reviewing_settings.get_all(self.event_new)) form = AbstractReviewingSettingsForm(event=self.event_new, obj=defaults, has_ratings=has_ratings) if form.validate_on_submit(): data = form.data # XXX: we need to do this assignment for new questions, # but editing or deleting existing questions changes an # object that is already in the session so it's updated # in any case self.event_new.abstract_review_questions = data.pop( 'abstract_review_questions') abstracts_reviewing_settings.set_multi(self.event_new, data) flash(_('Abstract reviewing settings have been saved'), 'success') return jsonify_data() self.commit = False disabled_fields = form.RATING_FIELDS if has_ratings else () return jsonify_form(form, disabled_fields=disabled_fields)
def _process(self): defaults = FormDefaults(**abstracts_reviewing_settings.get_all(self.event)) form = AbstractReviewingSettingsForm(event=self.event, obj=defaults, has_ratings=self.ratings_query.has_rows()) if form.validate_on_submit(): data = form.data self._scale_ratings(data['scale_lower'], data['scale_upper']) abstracts_reviewing_settings.set_multi(self.event, data) flash(_('Abstract reviewing settings have been saved'), 'success') return jsonify_data() self.commit = False return jsonify_form(form)
def _process(self): has_ratings = (AbstractReviewRating.query .join(AbstractReviewRating.review) .join(AbstractReview.abstract) .join(AbstractReviewRating.question) .filter(~Abstract.is_deleted, Abstract.event == self.event, AbstractReviewQuestion.field_type == 'rating') .has_rows()) defaults = FormDefaults(**abstracts_reviewing_settings.get_all(self.event)) form = AbstractReviewingSettingsForm(event=self.event, obj=defaults, has_ratings=has_ratings) if form.validate_on_submit(): data = form.data abstracts_reviewing_settings.set_multi(self.event, data) flash(_('Abstract reviewing settings have been saved'), 'success') return jsonify_data() self.commit = False disabled_fields = form.RATING_FIELDS if has_ratings else () return jsonify_form(form, disabled_fields=disabled_fields)
def _process(self): has_ratings = (AbstractReviewRating.query .join(AbstractReviewRating.review) .join(AbstractReview.abstract) .filter(~Abstract.is_deleted, Abstract.event_new == self.event_new) .has_rows()) defaults = FormDefaults(abstract_review_questions=self.event_new.abstract_review_questions, **abstracts_reviewing_settings.get_all(self.event_new)) form = AbstractReviewingSettingsForm(event=self.event_new, obj=defaults, has_ratings=has_ratings) if form.validate_on_submit(): data = form.data # XXX: we need to do this assignment for new questions, # but editing or deleting existing questions changes an # object that is already in the session so it's updated # in any case self.event_new.abstract_review_questions = data.pop('abstract_review_questions') abstracts_reviewing_settings.set_multi(self.event_new, data) flash(_('Abstract reviewing settings have been saved'), 'success') return jsonify_data() self.commit = False disabled_fields = form.RATING_FIELDS if has_ratings else () return jsonify_form(form, disabled_fields=disabled_fields)