mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Include global settings in event/organizer settings
Also, add tests
This commit is contained in:
committed by
Raphael Michel
parent
c647aa9f4e
commit
c5fdf7c215
@@ -58,7 +58,8 @@ class Organizer(LoggedModel):
|
||||
"""
|
||||
Returns an object representing this organizer's settings
|
||||
"""
|
||||
return SettingsProxy(self, type=OrganizerSetting)
|
||||
from pretix.base.settings import GlobalSettingsObject
|
||||
return SettingsProxy(self, type=OrganizerSetting, parent=GlobalSettingsObject())
|
||||
|
||||
def get_cache(self) -> "pretix.base.cache.ObjectRelatedCache":
|
||||
"""
|
||||
|
||||
@@ -11,6 +11,7 @@ from django.db.models import Model
|
||||
from django.utils.translation import ugettext_noop
|
||||
|
||||
from pretix.base.i18n import LazyI18nString
|
||||
from pretix.base.models.settings import GlobalSetting
|
||||
|
||||
DEFAULTS = {
|
||||
'max_items_per_order': {
|
||||
@@ -511,3 +512,10 @@ class SettingsSandbox:
|
||||
|
||||
def set(self, key: str, value: Any):
|
||||
self._event.settings.set(self._convert_key(key), value)
|
||||
|
||||
|
||||
class GlobalSettingsObject:
|
||||
def __init__(self):
|
||||
self.settings = SettingsProxy(self, type=GlobalSetting)
|
||||
self.setting_objects = GlobalSetting.objects
|
||||
self.slug = 'GLOBALSETTINGS'
|
||||
|
||||
@@ -4,18 +4,10 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from pretix.base.forms import SettingsForm
|
||||
from pretix.base.i18n import I18nFormField, I18nTextInput
|
||||
from pretix.base.models.settings import GlobalSetting
|
||||
from pretix.base.settings import SettingsProxy
|
||||
from pretix.base.settings import GlobalSettingsObject
|
||||
from pretix.base.signals import register_global_settings
|
||||
|
||||
|
||||
class GlobalSettingsObject:
|
||||
def __init__(self):
|
||||
self.settings = SettingsProxy(self, type=GlobalSetting)
|
||||
self.setting_objects = GlobalSetting.objects
|
||||
self.slug = 'GLOBALSETTINGS'
|
||||
|
||||
|
||||
class GlobalSettingsForm(SettingsForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.obj = GlobalSettingsObject()
|
||||
|
||||
@@ -92,7 +92,7 @@ class OrganizerPermissionRequiredMixin:
|
||||
return organizer_permission_required(cls.permission)(view)
|
||||
|
||||
|
||||
def administrator_permission_required(permission):
|
||||
def administrator_permission_required():
|
||||
"""
|
||||
This view decorator rejects all requests with a 403 response which are not from
|
||||
users with the is_superuser flag.
|
||||
@@ -114,9 +114,7 @@ class AdministratorPermissionRequiredMixin:
|
||||
This mixin is equivalent to the administrator_permission_required view decorator but
|
||||
is in a form suitable for class-based views.
|
||||
"""
|
||||
permission = ''
|
||||
|
||||
@classmethod
|
||||
def as_view(cls, **initkwargs):
|
||||
view = super(AdministratorPermissionRequiredMixin, cls).as_view(**initkwargs)
|
||||
return administrator_permission_required(cls.permission)(view)
|
||||
return administrator_permission_required()(view)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<form action="" method="post" class="form-horizontal">
|
||||
{% csrf_token %}
|
||||
{% bootstrap_form_errors form %}
|
||||
{% bootstrap_form form %}
|
||||
{% bootstrap_form form layout='horizontal' %}
|
||||
<div class="form-group submit-group">
|
||||
<button type="submit" class="btn btn-primary btn-save">
|
||||
{% trans "Save" %}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from django.shortcuts import reverse
|
||||
from django.views.generic import FormView
|
||||
|
||||
from pretix.control.forms.global_settings import GlobalSettingsForm
|
||||
@@ -13,5 +14,4 @@ class GlobalSettingsView(AdministratorPermissionRequiredMixin, FormView):
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_success_url(self):
|
||||
from django.shortcuts import reverse
|
||||
return reverse('control:global-settings')
|
||||
|
||||
Reference in New Issue
Block a user