clean up some messy code
This commit is contained in:
@@ -145,6 +145,7 @@ class CompteRenduCreateView(generic.DetailView):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
# Overrides app_menu and replace it
|
||||||
self.app_menu = ["compte_rendu/menu_creation.html"]
|
self.app_menu = ["compte_rendu/menu_creation.html"]
|
||||||
|
|
||||||
def get_forms(self, *args, initial=None):
|
def get_forms(self, *args, initial=None):
|
||||||
|
|||||||
@@ -10,14 +10,10 @@ def webpage(**options):
|
|||||||
-- ajax : view will return content_template for Ajax requests
|
-- ajax : view will return content_template for Ajax requests
|
||||||
-- permissions : list of permissions needed to access view
|
-- permissions : list of permissions needed to access view
|
||||||
"""
|
"""
|
||||||
try: ajax = options.pop('ajax')
|
ajax = options.pop('ajax', False)
|
||||||
except KeyError: ajax = False
|
permissions = options.pop('permissions', [])
|
||||||
try: permissions = options.pop('permissions')
|
app_menu = options.pop('app_menu', [])
|
||||||
except KeyError: permissions = []
|
app_name = options.pop('app_name', None)
|
||||||
try: app_menu = options.pop('app_menu')
|
|
||||||
except KeyError: app_menu = []
|
|
||||||
try: app_name = options.pop('app_name')
|
|
||||||
except KeyError: app_name = None
|
|
||||||
|
|
||||||
new_bases = []
|
new_bases = []
|
||||||
if ajax:
|
if ajax:
|
||||||
@@ -27,7 +23,7 @@ def webpage(**options):
|
|||||||
if permissions:
|
if permissions:
|
||||||
new_bases.append(PermissionRequiredMixin)
|
new_bases.append(PermissionRequiredMixin)
|
||||||
|
|
||||||
def update_class(cls):
|
def class_decorator(cls):
|
||||||
_insert_bases(cls, new_bases)
|
_insert_bases(cls, new_bases)
|
||||||
if permissions:
|
if permissions:
|
||||||
cls.permissions = permissions
|
cls.permissions = permissions
|
||||||
@@ -35,4 +31,4 @@ def webpage(**options):
|
|||||||
cls.app_name = app_name
|
cls.app_name = app_name
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
return update_class
|
return class_decorator
|
||||||
|
|||||||
Reference in New Issue
Block a user