diff --git a/app/main/views/sms.py b/app/main/views/sms.py index a4ae64aa3..42340cbaa 100644 --- a/app/main/views/sms.py +++ b/app/main/views/sms.py @@ -37,11 +37,23 @@ from app.utils import ( @main.route("/services//sms/send", methods=['GET']) def choose_sms_template(service_id): + try: + jobs = job_api_client.get_job(service_id)['data'] + except HTTPError as e: + if e.status_code == 404: + abort(404) + else: + raise e + print("="*80) + print(jobs) + print(len(jobs)) + print(bool(len(jobs))) return render_template( 'views/choose-sms-template.html', templates=[ Template(template) for template in templates_dao.get_service_templates(service_id)['data'] ], + has_jobs=len(jobs), service_id=service_id ) diff --git a/app/templates/views/choose-sms-template.html b/app/templates/views/choose-sms-template.html index 4fb5595e3..221fa781b 100644 --- a/app/templates/views/choose-sms-template.html +++ b/app/templates/views/choose-sms-template.html @@ -14,6 +14,15 @@
{% if templates %} + {% if not has_jobs %} + {{ banner( + """ + Send yourself a test message + """, + subhead='Next step', + type="tip" + )}} + {% endif %}
{% for template in templates %}
diff --git a/tests/app/main/views/test_sms.py b/tests/app/main/views/test_sms.py index 0c50631dc..6f9656e25 100644 --- a/tests/app/main/views/test_sms.py +++ b/tests/app/main/views/test_sms.py @@ -9,7 +9,8 @@ def test_choose_sms_template(app_, mock_login, mock_get_user, mock_check_verify_code, - mock_get_service_templates): + mock_get_service_templates, + mock_get_jobs): with app_.test_request_context(): with app_.test_client() as client: client.login(api_user_active)