Make text message price dependent on date

So we don’t have to deploy a change on a Saturday.

In the future this could pull from the rates in the database, but while
that code is shifting around I didn’t want to touoch it. We’d also have
to think about caching so as not to have a non-authenticated route
hitting the database.
This commit is contained in:
Chris Hill-Scott
2022-04-28 10:48:44 +01:00
parent dfc37c2371
commit 4a0f5e8a41
5 changed files with 47 additions and 3 deletions

View File

@@ -1,19 +1,28 @@
from datetime import datetime
from flask import current_app, render_template
from flask_login import current_user
from notifications_utils.international_billing_rates import (
INTERNATIONAL_BILLING_RATES,
)
from notifications_utils.timezones import convert_utc_to_bst
from app.main import main
from app.main.forms import SearchByNameForm
from app.main.views.sub_navigation_dictionaries import pricing_nav
def get_current_sms_rate():
if convert_utc_to_bst(datetime.utcnow()) < convert_utc_to_bst(datetime(2022, 5, 1)):
return '1.61'
return '1.72'
@main.route('/pricing')
def pricing():
return render_template(
'views/pricing/index.html',
sms_rate=0.0158,
sms_rate=get_current_sms_rate(),
international_sms_rates=sorted([
(cc, country['names'], country['billable_units'])
for cc, country in INTERNATIONAL_BILLING_RATES.items()