Skip to content

Commit

Permalink
exclude exceptions from right of reply progress screen
Browse files Browse the repository at this point in the history
struan committed Nov 25, 2024
1 parent 870b3eb commit 842a168
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions crowdsourcer/models.py
Original file line number Diff line number Diff line change
@@ -261,6 +261,7 @@ def response_counts(
response_type=None,
question_types=None,
right_of_reply=False,
exceptions=[],
):
if response_type is None:
response_type = ResponseType.objects.get(type="First Mark")
@@ -283,6 +284,7 @@ def response_counts(
section__marking_session=marking_session,
how_marked__in=question_types,
)
.exclude(pk__in=exceptions)
.values("questiongroup")
.annotate(num_questions=Count("pk"))
.values("num_questions")
8 changes: 7 additions & 1 deletion crowdsourcer/views/rightofreply.py
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
SessionProperties,
SessionPropertyValues,
)
from crowdsourcer.scoring import get_exceptions_for_authority
from crowdsourcer.views.base import BaseQuestionView

logger = logging.getLogger(__name__)
@@ -71,6 +72,7 @@ def get_queryset(self):
raise PermissionDenied

authority = PublicAuthority.objects.get(name=self.kwargs["name"])
self.authority = authority
if user.is_superuser is False:
if hasattr(user, "marker"):
marker = user.marker
@@ -109,11 +111,14 @@ def get_context_data(self, **kwargs):
question_types = ["volunteer", "national_volunteer", "foi"]

response_type = ResponseType.objects.get(type="Right of Reply")
exceptions = get_exceptions_for_authority(
self.request.current_session, self.authority
)
for section in sections:
questions = Question.objects.filter(
section=section,
how_marked__in=question_types,
)
).exclude(pk__in=exceptions)
question_list = list(questions.values_list("id", flat=True))

authority = PublicAuthority.objects.get(name=context["authority_name"])
@@ -130,6 +135,7 @@ def get_context_data(self, **kwargs):
response_type=response_type,
question_types=question_types,
right_of_reply=True,
exceptions=exceptions,
).distinct()

section.complete = 0

0 comments on commit 842a168

Please sign in to comment.