Skip to content

Commit 4c2fa2a

Browse files
committed
Correctly filter exact tags when getting the sponsorship brochure
1 parent 7f6fe87 commit 4c2fa2a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

backend/sponsors/tests/test_views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def test_view_brochure_view(client):
3636
brochure = DocumentFactory()
3737
brochure.tags.add("sponsorship-brochure", sponsor_lead.conference.code)
3838

39+
other_brochure = DocumentFactory()
40+
other_brochure.tags.add("sponsorship-brochure", "other-code")
41+
3942
view_brochure_url_path = reverse("view-brochure", args=[sponsor_lead.id])
4043
signer = Signer()
4144
signature = signer.sign(view_brochure_url_path).split(signer.sep)[-1]

backend/sponsors/views.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ def view_brochure(request, sponsor_lead_id):
1212
sponsor_lead.save(update_fields=["brochure_viewed"])
1313

1414
Document = get_document_model()
15-
brochure = Document.objects.filter(
16-
tags__name__in=["sponsorship-brochure", sponsor_lead.conference.code],
17-
).first()
15+
brochure = (
16+
Document.objects.filter(tags__name="sponsorship-brochure")
17+
.filter(tags__name=sponsor_lead.conference.code)
18+
.first()
19+
)
1820

1921
return redirect(brochure.url, permanent=False)

0 commit comments

Comments
 (0)