Use Flask for routing

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
This commit is contained in:
Chris Hill-Scott
2015-12-10 21:15:20 +00:00
parent dbc55e76b0
commit 8a34fa7e0a
6 changed files with 105 additions and 90 deletions

View File

@@ -41,47 +41,6 @@ def addservice():
return render_template('views/add-service.html')
@main.route("/send-sms")
def sendsms():
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
"""
},
]
)
@main.route("/check-sms")
def checksms():
return render_template(
'views/check-sms.html',
recipients=[
{'phone': "+44 7815838437", 'registration': 'LC12 BFL', 'date': '25 December 2015'},
{'phone': "+44 7815838437", 'registration': 'LC12 BFL', 'date': '25 December 2015'},
{'phone': "+44 7815838437", 'registration': 'LC12 BFL', 'date': '25 December 2015'},
{'phone': "+44 7815838437", 'registration': 'LC12 BFL', 'date': '25 December 2015'},
{'phone': "+44 7815838437", 'registration': 'LC12 BFL', 'date': '25 December 2015'}
],
message_template="""
Vehicle tax: Your vehicle tax for ((registration number)) expires on ((date)).
Tax your vehicle at www.gov.uk/vehicle-tax
"""
)
@main.route("/email-not-received")
def emailnotreceived():
return render_template('views/email-not-received.html')