All tests passing and merged with master.

This commit is contained in:
Nicholas Staples
2016-01-27 16:30:33 +00:00
51 changed files with 763 additions and 892 deletions

View File

@@ -26,8 +26,11 @@ def get_service_by_id(id_):
return notifications_api_client.get_service(id_)
def get_services():
return notifications_api_client.get_services()
def get_services(user_id=None):
if user_id:
return notifications_api_client.get_services({'user_id': str(user_id)})
else:
return notifications_api_client.get_services()
def unrestrict_service(service_id):
@@ -55,8 +58,8 @@ def activate_service(service_id):
# TODO Fix when functionality is added to the api.
def find_service_by_service_name(service_name):
resp = notifications_api_client.get_services()
def find_service_by_service_name(service_name, user_id=None):
resp = notifications_api_client.get_services(user_id)
retval = None
for srv_json in resp['data']:
if srv_json['name'] == service_name:
@@ -69,8 +72,8 @@ def delete_service(id_):
return notifications_api_client.delete_service(id_)
def find_all_service_names():
resp = notifications_api_client.get_services()
def find_all_service_names(user_id=None):
resp = notifications_api_client.get_services(user_id)
return [x['name'] for x in resp['data']]
@@ -90,4 +93,4 @@ class ServicesBrowsableItem(BrowsableItem):
@property
def hint(self):
return "Some service hint here"
return None

View File

@@ -38,6 +38,7 @@ def update_user(user):
def increment_failed_login_count(id):
user = get_user_by_id(id)
user.failed_login_count += 1
return user_api_client.update_user(user)
def activate_user(user):
@@ -45,38 +46,19 @@ def activate_user(user):
return user_api_client.update_user(user)
def update_email_address(id, email_address):
user = get_user_by_id(id)
user.email_address = email_address
# TODO update user
def is_email_unique(email_address):
if user_api_client.get_user_by_email(email_address):
return False
return True
def update_mobile_number(id, mobile_number):
user = get_user_by_id(id)
user.mobile_number = mobile_number
# TODO update user
def update_password(user, password):
user.password = hashpw(password)
user.password_changed_at = datetime.now()
user.state = 'active'
# TODO update user
def request_password_reset(email):
user = get_user_by_email(email)
user.state = 'request_password_reset'
# TODO update user
def send_verify_code(user_id, code_type):
def send_verify_code(user_id, code_type, to=None):
return user_api_client.send_verify_code(user_id, code_type)