Use new setting_enabled and required decorators in plugin sample
This commit is contained in:
parent
b471fbfd44
commit
5089911c7f
|
@ -1,14 +0,0 @@
|
|||
import functools
|
||||
|
||||
from django.http import Http404
|
||||
|
||||
from . import app_settings
|
||||
|
||||
def plugin_enabled(view):
|
||||
'''If plugin is not enabled, return 404'''
|
||||
@functools.wraps(view)
|
||||
def wrapper(*args, **kwargs):
|
||||
if not app_settings.ENABLED:
|
||||
raise Http404
|
||||
return view(*args, **kwargs)
|
||||
return wrapper
|
|
@ -1,8 +1,14 @@
|
|||
from django.conf.urls import patterns, url
|
||||
|
||||
from authentic2.decorators import setting_enabled, required
|
||||
|
||||
from . import app_settings
|
||||
from .views import index
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url('^authentic2_plugin_template/$', index,
|
||||
name='authentic2-plugin-template-index'),
|
||||
urlpatterns = required(
|
||||
setting_enabled('ENABLE', settings=app_settings),
|
||||
patterns('',
|
||||
url('^authentic2_plugin_template/$', index,
|
||||
name='authentic2-plugin-template-index'),
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue