flash form error message from our base form class
This commit is contained in:
parent
1dd2cdd48b
commit
16064be468
@ -1,6 +1,8 @@
|
|||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from flask import current_app, request as http_request
|
from flask import current_app, request as http_request
|
||||||
|
|
||||||
|
from atst.utils.flash import formatted_flash as flash
|
||||||
|
|
||||||
|
|
||||||
class ValidatedForm(FlaskForm):
|
class ValidatedForm(FlaskForm):
|
||||||
def perform_extra_validation(self, *args, **kwargs):
|
def perform_extra_validation(self, *args, **kwargs):
|
||||||
@ -14,6 +16,12 @@ class ValidatedForm(FlaskForm):
|
|||||||
_data.pop("csrf_token", None)
|
_data.pop("csrf_token", None)
|
||||||
return _data
|
return _data
|
||||||
|
|
||||||
|
def validate(self, *args, **kwargs):
|
||||||
|
valid = super().validate(*args, **kwargs)
|
||||||
|
if not valid:
|
||||||
|
flash("form_errors")
|
||||||
|
return valid
|
||||||
|
|
||||||
|
|
||||||
class CacheableForm(ValidatedForm):
|
class CacheableForm(ValidatedForm):
|
||||||
def __init__(self, formdata=None, **kwargs):
|
def __init__(self, formdata=None, **kwargs):
|
||||||
|
@ -13,7 +13,6 @@ from atst.domain.requests import Requests
|
|||||||
from atst.domain.exceptions import NotFoundError
|
from atst.domain.exceptions import NotFoundError
|
||||||
from atst.forms.ccpo_review import CCPOReviewForm
|
from atst.forms.ccpo_review import CCPOReviewForm
|
||||||
from atst.forms.internal_comment import InternalCommentForm
|
from atst.forms.internal_comment import InternalCommentForm
|
||||||
from atst.utils.flash import formatted_flash as flash
|
|
||||||
|
|
||||||
|
|
||||||
def map_ccpo_authorizing(user):
|
def map_ccpo_authorizing(user):
|
||||||
@ -64,7 +63,6 @@ def submit_approval(request_id):
|
|||||||
|
|
||||||
return redirect(url_for("requests.requests_index"))
|
return redirect(url_for("requests.requests_index"))
|
||||||
else:
|
else:
|
||||||
flash("form_errors")
|
|
||||||
return render_approval(request, form)
|
return render_approval(request, form)
|
||||||
|
|
||||||
|
|
||||||
@ -96,5 +94,4 @@ def create_internal_comment(request_id):
|
|||||||
url_for("requests.approval", request_id=request_id, _anchor="ccpo-notes")
|
url_for("requests.approval", request_id=request_id, _anchor="ccpo-notes")
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
flash("form_errors")
|
|
||||||
return render_approval(request, internal_comment_form=form)
|
return render_approval(request, internal_comment_form=form)
|
||||||
|
@ -112,7 +112,6 @@ def requests_update(screen=1, request_id=None):
|
|||||||
where = "/requests"
|
where = "/requests"
|
||||||
return redirect(where)
|
return redirect(where)
|
||||||
else:
|
else:
|
||||||
flash("form_errors")
|
|
||||||
rerender_args = dict(
|
rerender_args = dict(
|
||||||
f=jedi_flow.form,
|
f=jedi_flow.form,
|
||||||
data=post_data,
|
data=post_data,
|
||||||
|
@ -29,7 +29,5 @@ def update_user():
|
|||||||
flash("user_updated")
|
flash("user_updated")
|
||||||
if next_url:
|
if next_url:
|
||||||
return redirect(next_url)
|
return redirect(next_url)
|
||||||
else:
|
|
||||||
flash("form_errors")
|
|
||||||
|
|
||||||
return render_template("user/edit.html", form=form, user=user, next=next_url)
|
return render_template("user/edit.html", form=form, user=user, next=next_url)
|
||||||
|
@ -8,7 +8,6 @@ from atst.domain.workspaces import Workspaces
|
|||||||
from atst.forms.workspace import WorkspaceForm
|
from atst.forms.workspace import WorkspaceForm
|
||||||
from atst.domain.authz import Authorization
|
from atst.domain.authz import Authorization
|
||||||
from atst.models.permissions import Permissions
|
from atst.models.permissions import Permissions
|
||||||
from atst.utils.flash import formatted_flash as flash
|
|
||||||
|
|
||||||
|
|
||||||
@workspaces_bp.route("/workspaces")
|
@workspaces_bp.route("/workspaces")
|
||||||
@ -34,7 +33,6 @@ def edit_workspace(workspace_id):
|
|||||||
url_for("workspaces.workspace_projects", workspace_id=workspace.id)
|
url_for("workspaces.workspace_projects", workspace_id=workspace.id)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
flash("form_errors")
|
|
||||||
return render_template("workspaces/edit.html", form=form, workspace=workspace)
|
return render_template("workspaces/edit.html", form=form, workspace=workspace)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user