From b249477953d0f115b2d39600474f81ccb5324564 Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Wed, 7 Sep 2016 10:31:33 +0100 Subject: [PATCH 1/2] Simplified the config files for admin. --- README.md | 11 ++++------- app/main/views/jobs.py | 30 ++++++++++++++---------------- config.py | 18 ++++++++++-------- environment_test.sh | 3 --- 4 files changed, 28 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 8dec06960..89932712b 100644 --- a/README.md +++ b/README.md @@ -59,15 +59,12 @@ in a separate terminal from the app ``` echo " export NOTIFY_ENVIRONMENT='development' -export ADMIN_CLIENT_SECRET='dev-notify-secret-key' -export ADMIN_CLIENT_USER_NAME='dev-notify-admin' +export ADMIN_CLIENT_SECRET='notify-secret-key' export API_HOST_NAME='http://localhost:6011' export DANGEROUS_SALT='dev-notify-salt' -export SECRET_KEY='dev-notify-secret-key' -export DESKPRO_API_HOST="" -export DESKPRO_API_KEY="" -export DESKPRO_DEPT_ID="" -export DESKPRO_ASSIGNED_AGENT_TEAM_ID="" +export SECRET_KEY='notify-secret-key' +export DESKPRO_API_HOST="some-host" +export DESKPRO_API_KEY="some-key" "> environment.sh ``` diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index c31d4b70e..7358ba5cb 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -66,9 +66,9 @@ def view_jobs(service_id): return render_template( 'views/jobs/jobs.html', jobs=add_rate_to_jobs([ - job for job in job_api_client.get_job(service_id)['data'] - if job['job_status'] != 'scheduled' - ]) + job for job in job_api_client.get_job(service_id)['data'] + if job['job_status'] != 'scheduled' + ]) ) @@ -76,7 +76,6 @@ def view_jobs(service_id): @login_required @user_has_permissions('view_activity', admin_override=True) def view_job(service_id, job_id): - job = job_api_client.get_job(service_id, job_id)['data'] filter_args = _parse_filter_args(request.args) filter_args['status'] = _set_status_filters(filter_args) @@ -234,14 +233,13 @@ def view_notifications(service_id, message_type): @login_required @user_has_permissions('view_activity', admin_override=True) def view_notification(service_id, job_id, notification_id): - now = time.strftime('%H:%M') return render_template( 'views/notification.html', message=[ message for message in messages if message['id'] == notification_id - ][0], + ][0], delivered_at=now, uploaded_at=now, job_id=job_id @@ -273,7 +271,7 @@ def get_status_filters(service, message_type, statistics): stats[key] ) for key, label, option in filters - ] + ] def _get_job_counts(job, help_argument): @@ -296,23 +294,23 @@ def _get_job_counts(job, help_argument): count ) for label, query_param, count in [ [ - 'total', '', - job.get('notification_count', 0) + 'total', '', + job.get('notification_count', 0) ], [ - 'sending', 'sending', - sending + 'sending', 'sending', + sending ], [ - 'delivered', 'delivered', - job.get('notifications_delivered', 0) + 'delivered', 'delivered', + job.get('notifications_delivered', 0) ], [ - 'failed', 'failed', - job.get('notifications_failed', 0) + 'failed', 'failed', + job.get('notifications_failed', 0) ] ] - ] + ] def get_job_partials(job): diff --git a/config.py b/config.py index 56586c883..1d829afd5 100644 --- a/config.py +++ b/config.py @@ -3,13 +3,20 @@ from datetime import timedelta class Config(object): - DEBUG = False ADMIN_CLIENT_SECRET = os.environ['ADMIN_CLIENT_SECRET'] - ADMIN_CLIENT_USER_NAME = os.environ['ADMIN_CLIENT_USER_NAME'] API_HOST_NAME = os.environ['API_HOST_NAME'] + SECRET_KEY = os.environ['SECRET_KEY'] + DANGEROUS_SALT = os.environ['DANGEROUS_SALT'] + DESKPRO_API_HOST = os.environ['DESKPRO_API_HOST'] + DESKPRO_API_KEY = os.environ['DESKPRO_API_KEY'] + + DESKPRO_DEPT_ID = 5 + DESKPRO_ASSIGNED_AGENT_TEAM_ID = 5 + + DEBUG = False + ADMIN_CLIENT_USER_NAME = 'notify-admin' ASSETS_DEBUG = False AWS_REGION = 'eu-west-1' - DANGEROUS_SALT = os.environ['DANGEROUS_SALT'] DEFAULT_SERVICE_LIMIT = 50 EMAIL_EXPIRY_SECONDS = 3600 * 24 * 7 # one week HEADER_COLOUR = '#FFBF47' # $yellow @@ -23,7 +30,6 @@ class Config(object): REMEMBER_COOKIE_HTTPONLY = True REMEMBER_COOKIE_NAME = 'notify_admin_remember_me' REMEMBER_COOKIE_SECURE = True - SECRET_KEY = os.environ['SECRET_KEY'] SEND_FILE_MAX_AGE_DEFAULT = 365 * 24 * 60 * 60 # 1 year SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_NAME = 'notify_admin_session' @@ -33,11 +39,7 @@ class Config(object): TOKEN_MAX_AGE_SECONDS = 3600 WTF_CSRF_ENABLED = True CSV_UPLOAD_BUCKET_NAME = 'local-notifications-csv-upload' - DESKPRO_API_HOST = os.environ['DESKPRO_API_HOST'] - DESKPRO_API_KEY = os.environ['DESKPRO_API_KEY'] DESKPRO_PERSON_EMAIL = 'donotreply@notifications.service.gov.uk' - DESKPRO_DEPT_ID = os.environ['DESKPRO_DEPT_ID'] - DESKPRO_ASSIGNED_AGENT_TEAM_ID = os.environ['DESKPRO_ASSIGNED_AGENT_TEAM_ID'] ACTIVITY_STATS_LIMIT_DAYS = 7 TEST_MESSAGE_FILENAME = 'Test message' diff --git a/environment_test.sh b/environment_test.sh index 1ce9096df..0e781fb34 100644 --- a/environment_test.sh +++ b/environment_test.sh @@ -1,10 +1,7 @@ export NOTIFY_ENVIRONMENT='test' export ADMIN_CLIENT_SECRET='dev-notify-secret-key' -export ADMIN_CLIENT_USER_NAME='dev-notify-admin' export API_HOST_NAME='' export DANGEROUS_SALT='dev-notify-salt' export SECRET_KEY='dev-notify-secret-key' export DESKPRO_API_HOST="" export DESKPRO_API_KEY="" -export DESKPRO_DEPT_ID="" -export DESKPRO_ASSIGNED_AGENT_TEAM_ID="" From 130698f72035df52b909b4942e4016fde2509c56 Mon Sep 17 00:00:00 2001 From: Martyn Inglis Date: Thu, 8 Sep 2016 09:29:08 +0100 Subject: [PATCH 2/2] Removed unused route and fixed some formatting --- app/main/views/jobs.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index e25c34aa1..770d56c46 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -242,21 +242,6 @@ def view_notifications(service_id, message_type): ) -@main.route("/services//jobs//notification/") -@login_required -@user_has_permissions('view_activity', admin_override=True) -def view_notification(service_id, job_id, notification_id): - now = time.strftime('%H:%M') - - return render_template( - 'views/notification.html', - message=[message for message in messages if message['id'] == notification_id][0], - delivered_at=now, - uploaded_at=now, - job_id=job_id - ) - - def get_status_filters(service, message_type, statistics): stats = statistics[message_type] stats['sending'] = stats['requested'] - stats['delivered'] - stats['failed'] @@ -321,7 +306,7 @@ def _get_job_counts(job, help_argument): job.get('notifications_failed', 0) ] ] - ] + ] def get_job_partials(job):