2023-12-13 23:58:00 +01:00
|
|
|
from django.contrib import messages
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from django.views.generic import FormView
|
|
|
|
from pretalx.common.mixins.views import PermissionRequired
|
|
|
|
|
|
|
|
from .forms import MusicrateSettingsForm
|
|
|
|
|
|
|
|
|
|
|
|
class MusicrateSettingsView(PermissionRequired, FormView):
|
|
|
|
permission_required = "orga.change_settings"
|
|
|
|
template_name = "pretalx_musicrate/settings.html"
|
|
|
|
form_class = MusicrateSettingsForm
|
|
|
|
|
|
|
|
def get_success_url(self):
|
|
|
|
return self.request.path
|
|
|
|
|
|
|
|
def get_object(self):
|
|
|
|
return self.request.event
|
|
|
|
|
|
|
|
def get_form_kwargs(self):
|
|
|
|
kwargs = super().get_form_kwargs()
|
|
|
|
kwargs["event"] = self.request.event
|
|
|
|
return kwargs
|
|
|
|
|
|
|
|
def form_valid(self, form):
|
|
|
|
form.save()
|
2023-12-14 00:57:15 +01:00
|
|
|
messages.success(
|
2023-12-14 19:36:50 +01:00
|
|
|
self.request, _("The pretalx-musicrate settings were updated.")
|
2023-12-14 00:57:15 +01:00
|
|
|
)
|
2023-12-13 23:58:00 +01:00
|
|
|
return super().form_valid(form)
|