mirror of
https://github.com/pretix/pretix.git
synced 2026-09-13 16:14:40 +00:00
Event Settings: Make contact_url and imprint_url I18nURLField (Z#23238623) (#6506)
* Event Settings: Make contact_url and imprint_url I18nURLField (Z#23238623) * isort * Update doc/api/resources/events.rst --------- Co-authored-by: Raphael Michel <michel@pretix.eu>
This commit is contained in:
co-authored by
Raphael Michel
parent
edb4069e18
commit
2c15d8b074
@@ -566,7 +566,7 @@ organizer level.
|
|||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"imprint_url": "https://pretix.eu",
|
"region": "DE",
|
||||||
…
|
…
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -579,12 +579,14 @@ organizer level.
|
|||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"imprint_url":
|
"region":
|
||||||
{
|
{
|
||||||
"value": "https://pretix.eu",
|
"value": "DE",
|
||||||
"label": "Imprint URL",
|
"label": "Region",
|
||||||
"readonly": false,
|
"readonly": false,
|
||||||
"help_text": "This should point e.g. to a part of your website that has your contact details and legal information."
|
"help_text": "Will be used to determine date and time formatting as well as default country for customer
|
||||||
|
addresses and phone numbers. For formatting, this takes less priority than the language and
|
||||||
|
is therefore mostly relevant for languages used in different regions globally (like English)."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
…
|
…
|
||||||
@@ -620,7 +622,7 @@ organizer level.
|
|||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"imprint_url": "https://example.org/imprint/"
|
"region": "DE"
|
||||||
}
|
}
|
||||||
|
|
||||||
**Example response**:
|
**Example response**:
|
||||||
@@ -632,7 +634,7 @@ organizer level.
|
|||||||
Content-Type: application/json
|
Content-Type: application/json
|
||||||
|
|
||||||
{
|
{
|
||||||
"imprint_url": "https://example.org/imprint/",
|
"region": "DE",
|
||||||
…
|
…
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2314,25 +2314,27 @@ DEFAULTS = {
|
|||||||
},
|
},
|
||||||
'contact_url': {
|
'contact_url': {
|
||||||
'default': None,
|
'default': None,
|
||||||
'type': str,
|
'type': LazyI18nString,
|
||||||
'serializer_class': serializers.URLField,
|
'form_class': I18nURLFormField,
|
||||||
'form_class': forms.URLField,
|
|
||||||
'form_kwargs': dict(
|
'form_kwargs': dict(
|
||||||
label=_("Contact URL"),
|
label=_("Contact URL"),
|
||||||
help_text=_("If you set this, the footer contact link will point here instead of using the email address above. "
|
help_text=_("If you set this, the footer contact link will point here instead of using the email address above. "
|
||||||
"Please note that you still need to add a contact email address that will be shared with all emails you send.")
|
"Please note that you still need to add a contact email address that will be shared with all emails you send."),
|
||||||
)
|
widget=I18nTextInput,
|
||||||
|
),
|
||||||
|
'serializer_class': I18nURLField,
|
||||||
},
|
},
|
||||||
'imprint_url': {
|
'imprint_url': {
|
||||||
'default': None,
|
'default': None,
|
||||||
'type': str,
|
'type': LazyI18nString,
|
||||||
'form_class': forms.URLField,
|
'form_class': I18nURLFormField,
|
||||||
'form_kwargs': dict(
|
'form_kwargs': dict(
|
||||||
label=_("Imprint URL"),
|
label=_("Imprint URL"),
|
||||||
help_text=_("This should point e.g. to a part of your website that has your contact details and legal "
|
help_text=_("This should point e.g. to a part of your website that has your contact details and legal "
|
||||||
"information."),
|
"information."),
|
||||||
|
widget=I18nTextInput,
|
||||||
),
|
),
|
||||||
'serializer_class': serializers.URLField,
|
'serializer_class': I18nURLField,
|
||||||
},
|
},
|
||||||
'privacy_url': {
|
'privacy_url': {
|
||||||
'default': None,
|
'default': None,
|
||||||
|
|||||||
@@ -1434,8 +1434,12 @@ def test_get_event_settings(token_client, organizer, event):
|
|||||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||||
)
|
)
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
assert resp.data['imprint_url'] == "https://example.org"
|
assert resp.data['imprint_url'] == {
|
||||||
assert resp.data['contact_url'] == "https://example.org/contact"
|
"en": "https://example.org",
|
||||||
|
}
|
||||||
|
assert resp.data['contact_url'] == {
|
||||||
|
"en": "https://example.org/contact",
|
||||||
|
}
|
||||||
assert resp.data['seating_allow_blocked_seats_for_channel'] == []
|
assert resp.data['seating_allow_blocked_seats_for_channel'] == []
|
||||||
|
|
||||||
resp = token_client.get(
|
resp = token_client.get(
|
||||||
@@ -1443,7 +1447,9 @@ def test_get_event_settings(token_client, organizer, event):
|
|||||||
)
|
)
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
assert resp.data['imprint_url'] == {
|
assert resp.data['imprint_url'] == {
|
||||||
"value": "https://example.org",
|
"value": {
|
||||||
|
"en": "https://example.org",
|
||||||
|
},
|
||||||
"label": "Imprint URL",
|
"label": "Imprint URL",
|
||||||
"help_text": "This should point e.g. to a part of your website that has your contact details and legal "
|
"help_text": "This should point e.g. to a part of your website that has your contact details and legal "
|
||||||
"information.",
|
"information.",
|
||||||
@@ -1478,8 +1484,12 @@ def test_patch_event_settings(token_client, organizer, event, team):
|
|||||||
format='json'
|
format='json'
|
||||||
)
|
)
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
assert resp.data['contact_url'] == "https://example.com/contact"
|
assert resp.data['contact_url'] == {
|
||||||
assert resp.data['imprint_url'] == "https://example.com"
|
"en": "https://example.com/contact",
|
||||||
|
}
|
||||||
|
assert resp.data['imprint_url'] == {
|
||||||
|
"en": "https://example.com",
|
||||||
|
}
|
||||||
assert resp.data['seating_allow_blocked_seats_for_channel'] == ['web']
|
assert resp.data['seating_allow_blocked_seats_for_channel'] == ['web']
|
||||||
assert not resp.data['reusable_media_active']
|
assert not resp.data['reusable_media_active']
|
||||||
event.settings.flush()
|
event.settings.flush()
|
||||||
@@ -1542,8 +1552,12 @@ def test_patch_event_settings(token_client, organizer, event, team):
|
|||||||
format='json'
|
format='json'
|
||||||
)
|
)
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
assert resp.data['contact_url'] == "https://example.org/contact"
|
assert resp.data['contact_url'] == {
|
||||||
assert resp.data['imprint_url'] == "https://example.org"
|
"en": "https://example.org/contact",
|
||||||
|
}
|
||||||
|
assert resp.data['imprint_url'] == {
|
||||||
|
"en": "https://example.org",
|
||||||
|
}
|
||||||
event.settings.flush()
|
event.settings.flush()
|
||||||
assert event.settings.contact_url == 'https://example.org/contact'
|
assert event.settings.contact_url == 'https://example.org/contact'
|
||||||
assert event.settings.imprint_url == 'https://example.org'
|
assert event.settings.imprint_url == 'https://example.org'
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ from datetime import datetime
|
|||||||
import pytest
|
import pytest
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
from django_scopes import scopes_disabled
|
from django_scopes import scopes_disabled
|
||||||
|
from i18nfield.strings import LazyI18nString
|
||||||
from tests.const import SAMPLE_PNG
|
from tests.const import SAMPLE_PNG
|
||||||
|
|
||||||
TEST_ORGANIZER_RES = {
|
TEST_ORGANIZER_RES = {
|
||||||
@@ -165,9 +166,11 @@ def test_patch_settings(token_client, organizer):
|
|||||||
format='json'
|
format='json'
|
||||||
)
|
)
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
assert resp.data['contact_url'] == 'https://example.org/contact'
|
assert resp.data['contact_url'] == {
|
||||||
|
'en': 'https://example.org/contact',
|
||||||
|
}
|
||||||
organizer.settings.flush()
|
organizer.settings.flush()
|
||||||
assert organizer.settings.contact_url == 'https://example.org/contact'
|
assert organizer.settings.contact_url == LazyI18nString('https://example.org/contact')
|
||||||
|
|
||||||
resp = token_client.patch(
|
resp = token_client.patch(
|
||||||
'/api/v1/organizers/{}/settings/'.format(organizer.slug),
|
'/api/v1/organizers/{}/settings/'.format(organizer.slug),
|
||||||
|
|||||||
Reference in New Issue
Block a user