Added the retrieve_status() utility and applied it in the retrieve_status template tag in the Mia core application.
This commit is contained in:
parent
983f38d6f0
commit
80b871d488
@ -61,6 +61,20 @@ def error_redirect(request, url, form, errors_by_field):
|
|||||||
return HttpResponseRedirect(str(UrlBuilder(url).add_param("s", id)))
|
return HttpResponseRedirect(str(UrlBuilder(url).add_param("s", id)))
|
||||||
|
|
||||||
|
|
||||||
|
def retrieve_status(request):
|
||||||
|
"""Retrieves the previously-stored status.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request (HttpRequest): The request.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: The previously-stored status.
|
||||||
|
"""
|
||||||
|
if "s" not in request.GET:
|
||||||
|
return None
|
||||||
|
return _retrieve(request, request.GET["s"])
|
||||||
|
|
||||||
|
|
||||||
def _store(request, status):
|
def _store(request, status):
|
||||||
"""Stores the status into the session, and returns the status ID that can
|
"""Stores the status into the session, and returns the status ID that can
|
||||||
be used to retrieve the status later with retrieve().
|
be used to retrieve the status later with retrieve().
|
||||||
|
@ -26,7 +26,7 @@ from django.urls import reverse
|
|||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext
|
from django.utils.translation import gettext
|
||||||
|
|
||||||
from mia_core.status import _retrieve
|
from mia_core.status import _retrieve, retrieve_status
|
||||||
from mia_core.utils import UrlBuilder
|
from mia_core.utils import UrlBuilder
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
@ -126,9 +126,7 @@ def retrieve_status_tag(context):
|
|||||||
Returns:
|
Returns:
|
||||||
str: An empty string.
|
str: An empty string.
|
||||||
"""
|
"""
|
||||||
if "s" not in context.request.GET:
|
status = retrieve_status(context.request)
|
||||||
return ""
|
|
||||||
status = _retrieve(context.request, context.request.GET["s"])
|
|
||||||
if status is None:
|
if status is None:
|
||||||
return ""
|
return ""
|
||||||
if "success" in status:
|
if "success" in status:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user