flows: fix FlowNonApplicableException and EmptyFlowException leading to infinite spinners
This commit is contained in:
parent
2c07859b68
commit
5184c4b7ef
|
@ -0,0 +1,25 @@
|
|||
{# Template used by bad_request_message within flows #}
|
||||
{% extends 'login/base.html' %}
|
||||
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load passbook_utils %}
|
||||
|
||||
{% block title %}
|
||||
{% trans card_title %}
|
||||
{% endblock %}
|
||||
|
||||
{% block card_title %}
|
||||
{% trans card_title %}
|
||||
{% endblock %}
|
||||
|
||||
{% block card %}
|
||||
<form method="POST" class="pf-c-form">
|
||||
{% if message %}
|
||||
<h3>{% trans message %}</h3>
|
||||
{% endif %}
|
||||
{% if 'back' in request.GET %}
|
||||
<a href="{% back %}" class="btn btn-primary btn-block btn-lg">{% trans 'Back' %}</a>
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
|
||||
class FlowNonApplicableException(BaseException):
|
||||
"""Exception raised when a Flow does not apply to a user."""
|
||||
"""Flow does not apply to current user (denied by policy)."""
|
||||
|
||||
|
||||
class EmptyFlowException(BaseException):
|
||||
"""Exception raised when a Flow Plan is empty"""
|
||||
"""Flow has no stages."""
|
||||
|
|
|
@ -54,7 +54,10 @@ class FlowExecutorView(View):
|
|||
LOGGER.debug("f(exec): Redirecting to next on fail")
|
||||
return redirect(self.request.GET.get(NEXT_ARG_NAME))
|
||||
message = exc.__doc__ if exc.__doc__ else str(exc)
|
||||
return bad_request_message(self.request, message)
|
||||
return to_stage_response(
|
||||
self.request,
|
||||
bad_request_message(self.request, message, template="error/embedded.html"),
|
||||
)
|
||||
|
||||
def dispatch(self, request: HttpRequest, flow_slug: str) -> HttpResponse:
|
||||
# Early check if theres an active Plan for the current session
|
||||
|
|
|
@ -27,12 +27,12 @@ class CreateAssignPermView(CreateView):
|
|||
|
||||
|
||||
def bad_request_message(
|
||||
request: HttpRequest, message: str, title="Bad Request"
|
||||
request: HttpRequest,
|
||||
message: str,
|
||||
title="Bad Request",
|
||||
template="error/generic.html",
|
||||
) -> TemplateResponse:
|
||||
"""Return generic error page with message, with status code set to 400"""
|
||||
return TemplateResponse(
|
||||
request,
|
||||
"error/generic.html",
|
||||
{"message": message, "card_title": _(title)},
|
||||
status=400,
|
||||
request, template, {"message": message, "card_title": _(title)}, status=400,
|
||||
)
|
||||
|
|
Reference in New Issue