mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -04:00
Slight changes to match new API features:
- get user now throws a 404 so handle that - making a service now needs one user not many to create
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from notifications_python_client import HTTPError
|
||||||
|
|
||||||
from sqlalchemy.orm import load_only
|
from sqlalchemy.orm import load_only
|
||||||
|
|
||||||
@@ -47,9 +48,15 @@ def activate_user(user):
|
|||||||
|
|
||||||
|
|
||||||
def is_email_unique(email_address):
|
def is_email_unique(email_address):
|
||||||
if user_api_client.get_user_by_email(email_address):
|
try:
|
||||||
return False
|
if user_api_client.get_user_by_email(email_address):
|
||||||
return True
|
return False
|
||||||
|
return True
|
||||||
|
except HTTPError as ex:
|
||||||
|
if ex.status_code == 404:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
raise ex
|
||||||
|
|
||||||
|
|
||||||
def request_password_reset(user):
|
def request_password_reset(user):
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ def register():
|
|||||||
return redirect(url_for('main.choose_service'))
|
return redirect(url_for('main.choose_service'))
|
||||||
|
|
||||||
form = RegisterUserForm()
|
form = RegisterUserForm()
|
||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
if users_dao.is_email_unique(form.email_address.data):
|
if users_dao.is_email_unique(form.email_address.data):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class NotificationsAdminAPIClient(NotificationsAPIClient):
|
|||||||
"name": service_name,
|
"name": service_name,
|
||||||
"active": active,
|
"active": active,
|
||||||
"limit": limit,
|
"limit": limit,
|
||||||
"users": [user_id],
|
"user_id": user_id,
|
||||||
"restricted": restricted
|
"restricted": restricted
|
||||||
}
|
}
|
||||||
return self.post("/service", data)
|
return self.post("/service", data)
|
||||||
|
|||||||
Reference in New Issue
Block a user