mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-11 10:28:41 -04:00
Replace CSV preview with rendered messages
If there are less than 7 messages, show them all. If there are more than 7, show the first and last three, and a link to the remaining x.
This commit is contained in:
+42
-27
@@ -3,28 +3,30 @@ from flask_login import login_required
|
||||
|
||||
from app.main import main
|
||||
|
||||
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
|
||||
"""
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@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
|
||||
"""
|
||||
},
|
||||
]
|
||||
message_templates=message_templates
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
return redirect(url_for('.checksms'))
|
||||
@@ -32,20 +34,33 @@ def sendsms():
|
||||
|
||||
@main.route("/sms/check", methods=['GET', 'POST'])
|
||||
def checksms():
|
||||
|
||||
recipients = [
|
||||
{'phone': "+44 7700 900989", 'registration number': 'LC12 BFL', 'date': '24 December 2015'},
|
||||
{'phone': "+44 7700 900479", 'registration number': 'DU04 AOM', 'date': '25 December 2015'},
|
||||
{'phone': "+44 7700 900964", 'registration number': 'M91 MJB', 'date': '26 December 2015'},
|
||||
{'phone': "+44 7700 900703", 'registration number': 'Y249 NPU', 'date': '31 December 2015'},
|
||||
{'phone': "+44 7700 900730", 'registration number': 'LG55 UGB', 'date': '1 January 2016'},
|
||||
{'phone': "+44 7700 900989", 'registration number': 'LC12 BFL', 'date': '24 December 2015'},
|
||||
{'phone': "+44 7700 900479", 'registration number': 'DU04 AOM', 'date': '25 December 2015'},
|
||||
{'phone': "+44 7700 900964", 'registration number': 'M91 MJB', 'date': '26 December 2015'},
|
||||
{'phone': "+44 7700 900703", 'registration number': 'Y249 NPU', 'date': '31 December 2015'},
|
||||
{'phone': "+44 7700 900730", 'registration number': 'LG55 UGB', 'date': '1 January 2016'},
|
||||
]
|
||||
|
||||
number_of_recipients = len(recipients)
|
||||
too_many_recipients_to_display = number_of_recipients > 7
|
||||
|
||||
if request.method == 'GET':
|
||||
return render_template(
|
||||
'views/check-sms.html',
|
||||
recipients=[
|
||||
{'phone': "+44 7700 900989", 'registration number': 'LC12 BFL', 'date': '24 December 2015'},
|
||||
{'phone': "+44 7700 900479", 'registration number': 'DU04 AOM', 'date': '25 December 2015'},
|
||||
{'phone': "+44 7700 900964", 'registration number': 'M91 MJB', 'date': '26 December 2015'},
|
||||
{'phone': "+44 7700 900703", 'registration number': 'Y249 NPU', 'date': '31 December 2015'},
|
||||
{'phone': "+44 7700 900730", 'registration number': '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
|
||||
"""
|
||||
number_of_recipients=number_of_recipients,
|
||||
recipients={
|
||||
"first_three": recipients[:3] if too_many_recipients_to_display else [],
|
||||
"last_three": recipients[number_of_recipients - 3:] if too_many_recipients_to_display else [],
|
||||
"all": recipients if not too_many_recipients_to_display else []
|
||||
},
|
||||
message_template=message_templates[0]['body']
|
||||
)
|
||||
elif request.method == 'POST':
|
||||
return redirect(url_for('.showjob'))
|
||||
|
||||
Reference in New Issue
Block a user