Formulaire public : logo et texte d'introduction personnalisables
FormTemplate porte désormais un logo (image, PUT/GET .../form/logo — GET public comme .../form/public, affiché sur /inscription) et un texte d'introduction libre (PATCH .../form, description désormais optionnelle comme is_open). Écran de configuration (/inscriptions) : nouveau panneau « Personnalisation » pour importer le logo et rédiger le texte. Le formulaire public affiche le logo en grand au-dessus du panneau et le texte juste sous le titre. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
48d3deec65
commit
957a004623
@@ -59,6 +59,71 @@ def test_closing_the_form(client, edition):
|
||||
assert resp.json()["is_open"] is False
|
||||
|
||||
|
||||
def test_setting_description_does_not_touch_is_open(client, edition):
|
||||
client.patch(_form_url(edition), json={"is_open": False})
|
||||
resp = client.patch(_form_url(edition), json={"description": "Bienvenue !"})
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["description"] == "Bienvenue !"
|
||||
assert resp.json()["is_open"] is False # inchangé, absent du corps
|
||||
|
||||
|
||||
def test_clearing_description_with_an_explicit_null(client, edition):
|
||||
client.patch(_form_url(edition), json={"description": "Bienvenue !"})
|
||||
resp = client.patch(_form_url(edition), json={"description": None})
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["description"] is None
|
||||
|
||||
|
||||
def test_logo_is_coordinator_only(edition, make_account, as_account):
|
||||
lead = make_account(Role.LEAD, email="lead@e.fr")
|
||||
lead_client = as_account(lead)
|
||||
resp = lead_client.put(
|
||||
_form_url(edition, "/logo"), files={"file": ("logo.png", io.BytesIO(_PNG), "image/png")}
|
||||
)
|
||||
assert resp.status_code == 403
|
||||
|
||||
|
||||
def test_no_logo_by_default(client, raw_client, edition):
|
||||
assert client.get(_form_url(edition)).json()["has_logo"] is False
|
||||
resp = raw_client.get(_form_url(edition, "/logo"))
|
||||
assert resp.status_code == 404
|
||||
|
||||
|
||||
def test_uploading_a_logo_and_reading_it_back_publicly(client, raw_client, edition):
|
||||
resp = client.put(
|
||||
_form_url(edition, "/logo"), files={"file": ("logo.png", io.BytesIO(_PNG), "image/png")}
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["has_logo"] is True
|
||||
|
||||
assert client.get(_form_url(edition)).json()["has_logo"] is True
|
||||
|
||||
logo = raw_client.get(_form_url(edition, "/logo"))
|
||||
assert logo.status_code == 200
|
||||
assert logo.headers["content-type"] == "image/png"
|
||||
assert logo.content == _PNG
|
||||
|
||||
|
||||
def test_uploading_an_unsupported_logo_type_is_rejected(client, edition):
|
||||
resp = client.put(
|
||||
_form_url(edition, "/logo"),
|
||||
files={"file": ("logo.gif", b"not-a-real-gif", "image/gif")},
|
||||
)
|
||||
assert resp.status_code == 422
|
||||
assert resp.json()["detail"]["code"] == "form.logo_type_not_supported"
|
||||
|
||||
|
||||
def test_public_config_reports_the_logo_and_description(client, raw_client, edition):
|
||||
client.patch(_form_url(edition), json={"description": "Bienvenue au festival !"})
|
||||
client.put(
|
||||
_form_url(edition, "/logo"), files={"file": ("logo.png", io.BytesIO(_PNG), "image/png")}
|
||||
)
|
||||
|
||||
body = raw_client.get(_form_url(edition, "/public")).json()
|
||||
assert body["description"] == "Bienvenue au festival !"
|
||||
assert body["has_logo"] is True
|
||||
|
||||
|
||||
def test_public_form_hides_positions_and_artists_unless_enabled(
|
||||
client, raw_client, edition, session
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user