mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
This commit: - replaces links that look like buttons with forms and submit buttons - splits the view code for SMS into its own file - moves the routing into the Python by adding handling for `post` requests - uses Flask’s `url_for` to generate URLs, rather than hard coding them (so that it’s easier to change the URLs) - chages the URLs for sending text messages
52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
from flask import request, render_template, redirect, url_for
|
|
from flask_login import login_required
|
|
|
|
from app.main import main
|
|
|
|
|
|
@main.route("/sms/send", methods=['GET', 'POST'])
|
|
def sendsms():
|
|
if request.method == 'GET':
|
|
return render_template(
|
|
'views/send-sms.html',
|
|
message_templates=[
|
|
{
|
|
'name': 'Reminder',
|
|
'body': """
|
|
Vehicle tax: Your vehicle tax for ((registration number)) expires on ((date)).
|
|
Tax your vehicle at www.gov.uk/vehicle-tax
|
|
"""
|
|
},
|
|
{
|
|
'name': 'Warning',
|
|
'body': """
|
|
Vehicle tax: Your vehicle tax for ((registration number)) has expired.
|
|
Tax your vehicle at www.gov.uk/vehicle-tax
|
|
"""
|
|
},
|
|
]
|
|
)
|
|
elif request.method == 'POST':
|
|
return redirect(url_for('.checksms'))
|
|
|
|
|
|
@main.route("/sms/check", methods=['GET', 'POST'])
|
|
def checksms():
|
|
if request.method == 'GET':
|
|
return render_template(
|
|
'views/check-sms.html',
|
|
recipients=[
|
|
{'phone': "+44 7815838437", 'registration': 'LC12 BFL', 'date': '24 December 2015'},
|
|
{'phone': "+44 7815838437", 'registration': 'DU04 AOM', 'date': '25 December 2015'},
|
|
{'phone': "+44 7815838437", 'registration': 'M91 MJB', 'date': '26 December 2015'},
|
|
{'phone': "+44 7815838437", 'registration': 'Y249 NPU', 'date': '31 December 2015'},
|
|
{'phone': "+44 7815838437", 'registration': 'LG55 UGB', 'date': '1 January 2016'}
|
|
],
|
|
message_template="""
|
|
Vehicle tax: Your vehicle tax for ((registration number)) expires on ((date)).
|
|
Tax your vehicle at www.gov.uk/vehicle-tax
|
|
"""
|
|
)
|
|
elif request.method == 'POST':
|
|
return redirect(url_for('.showjob'))
|