diff --git a/debug_toolbar/_compat.py b/debug_toolbar/_compat.py new file mode 100644 index 000000000..ecd8fe068 --- /dev/null +++ b/debug_toolbar/_compat.py @@ -0,0 +1,5 @@ +try: + from django.contrib.auth.decorators import login_not_required +except ImportError: + def login_not_required(func): + return func diff --git a/debug_toolbar/decorators.py b/debug_toolbar/decorators.py index b458914b6..5dfd0796f 100644 --- a/debug_toolbar/decorators.py +++ b/debug_toolbar/decorators.py @@ -5,17 +5,8 @@ from debug_toolbar import settings as dt_settings -try: - from django.contrib.auth.decorators import login_not_required -except ImportError: - - def login_not_required(func): - return func - - def require_show_toolbar(view): @functools.wraps(view) - @login_not_required def inner(request, *args, **kwargs): from debug_toolbar.middleware import get_show_toolbar diff --git a/debug_toolbar/panels/history/views.py b/debug_toolbar/panels/history/views.py index 3fcbd9b32..1e0d4d261 100644 --- a/debug_toolbar/panels/history/views.py +++ b/debug_toolbar/panels/history/views.py @@ -1,11 +1,12 @@ from django.http import HttpResponseBadRequest, JsonResponse from django.template.loader import render_to_string +from debug_toolbar._compat import login_not_required from debug_toolbar.decorators import render_with_toolbar_language, require_show_toolbar from debug_toolbar.panels.history.forms import HistoryStoreForm from debug_toolbar.toolbar import DebugToolbar - +@login_not_required @require_show_toolbar @render_with_toolbar_language def history_sidebar(request): @@ -36,7 +37,7 @@ def history_sidebar(request): return JsonResponse(context) return HttpResponseBadRequest("Form errors") - +@login_not_required @require_show_toolbar @render_with_toolbar_language def history_refresh(request): diff --git a/debug_toolbar/panels/sql/views.py b/debug_toolbar/panels/sql/views.py index 4b6ced9da..b3ad6debb 100644 --- a/debug_toolbar/panels/sql/views.py +++ b/debug_toolbar/panels/sql/views.py @@ -2,6 +2,7 @@ from django.template.loader import render_to_string from django.views.decorators.csrf import csrf_exempt +from debug_toolbar._compat import login_not_required from debug_toolbar.decorators import render_with_toolbar_language, require_show_toolbar from debug_toolbar.forms import SignedDataForm from debug_toolbar.panels.sql.forms import SQLSelectForm @@ -17,6 +18,7 @@ def get_signed_data(request): @csrf_exempt +@login_not_required @require_show_toolbar @render_with_toolbar_language def sql_select(request): @@ -47,6 +49,7 @@ def sql_select(request): @csrf_exempt +@login_not_required @require_show_toolbar @render_with_toolbar_language def sql_explain(request): @@ -86,6 +89,7 @@ def sql_explain(request): @csrf_exempt +@login_not_required @require_show_toolbar @render_with_toolbar_language def sql_profile(request): diff --git a/debug_toolbar/panels/templates/views.py b/debug_toolbar/panels/templates/views.py index e65d1a9d5..be6893e0f 100644 --- a/debug_toolbar/panels/templates/views.py +++ b/debug_toolbar/panels/templates/views.py @@ -5,9 +5,11 @@ from django.template.loader import render_to_string from django.utils.html import format_html, mark_safe +from debug_toolbar._compat import login_not_required from debug_toolbar.decorators import render_with_toolbar_language, require_show_toolbar +@login_not_required @require_show_toolbar @render_with_toolbar_language def template_source(request): diff --git a/debug_toolbar/views.py b/debug_toolbar/views.py index b93acbeed..467d7485c 100644 --- a/debug_toolbar/views.py +++ b/debug_toolbar/views.py @@ -2,10 +2,12 @@ from django.utils.html import escape from django.utils.translation import gettext as _ +from debug_toolbar._compat import login_not_required from debug_toolbar.decorators import render_with_toolbar_language, require_show_toolbar from debug_toolbar.toolbar import DebugToolbar +@login_not_required @require_show_toolbar @render_with_toolbar_language def render_panel(request):