mirror of
https://github.com/Kunsi/pretalx-plugin-broadcast-tools
synced 2025-06-07 10:24:35 +00:00
move views into dedicated files
This commit is contained in:
parent
8f8f8a90e2
commit
3063adcc73
6 changed files with 119 additions and 107 deletions
37
pretalx_broadcast_tools/views/orga.py
Normal file
37
pretalx_broadcast_tools/views/orga.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
from django.views.generic import FormView
|
||||
from pretalx.common.mixins.views import PermissionRequired
|
||||
|
||||
from ..forms import BroadcastToolsSettingsForm
|
||||
|
||||
|
||||
class BroadcastToolsOrgaView(PermissionRequired, FormView):
|
||||
form_class = BroadcastToolsSettingsForm
|
||||
permission_required = "orga.change_settings"
|
||||
template_name = "pretalx_broadcast_tools/orga.html"
|
||||
|
||||
def get_success_url(self):
|
||||
return self.request.path
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["localized_rooms"] = [
|
||||
room.name.localize(self.request.event.locale)
|
||||
for room in self.request.event.rooms.all()
|
||||
]
|
||||
return context
|
||||
|
||||
def form_valid(self, form):
|
||||
form.save()
|
||||
return super().form_valid(form)
|
||||
|
||||
def get_object(self):
|
||||
return self.request.event
|
||||
|
||||
def get_form_kwargs(self):
|
||||
kwargs = super().get_form_kwargs()
|
||||
return {
|
||||
"obj": self.request.event,
|
||||
"attribute_name": "settings",
|
||||
"locales": self.request.event.locales,
|
||||
**kwargs,
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue