Skip to content

Commit

Permalink
fix council progress reporting screens
Browse files Browse the repository at this point in the history
more null_responses fixes
  • Loading branch information
struan committed Nov 19, 2024
1 parent 9f19299 commit 73353e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
11 changes: 7 additions & 4 deletions crowdsourcer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ def response_counts(
if question_types is None:
question_types = Question.VOLUNTEER_TYPES

stage_name = ""
if right_of_reply:
null_responses = Response.objects.filter(agree_with_response__isnull=True)
else:
null_responses = Response.null_responses()
stage_name = "Right of Reply"
null_responses = Response.null_responses(stage_name=stage_name)

authorities = cls.objects.filter(
marking_session=marking_session, questiongroup__question__in=questions
Expand Down Expand Up @@ -394,7 +394,10 @@ def evidence_links(self):
return links

@classmethod
def null_responses(cls):
def null_responses(cls, stage_name=""):
if stage_name == "Right of Reply":
return cls.objects.filter(agree_with_response__isnull=True)

return cls.objects.filter(option__isnull=True, multi_option__isnull=True)


Expand Down
11 changes: 8 additions & 3 deletions crowdsourcer/views/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def get_queryset(self):
authority=OuterRef("pk"),
response_type=response_type,
)
.exclude(id__in=Response.null_responses())
.exclude(id__in=Response.null_responses(stage_name=self.stage))
.values("authority")
.annotate(response_count=Count("question_id", distinct=True))
.values("response_count")
Expand Down Expand Up @@ -195,7 +195,7 @@ def get_context_data(self, **kwargs):
question__in=question_list,
response_type=stage,
)
.exclude(id__in=Response.null_responses())
.exclude(id__in=Response.null_responses(stage_name=self.stage))
.values("authority")
.annotate(response_count=Count("question_id", distict=True))
.values("response_count")
Expand Down Expand Up @@ -288,7 +288,11 @@ def get_context_data(self, **kwargs):
authority=OuterRef("pk"),
response_type=rt,
)
.exclude(id__in=Response.null_responses())
.exclude(
id__in=Response.null_responses(
stage_name=self.request.current_stage.type
)
)
.values("authority")
.annotate(
response_count=Count("question_id", distinct=True)
Expand Down Expand Up @@ -478,6 +482,7 @@ def get_context_data(self, **kwargs):
self.request.current_session,
response_type=response_types,
question_types=types,
right_of_reply=True,
)
.annotate(
num_challenges=Subquery(
Expand Down

0 comments on commit 73353e6

Please sign in to comment.