mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-15 23:38:52 -04:00
Make it say later today
Categories before: > Now, today, tomorrow, Friday… Categories after: > Now, later today, tomorrow Friday… This reduces the ambiguity of ‘now’ vs ‘today’, and keeping the word ‘later’ suggests what this features is about. This implementation here is a bit hacky, but it works…
This commit is contained in:
@@ -78,10 +78,11 @@
|
||||
.on('click', '.js-category-button', function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
let day = $(this).attr('value');
|
||||
let wordsInDay = $(this).attr('value').split(' ');
|
||||
let day = wordsInDay[wordsInDay.length - 1].toLowerCase();
|
||||
render('choose', {
|
||||
'choices': choices.filter(
|
||||
element => element.label.indexOf(day) > -1
|
||||
element => element.label.toLowerCase().indexOf(day) > -1
|
||||
),
|
||||
'name': name
|
||||
});
|
||||
|
||||
@@ -44,11 +44,11 @@ def get_human_time(time):
|
||||
)
|
||||
|
||||
|
||||
def get_human_day(time):
|
||||
def get_human_day(time, prefix_today_with='T'):
|
||||
# Add 1 hour to get ‘midnight today’ instead of ‘midnight tomorrow’
|
||||
time = (time - timedelta(hours=1)).strftime('%A')
|
||||
if time == datetime.utcnow().strftime('%A'):
|
||||
return 'Today'
|
||||
return '{}oday'.format(prefix_today_with)
|
||||
if time == (datetime.utcnow() + timedelta(days=1)).strftime('%A'):
|
||||
return 'Tomorrow'
|
||||
return time
|
||||
@@ -71,7 +71,10 @@ def get_next_days_until(until):
|
||||
now = datetime.utcnow()
|
||||
days = int((until - now).total_seconds() / (60 * 60 * 24))
|
||||
return [
|
||||
get_human_day((now + timedelta(days=i)).replace(tzinfo=pytz.utc))
|
||||
get_human_day(
|
||||
(now + timedelta(days=i)).replace(tzinfo=pytz.utc),
|
||||
prefix_today_with='Later t'
|
||||
)
|
||||
for i in range(0, days + 1)
|
||||
]
|
||||
|
||||
|
||||
@@ -41,5 +41,5 @@ def test_form_defaults_to_now(app_):
|
||||
@freeze_time("2016-01-01 11:09:00.061258")
|
||||
def test_form_contains_next_three_days(app_):
|
||||
assert ChooseTimeForm().scheduled_for.categories == [
|
||||
'Today', 'Tomorrow', 'Sunday', 'Monday'
|
||||
'Later today', 'Tomorrow', 'Sunday', 'Monday'
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user