When user not found, redirect to users page and show flash message
This commit is contained in:
parent
43855c5495
commit
fa83dfe6bd
@ -43,8 +43,8 @@ def submit_new_user():
|
|||||||
new_user = Users.get_by_dod_id(request.form["dod_id"])
|
new_user = Users.get_by_dod_id(request.form["dod_id"])
|
||||||
form = CCPOUserForm(obj=new_user)
|
form = CCPOUserForm(obj=new_user)
|
||||||
except NotFoundError:
|
except NotFoundError:
|
||||||
new_user = None
|
flash("ccpo_user_not_found")
|
||||||
form = CCPOUserForm()
|
return redirect(url_for("ccpo.users"))
|
||||||
|
|
||||||
return render_template("ccpo/confirm_user.html", new_user=new_user, form=form)
|
return render_template("ccpo/confirm_user.html", new_user=new_user, form=form)
|
||||||
|
|
||||||
|
@ -35,6 +35,11 @@ MESSAGES = {
|
|||||||
"message_template": "You have successfully given {{ user_name }} CCPO permissions.",
|
"message_template": "You have successfully given {{ user_name }} CCPO permissions.",
|
||||||
"category": "success",
|
"category": "success",
|
||||||
},
|
},
|
||||||
|
"ccpo_user_not_found": {
|
||||||
|
"title_template": translate("ccpo.form.user_not_found_title"),
|
||||||
|
"message_template": translate("ccpo.form.user_not_found_text"),
|
||||||
|
"category": "info",
|
||||||
|
},
|
||||||
"environment_added": {
|
"environment_added": {
|
||||||
"title_template": translate("flash.success"),
|
"title_template": translate("flash.success"),
|
||||||
"message_template": """
|
"message_template": """
|
||||||
|
@ -30,15 +30,5 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{% else %}
|
|
||||||
<h3>{{ 'ccpo.form.user_not_found_title' | translate }}</h3>
|
|
||||||
<p>
|
|
||||||
{{ "ccpo.form.user_not_found_text" | translate }}
|
|
||||||
</p>
|
|
||||||
<div class='action-group'>
|
|
||||||
<a class='action-group__action icon-link icon-link--default' href="{{ url_for('ccpo.users') }}">
|
|
||||||
{{ "ccpo.form.return_link" | translate }}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -28,7 +28,7 @@ def test_submit_new_user(user_session, client):
|
|||||||
response = client.post(
|
response = client.post(
|
||||||
url_for("ccpo.submit_new_user"), data={"dod_id": random_dod_id}
|
url_for("ccpo.submit_new_user"), data={"dod_id": random_dod_id}
|
||||||
)
|
)
|
||||||
assert translate("ccpo.form.user_not_found_title") in response.data.decode()
|
assert url_for("ccpo.users") in response.location
|
||||||
|
|
||||||
|
|
||||||
def test_confirm_new_user(user_session, client):
|
def test_confirm_new_user(user_session, client):
|
||||||
|
@ -146,7 +146,7 @@ def test_ccpo_submit_new_user_access(post_url_assert_status):
|
|||||||
rando = user_with()
|
rando = user_with()
|
||||||
|
|
||||||
url = url_for("ccpo.submit_new_user")
|
url = url_for("ccpo.submit_new_user")
|
||||||
post_url_assert_status(ccpo, url, 200, data={"dod_id": "1234567890"})
|
post_url_assert_status(ccpo, url, 302, data={"dod_id": "1234567890"})
|
||||||
post_url_assert_status(rando, url, 404, data={"dod_id": "1234567890"})
|
post_url_assert_status(rando, url, 404, data={"dod_id": "1234567890"})
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user