diff --git a/sapl/base/templatetags/common_tags.py b/sapl/base/templatetags/common_tags.py index 718fb2b81..a5c36b66d 100644 --- a/sapl/base/templatetags/common_tags.py +++ b/sapl/base/templatetags/common_tags.py @@ -266,7 +266,20 @@ def has_iframe(obj): session = getattr(obj, "session", None) if not session: return False - return bool(session.get("iframe", False)) + + iframe = session.get('iframe', False) + if not iframe and hasattr(obj, 'GET') and 'iframe' in obj.GET: + ival = obj.GET['iframe'] + if ival and int(ival) == 1: + session['iframe'] = True + return True + elif hasattr(obj, 'GET') and 'iframe' in obj.GET: + ival = obj.GET['iframe'] + if ival and int(ival) == 0: + del session['iframe'] + return False + + return iframe @register.filter diff --git a/sapl/base/templatetags/menus.py b/sapl/base/templatetags/menus.py index 8763d484a..93a2f6c28 100644 --- a/sapl/base/templatetags/menus.py +++ b/sapl/base/templatetags/menus.py @@ -64,6 +64,8 @@ def nav_run(context, path=None): """ rm = request.resolver_match + if rm is None: + return {} app_template = rm.app_name.rsplit('.', 1)[-1] if path: diff --git a/sapl/templates/404.html b/sapl/templates/404.html index b174f7a4f..68ca03c03 100644 --- a/sapl/templates/404.html +++ b/sapl/templates/404.html @@ -1,12 +1,149 @@ {% extends "base.html" %} {% load i18n %} -{% block head_title %}{% trans 'Página não encontrada! Erro 404' %}{% endblock %} +{% block head_title %}{% trans 'Página não encontrada' %} - 404{% endblock %} {% block base_content %} -
-

{% trans 'Página não encontrada! Erro 404' %}

-

{% trans 'A página que você está procurando não foi encontrada.' %}

- {% trans 'Voltar para a página inicial' %} + + +
+
+ +
+ +

404

+

{% trans 'Página não encontrada' %}

+ +

+ {% trans 'A página que você está procurando não existe ou foi movida.' %} +

+ +
-{% endblock %} + +{% endblock base_content %} diff --git a/sapl/urls.py b/sapl/urls.py index 5f90008c5..3d2a44478 100644 --- a/sapl/urls.py +++ b/sapl/urls.py @@ -122,3 +122,15 @@ def custom_permission_denied_view(request, exception=None): handler403 = custom_permission_denied_view + + +def custom_page_not_found_view(request, exception=None): + from django.shortcuts import redirect, render + + if not request.user.is_authenticated: + return redirect('/login/') + + return render(request, '404.html', status=404) + + +handler404 = custom_page_not_found_view