mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-10 19:34:27 -04:00
Merge pull request #95 from alphagov/implement_send_sms_and_email
Implement send sms and email
This commit is contained in:
@@ -61,8 +61,10 @@ class UKMobileNumber(StringField):
|
||||
|
||||
if len(self.data) != 9:
|
||||
return
|
||||
|
||||
self.data = '+44 7{} {} {}'.format(*re.findall('...', self.data))
|
||||
# TODO implement in the render field method.
|
||||
# API's require no spaces in the number
|
||||
# self.data = '+44 7{} {} {}'.format(*re.findall('...', self.data))
|
||||
self.data = '+447{}{}{}'.format(*re.findall('...', self.data))
|
||||
|
||||
|
||||
def mobile_number():
|
||||
|
||||
@@ -16,7 +16,7 @@ def add_service():
|
||||
heading = 'Add a new service'
|
||||
if form.validate_on_submit():
|
||||
user = users_dao.get_user_by_id(session['user_id'])
|
||||
service_id = services_dao.insert_new_service(form.name.data, user)
|
||||
service_id = services_dao.insert_new_service(form.name.data, user.id)
|
||||
return redirect(url_for('main.service_dashboard', service_id=service_id))
|
||||
else:
|
||||
return render_template(
|
||||
|
||||
@@ -13,8 +13,8 @@ class NotificationsAdminAPIClient(NotificationsAPIClient):
|
||||
|
||||
def init_app(self, application):
|
||||
self.base_url = application.config['API_HOST_NAME']
|
||||
self.client_id = application.config['NOTIFY_API_CLIENT']
|
||||
self.secret = application.config['NOTIFY_API_SECRET']
|
||||
self.client_id = application.config['ADMIN_CLIENT_USER_NAME']
|
||||
self.secret = application.config['ADMIN_CLIENT_SECRET']
|
||||
|
||||
def create_service(self, service_name, active, limit, restricted, user_id):
|
||||
"""
|
||||
@@ -128,7 +128,7 @@ class NotificationsAdminAPIClient(NotificationsAPIClient):
|
||||
message,
|
||||
job_id=None,
|
||||
description=None):
|
||||
pass
|
||||
self.send_sms_notification(mobile_number, message)
|
||||
|
||||
def send_email(self,
|
||||
email_address,
|
||||
@@ -137,4 +137,4 @@ class NotificationsAdminAPIClient(NotificationsAPIClient):
|
||||
subject,
|
||||
job_id=None,
|
||||
description=None):
|
||||
pass
|
||||
self.send_email_notification(email_address, message, from_address, subject)
|
||||
|
||||
@@ -22,7 +22,7 @@ class UserApiClient(BaseAPIClient):
|
||||
"password": password
|
||||
}
|
||||
user_data = self.post("/user", data)
|
||||
return User(user_data, max_failed_login_count=self.user_max_failed_login_count)
|
||||
return User(user_data['data'], max_failed_login_count=self.user_max_failed_login_count)
|
||||
|
||||
|
||||
class User(object):
|
||||
|
||||
@@ -11,6 +11,6 @@ Flask-Bcrypt==0.6.2
|
||||
credstash==1.8.0
|
||||
boto3==1.2.3
|
||||
|
||||
git+https://github.com/alphagov/notifications-python-client.git@0.1.8#egg=notifications-python-client==0.1.8
|
||||
git+https://github.com/alphagov/notifications-python-client.git@0.1.9#egg=notifications-python-client==0.1.9
|
||||
|
||||
git+https://github.com/alphagov/notifications-utils.git@0.0.3#egg=notifications-utils==0.0.3
|
||||
|
||||
@@ -72,4 +72,4 @@ def test_phone_number_rejects_invalid_values(phone_number, error_message):
|
||||
def test_phone_number_outputs_in_correct_format(phone_number):
|
||||
form = FormExample(phone_number=phone_number)
|
||||
form.validate()
|
||||
assert form.phone_number.data == '+44 7123 456 789'
|
||||
assert form.phone_number.data == '+447123456789'
|
||||
|
||||
@@ -107,7 +107,7 @@ def test_should_update_mobile_number_resend_code(app_,
|
||||
assert response.status_code == 302
|
||||
assert response.location == url_for('main.verify', _external=True)
|
||||
updated_user = users_dao.get_user_by_id(user.id)
|
||||
assert updated_user.mobile_number == '+44 7700 900 460'
|
||||
assert updated_user.mobile_number == '+447700900460'
|
||||
|
||||
|
||||
def test_should_render_verification_code_not_received(app_,
|
||||
|
||||
Reference in New Issue
Block a user