mirror of
https://github.com/pretix/pretix.git
synced 2026-05-03 14:54:04 +00:00
Replace SCSS compilation with CSS variables (#4191)
* Replace SCSS compilation with CSS variables * Update tests * Update src/pretix/presale/style.py Co-authored-by: Mira <weller@rami.io> * Update src/pretix/presale/context.py Co-authored-by: Mira <weller@rami.io> * Update src/pretix/presale/views/widget.py Co-authored-by: Mira <weller@rami.io> * Update src/pretix/presale/context.py Co-authored-by: Mira <weller@rami.io> * Update src/pretix/static/pretixbase/scss/_variables.scss Co-authored-by: Richard Schreiber <schreiber@rami.io> * Last minor changes * Rename file --------- Co-authored-by: Mira <weller@rami.io> Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
@@ -49,7 +49,6 @@ from pretix.base.models import (
|
||||
Event, InvoiceAddress, Order, OrderPosition, Organizer, SeatingPlan,
|
||||
)
|
||||
from pretix.base.models.orders import OrderFee
|
||||
from pretix.testutils.mock import mocker_context
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -1244,121 +1243,117 @@ def test_get_event_settings(token_client, organizer, event):
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_patch_event_settings(token_client, organizer, event):
|
||||
with mocker_context() as mocker:
|
||||
mocked = mocker.patch('pretix.presale.style.regenerate_css.apply_async')
|
||||
organizer.settings.imprint_url = 'https://example.org'
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'imprint_url': 'https://example.com',
|
||||
'confirm_texts': [
|
||||
{
|
||||
'de': 'Ich bin mit den AGB einverstanden.'
|
||||
}
|
||||
],
|
||||
'reusable_media_active': True, # readonly, ignored
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.data['imprint_url'] == "https://example.com"
|
||||
assert not resp.data['reusable_media_active']
|
||||
event.settings.flush()
|
||||
assert event.settings.imprint_url == 'https://example.com'
|
||||
assert not event.settings.reusable_media_active
|
||||
assert event.all_logentries().filter(action_type="pretix.event.settings").count() == 1
|
||||
mocked.assert_not_called()
|
||||
organizer.settings.imprint_url = 'https://example.org'
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'imprint_url': 'https://example.com',
|
||||
'confirm_texts': [
|
||||
{
|
||||
'de': 'Ich bin mit den AGB einverstanden.'
|
||||
}
|
||||
],
|
||||
'reusable_media_active': True, # readonly, ignored
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.data['imprint_url'] == "https://example.com"
|
||||
assert not resp.data['reusable_media_active']
|
||||
event.settings.flush()
|
||||
assert event.settings.imprint_url == 'https://example.com'
|
||||
assert not event.settings.reusable_media_active
|
||||
assert event.all_logentries().filter(action_type="pretix.event.settings").count() == 1
|
||||
|
||||
# The same settings again do not create a new log entry
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'imprint_url': 'https://example.com',
|
||||
'confirm_texts': [
|
||||
{
|
||||
'de': 'Ich bin mit den AGB einverstanden.'
|
||||
}
|
||||
],
|
||||
'reusable_media_active': True, # readonly, ignored
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert event.all_logentries().filter(action_type="pretix.event.settings").count() == 1
|
||||
# The same settings again do not create a new log entry
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'imprint_url': 'https://example.com',
|
||||
'confirm_texts': [
|
||||
{
|
||||
'de': 'Ich bin mit den AGB einverstanden.'
|
||||
}
|
||||
],
|
||||
'reusable_media_active': True, # readonly, ignored
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert event.all_logentries().filter(action_type="pretix.event.settings").count() == 1
|
||||
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'primary_color': '#ff0000',
|
||||
'theme_color_background': '#ff0000',
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
event.settings.flush()
|
||||
mocked.assert_any_call(args=(event.pk,))
|
||||
assert event.settings.primary_color == '#ff0000'
|
||||
assert event.all_logentries().filter(action_type="pretix.event.settings").count() == 2
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'primary_color': '#ff0000',
|
||||
'theme_color_background': '#ff0000',
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
event.settings.flush()
|
||||
assert event.settings.primary_color == '#ff0000'
|
||||
assert event.all_logentries().filter(action_type="pretix.event.settings").count() == 2
|
||||
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'primary_color': None,
|
||||
'theme_color_background': None,
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
event.settings.flush()
|
||||
assert event.settings.primary_color != '#ff0000'
|
||||
assert 'primary_color' not in event.settings._cache()
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'primary_color': None,
|
||||
'theme_color_background': None,
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
event.settings.flush()
|
||||
assert event.settings.primary_color != '#ff0000'
|
||||
assert 'primary_color' not in event.settings._cache()
|
||||
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'imprint_url': None,
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.data['imprint_url'] == "https://example.org"
|
||||
event.settings.flush()
|
||||
assert event.settings.imprint_url == 'https://example.org'
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'imprint_url': None,
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.data['imprint_url'] == "https://example.org"
|
||||
event.settings.flush()
|
||||
assert event.settings.imprint_url == 'https://example.org'
|
||||
|
||||
resp = token_client.put(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'imprint_url': 'invalid'
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 405
|
||||
resp = token_client.put(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'imprint_url': 'invalid'
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 405
|
||||
|
||||
locales = event.settings.locales
|
||||
locales = event.settings.locales
|
||||
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'locales': event.settings.locales + ['de', 'de-informal'],
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert set(resp.data['locales']) == set(locales + ['de', 'de-informal'])
|
||||
event.settings.flush()
|
||||
assert set(event.settings.locales) == set(locales + ['de', 'de-informal'])
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'locales': event.settings.locales + ['de', 'de-informal'],
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert set(resp.data['locales']) == set(locales + ['de', 'de-informal'])
|
||||
event.settings.flush()
|
||||
assert set(event.settings.locales) == set(locales + ['de', 'de-informal'])
|
||||
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'locales': locales,
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert set(resp.data['locales']) == set(locales)
|
||||
event.settings.flush()
|
||||
assert set(event.settings.locales) == set(locales)
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/events/{}/settings/'.format(organizer.slug, event.slug),
|
||||
{
|
||||
'locales': locales,
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert set(resp.data['locales']) == set(locales)
|
||||
event.settings.flush()
|
||||
assert set(event.settings.locales) == set(locales)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
||||
@@ -23,8 +23,6 @@ import pytest
|
||||
from django.core.files.base import ContentFile
|
||||
from tests.const import SAMPLE_PNG
|
||||
|
||||
from pretix.testutils.mock import mocker_context
|
||||
|
||||
TEST_ORGANIZER_RES = {
|
||||
"name": "Dummy",
|
||||
"slug": "dummy",
|
||||
@@ -69,62 +67,57 @@ def test_get_settings(token_client, organizer):
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_patch_settings(token_client, organizer):
|
||||
with mocker_context() as mocker:
|
||||
mocked = mocker.patch('pretix.presale.style.regenerate_organizer_css.apply_async')
|
||||
organizer.settings.event_list_type = 'week'
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/settings/'.format(organizer.slug),
|
||||
{
|
||||
'event_list_type': 'list'
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.data['event_list_type'] == "list"
|
||||
organizer.settings.flush()
|
||||
assert organizer.settings.event_list_type == 'list'
|
||||
|
||||
organizer.settings.event_list_type = 'week'
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/settings/'.format(organizer.slug),
|
||||
{
|
||||
'event_list_type': 'list'
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.data['event_list_type'] == "list"
|
||||
organizer.settings.flush()
|
||||
assert organizer.settings.event_list_type == 'list'
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/settings/'.format(organizer.slug),
|
||||
{
|
||||
'event_list_type': None,
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.data['event_list_type'] == "list"
|
||||
organizer.settings.flush()
|
||||
assert organizer.settings.event_list_type == 'list'
|
||||
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/settings/'.format(organizer.slug),
|
||||
{
|
||||
'event_list_type': None,
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.data['event_list_type'] == "list"
|
||||
organizer.settings.flush()
|
||||
assert organizer.settings.event_list_type == 'list'
|
||||
mocked.assert_not_called()
|
||||
resp = token_client.put(
|
||||
'/api/v1/organizers/{}/settings/'.format(organizer.slug),
|
||||
{
|
||||
'event_list_type': 'put-not-allowed'
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 405
|
||||
|
||||
resp = token_client.put(
|
||||
'/api/v1/organizers/{}/settings/'.format(organizer.slug),
|
||||
{
|
||||
'event_list_type': 'put-not-allowed'
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 405
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/settings/'.format(organizer.slug),
|
||||
{
|
||||
'primary_color': 'invalid-color'
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 400
|
||||
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/settings/'.format(organizer.slug),
|
||||
{
|
||||
'primary_color': 'invalid-color'
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 400
|
||||
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/settings/'.format(organizer.slug),
|
||||
{
|
||||
'primary_color': '#ff0000'
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
mocked.assert_any_call(args=(organizer.pk,))
|
||||
resp = token_client.patch(
|
||||
'/api/v1/organizers/{}/settings/'.format(organizer.slug),
|
||||
{
|
||||
'primary_color': '#ff0000'
|
||||
},
|
||||
format='json'
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
||||
Reference in New Issue
Block a user