WIP basic demo implementation
This commit is contained in:
parent
fea85cb07b
commit
3fe20eda62
@ -96,7 +96,10 @@ def _make_authentication_context():
|
|||||||
|
|
||||||
def redirect_after_login_url():
|
def redirect_after_login_url():
|
||||||
if request.args.get("next"):
|
if request.args.get("next"):
|
||||||
return request.args.get("next")
|
returl = request.args.get("next")
|
||||||
|
if request.args.get("formCache"):
|
||||||
|
returl += "?" + url.urlencode({"formCache": request.args.get("formCache")})
|
||||||
|
return returl
|
||||||
else:
|
else:
|
||||||
return url_for("atst.home")
|
return url_for("atst.home")
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ from atst.domain.invitations import (
|
|||||||
ExpiredError as InvitationExpiredError,
|
ExpiredError as InvitationExpiredError,
|
||||||
WrongUserError as InvitationWrongUserError,
|
WrongUserError as InvitationWrongUserError,
|
||||||
)
|
)
|
||||||
|
from atst.utils.form_cache import cache_form_data
|
||||||
|
|
||||||
|
|
||||||
def log_error(e):
|
def log_error(e):
|
||||||
@ -37,7 +38,10 @@ def make_error_pages(app):
|
|||||||
# pylint: disable=unused-variable
|
# pylint: disable=unused-variable
|
||||||
def session_expired(e):
|
def session_expired(e):
|
||||||
log_error(e)
|
log_error(e)
|
||||||
return redirect(url_for("atst.root", sessionExpired=True, next=request.path))
|
url_args = {"sessionExpired": True, "next": request.path}
|
||||||
|
if request.method == "POST":
|
||||||
|
url_args["formCache"] = cache_form_data(app.redis, request.form)
|
||||||
|
return redirect(url_for("atst.root", **url_args))
|
||||||
|
|
||||||
@app.errorhandler(Exception)
|
@app.errorhandler(Exception)
|
||||||
# pylint: disable=unused-variable
|
# pylint: disable=unused-variable
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from flask import g, render_template, redirect, url_for
|
from flask import g, render_template, redirect, url_for, current_app as app
|
||||||
from flask import request as http_request
|
from flask import request as http_request
|
||||||
from werkzeug.datastructures import ImmutableMultiDict, FileStorage
|
from werkzeug.datastructures import ImmutableMultiDict, FileStorage
|
||||||
|
|
||||||
@ -13,6 +13,7 @@ from atst.domain.requests.financial_verification import (
|
|||||||
)
|
)
|
||||||
from atst.models.attachment import Attachment
|
from atst.models.attachment import Attachment
|
||||||
from atst.domain.task_orders import TaskOrders
|
from atst.domain.task_orders import TaskOrders
|
||||||
|
from atst.utils.form_cache import retrieve_form_data
|
||||||
|
|
||||||
|
|
||||||
def fv_extended(_http_request):
|
def fv_extended(_http_request):
|
||||||
@ -91,6 +92,12 @@ class FinancialVerificationBase(object):
|
|||||||
raise FormValidationError(form)
|
raise FormValidationError(form)
|
||||||
|
|
||||||
|
|
||||||
|
def existing_form_data():
|
||||||
|
key = http_request.args.get("formCache")
|
||||||
|
if key:
|
||||||
|
return retrieve_form_data(app.redis, key)
|
||||||
|
|
||||||
|
|
||||||
class GetFinancialVerificationForm(FinancialVerificationBase):
|
class GetFinancialVerificationForm(FinancialVerificationBase):
|
||||||
def __init__(self, user, request, is_extended=False):
|
def __init__(self, user, request, is_extended=False):
|
||||||
self.user = user
|
self.user = user
|
||||||
@ -98,7 +105,7 @@ class GetFinancialVerificationForm(FinancialVerificationBase):
|
|||||||
self.is_extended = is_extended
|
self.is_extended = is_extended
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
form = self._get_form(self.request, self.is_extended)
|
form = self._get_form(self.request, self.is_extended, formdata=existing_form_data())
|
||||||
return form
|
return form
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user