Skip to content

Commit

Permalink
[orga] Allow administrators to deal with css issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rixx committed Dec 9, 2018
1 parent 73fbbc6 commit 2b959f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/pretalx/orga/forms/event.py
Expand Up @@ -20,6 +20,7 @@ class EventForm(ReadOnlyFlag, I18nModelForm):
)

def __init__(self, *args, **kwargs):
self.is_administrator = kwargs.pop('is_administrator', False)
super().__init__(*args, **kwargs)
self.initial['locales'] = self.instance.locale_array.split(',')
year = str(now().year)
Expand All @@ -39,6 +40,8 @@ def clean_custom_css(self):

if self.cleaned_data.get('custom_css') or self.files.get('custom_css'):
css = self.cleaned_data['custom_css'] or self.files['custom_css']
if self.is_administrator:
return css
try:
validate_css(css.read())
return css
Expand Down
5 changes: 5 additions & 0 deletions src/pretalx/orga/views/event.py
Expand Up @@ -64,6 +64,11 @@ def sform(self):
prefix='settings',
)

def get_form_kwargs(self, *args, **kwargs):
response = super().get_form_kwargs(*args, **kwargs)
response['is_administrator'] = self.request.user.is_administrator
return response

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['sform'] = self.sform
Expand Down

0 comments on commit 2b959f1

Please sign in to comment.