Skip to content

Commit 78bc854

Browse files
authored
Correctly filter exact tags when getting the sponsorship brochure (#4271)
1 parent 7f6fe87 commit 78bc854

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

backend/sponsors/tests/test_views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def test_view_brochure_view_with_wrong_signature_fails(client):
3333

3434
def test_view_brochure_view(client):
3535
sponsor_lead = SponsorLeadFactory(brochure_viewed=False, conference__code="code")
36+
37+
other_brochure = DocumentFactory()
38+
other_brochure.tags.add("sponsorship-brochure", "other-code")
39+
3640
brochure = DocumentFactory()
3741
brochure.tags.add("sponsorship-brochure", sponsor_lead.conference.code)
3842

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)