From 2cc9dc6995a422b66f461ca84371834dd7cda57d Mon Sep 17 00:00:00 2001 From: Nicholas Staples Date: Wed, 20 Jan 2016 11:46:39 +0000 Subject: [PATCH] Work in progress. --- app/main/forms.py | 6 ++++-- app/main/views/add_service.py | 2 +- app/notify_client/api_client.py | 9 ++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index df9515a5c..bb235d064 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -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(): diff --git a/app/main/views/add_service.py b/app/main/views/add_service.py index 7402ab497..3d01a005f 100644 --- a/app/main/views/add_service.py +++ b/app/main/views/add_service.py @@ -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( diff --git a/app/notify_client/api_client.py b/app/notify_client/api_client.py index df33884c5..c60afc3d2 100644 --- a/app/notify_client/api_client.py +++ b/app/notify_client/api_client.py @@ -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,6 +128,8 @@ class NotificationsAdminAPIClient(NotificationsAPIClient): message, job_id=None, description=None): + print("{0} {1} {2} {3}".format( + mobile_number, message, job_id, description)) self.send_sms_notification(mobile_number, message) def send_email(self, @@ -137,4 +139,5 @@ class NotificationsAdminAPIClient(NotificationsAPIClient): subject, job_id=None, description=None): - pass + print("{0} {1} {2} {3} {4} {5}".format( + email_address, message, from_address, subject, job_id, description))