Skip to content

Commit

Permalink
only list assignments with an authority set on right of reply homepage
Browse files Browse the repository at this point in the history
Otherwise you get an error when it's trying to generate the URLs as it
is looking for an authority. Plus it doesn't make sense.
  • Loading branch information
struan committed Nov 25, 2024
1 parent 914a869 commit 859381c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions crowdsourcer/tests/test_right_of_reply_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,24 @@ def test_council_homepage(self):
self.assertEqual(first.authority.name, "Aberdeen City Council")
self.assertEqual(second.authority.name, "Aberdeenshire Council")

def test_bad_assignments_ignored(self):
Assigned.objects.create(
marking_session=MarkingSession.objects.get(label="Default"),
user=self.user,
)
url = reverse("authority_ror_authorities")
response = self.client.get(url)

context = response.context
assignments = context["assignments"]

self.assertEqual(len(assignments), 2)

first = assignments[0]
second = assignments[1]
self.assertEqual(first.authority.name, "Aberdeen City Council")
self.assertEqual(second.authority.name, "Aberdeenshire Council")

def test_council_section_list(self):
url = reverse("authority_ror_sections", args=("Aberdeenshire Council",))
response = self.client.get(url)
Expand Down
4 changes: 3 additions & 1 deletion crowdsourcer/views/rightofreply.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def get_queryset(self):
if user.is_anonymous:
return None

qs = Assigned.objects.filter(user=user).order_by("authority__name")
qs = Assigned.objects.filter(user=user, authority__isnull=False).order_by(
"authority__name"
)

return qs

Expand Down

0 comments on commit 859381c

Please sign in to comment.