diff --git a/CHANGELOG.md b/CHANGELOG.md index fb25f182..f8aabe61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +Parsifal 2.0.5 (2021-09-10) +=========================== + +Bugfixes +-------- + +- Improve quality assessment performance (#81) + + Parsifal 2.0.4 (2021-09-10) =========================== diff --git a/parsifal/__init__.py b/parsifal/__init__.py index f4daf158..53bbd973 100644 --- a/parsifal/__init__.py +++ b/parsifal/__init__.py @@ -1,5 +1,5 @@ from parsifal.utils.version import get_version -VERSION = (2, 0, 4, "final", 0) +VERSION = (2, 0, 5, "final", 0) __version__ = get_version(VERSION) diff --git a/parsifal/apps/reviews/conducting/views.py b/parsifal/apps/reviews/conducting/views.py index 01033b71..2747a54f 100644 --- a/parsifal/apps/reviews/conducting/views.py +++ b/parsifal/apps/reviews/conducting/views.py @@ -11,7 +11,7 @@ from django.shortcuts import get_object_or_404, redirect, render from django.template.context_processors import csrf from django.urls import reverse as r -from django.utils.html import escape, format_html +from django.utils.html import escape from django.utils.translation import gettext as _ from django.views.decorators.http import require_POST @@ -237,6 +237,14 @@ def build_quality_assessment_table(request, review, order): quality_questions = review.get_quality_assessment_questions() quality_answers = review.get_quality_assessment_answers() + csrf_token = csrf(request)["csrf_token"] + + quality_index = {} + for study in selected_studies: + quality_index[study.pk] = {} + for qa in study.qualityassessment_set.all(): + quality_index[study.pk][qa.question_id] = qa.answer_id + if quality_questions and quality_answers: str_table = "" for study in selected_studies: @@ -248,31 +256,27 @@ def build_quality_assessment_table(request, review, order):
{question_description} | ', + str_table += '||
{question_description} | '.format( question_id=question.pk, - question_description=question.description, + question_description=escape(question.description), ) - question_answer_id = None - for qa in study.qualityassessment_set.all(): - if qa.question_id == question.pk: - question_answer_id = qa.answer_id - break + question_answer_id = quality_index[study.pk].get(question.pk) for answer in quality_answers: selected_answer = "" if answer.id == question_answer_id: selected_answer = " selected-answer" - str_table += format_html( - '{answer_description} | ', - selected=selected_answer, - answer_id=answer.pk, - answer_description=answer.description, + str_table += ( + '{answer_description} | '.format( + selected=selected_answer, + answer_id=answer.pk, + answer_description=escape(answer.description), + ) ) str_table += "