def _process(self): form = BulkPaperJudgmentForm(event=self.event, judgment=request.form.get('judgment'), contribution_id=[c.id for c in self.contributions]) if form.validate_on_submit(): submitted_papers = [c.paper for c in self.contributions if c.paper and c.paper.last_revision.state == PaperRevisionState.submitted] for submitted_paper in submitted_papers: judge_paper(submitted_paper, form.judgment.data, form.judgment_comment.data, judge=session.user) num_submitted_papers = len(submitted_papers) num_not_submitted_papers = len(self.contributions) - num_submitted_papers if num_submitted_papers: flash(ngettext("One paper has been judged.", "{num} papers have been judged.", num_submitted_papers).format(num=num_submitted_papers), 'success') if num_not_submitted_papers: flash(ngettext("One contribution has been skipped since it has no paper submitted yet or it is in " "a final state.", "{num} contributions have been skipped since they have no paper submitted yet or they " "are in a final state.", num_not_submitted_papers).format(num=num_not_submitted_papers), 'warning') return jsonify_data(**self.list_generator.render_list()) return jsonify_form(form=form, submit=_('Judge'), disabled_until_change=False)
def _process(self): form = BulkPaperJudgmentForm(event=self.event, judgment=request.form.get('judgment'), contribution_id=[c.id for c in self.contributions]) if form.validate_on_submit(): submitted_papers = [c.paper for c in self.contributions if c.paper and c.paper.last_revision.state == PaperRevisionState.submitted] for submitted_paper in submitted_papers: judge_paper(submitted_paper, form.judgment.data, form.judgment_comment.data, judge=session.user) num_submitted_papers = len(submitted_papers) num_not_submitted_papers = len(self.contributions) - num_submitted_papers if num_submitted_papers: flash(ngettext("One paper has been judged.", "{num} papers have been judged.", num_submitted_papers).format(num=num_submitted_papers), 'success') if num_not_submitted_papers: flash(ngettext("One contribution has been skipped since it has no paper submitted yet or it is in " "a final state.", "{num} contributions have been skipped since they have no paper submitted yet or they " "are in a final state.", num_not_submitted_papers).format(num=num_not_submitted_papers), 'warning') return jsonify_data(**self.list_generator.render_list()) return jsonify_form(form=form, submit=_('Judge'), disabled_until_change=False)