diff --git a/crowdsourcer/models.py b/crowdsourcer/models.py index 9678f0a..ee84fc8 100644 --- a/crowdsourcer/models.py +++ b/crowdsourcer/models.py @@ -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") diff --git a/crowdsourcer/views/rightofreply.py b/crowdsourcer/views/rightofreply.py index 331ee91..98f4a7a 100644 --- a/crowdsourcer/views/rightofreply.py +++ b/crowdsourcer/views/rightofreply.py @@ -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