Skip to content

Commit b6bd9ac

Browse files
authored
Update hotels hack with a better approach (#4506)
1 parent 19f667c commit b6bd9ac

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

backend/api/cms/page/queries/cms_page.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ def cms_page(
3030
)
3131
can_see_page = None
3232

33-
if password_restriction and password_restriction.password == "ticket":
33+
if (
34+
password_restriction
35+
and password_restriction.password
36+
and password_restriction.password.startswith("ticket-")
37+
):
3438
from conferences.models import Conference
3539

36-
# hack so we can go live with this feature for now :)
37-
conference = Conference.objects.get(code="pycon2026")
40+
conference_code = password_restriction.password.split("-")[1]
41+
conference = Conference.objects.get(code=conference_code)
3842

3943
user = info.context.request.user
4044
can_see_page = user.is_authenticated and user_has_admission_ticket(

backend/api/cms/tests/page/queries/test_cms_page.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_page(graphql_client, locale):
5454
"title": "Bubble",
5555
"slug": "bubble-tea",
5656
"body": [
57-
{"title": "I've Got a Lovely Bunch of " "Coconuts"},
57+
{"title": "I've Got a Lovely Bunch of Coconuts"},
5858
{
5959
"latitude": "43.766199999999997771737980656325817108154296875", # noqa: E501
6060
"longitude": "3.140000000000000124344978758017532527446746826171875", # noqa: E501
@@ -90,7 +90,7 @@ def test_page_with_ticket_restriction_and_ticket_returns_content(
9090
)
9191
page.save_revision().publish()
9292
PageViewRestriction.objects.create(
93-
page=page, restriction_type="password", password="ticket"
93+
page=page, restriction_type="password", password="ticket-pycon2025"
9494
)
9595
SiteFactory(hostname="pycon", port=80, root_page=parent)
9696
page.copy_for_translation(locale=locale("it"))
@@ -161,7 +161,7 @@ def test_page_with_ticket_restriction_without_ticket_returns_first_block(
161161
)
162162
page.save_revision().publish()
163163
PageViewRestriction.objects.create(
164-
page=page, restriction_type="password", password="ticket"
164+
page=page, restriction_type="password", password="ticket-pycon2025"
165165
)
166166
SiteFactory(hostname="pycon", port=80, root_page=parent)
167167
page.copy_for_translation(locale=locale("it"))
@@ -197,7 +197,7 @@ def test_page_with_ticket_restriction_without_ticket_returns_first_block(
197197
"title": "Bubble",
198198
"slug": "bubble-tea",
199199
"body": [
200-
{"title": "I've Got a Lovely Bunch of " "Coconuts"},
200+
{"title": "I've Got a Lovely Bunch of Coconuts"},
201201
],
202202
}
203203
}

0 commit comments

Comments
 (0)