mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-17 04:59:37 -04:00
Add log of notifications to API integration page
Now that we’ve removed simulated notifications from the dashboard and activity pages they’re not visible anywhere in the app. While they should’t be visible to non-technical users, developers have a real need for Notify to confirm that their code is doing what they expect. This is needed especially when they’re just getting started with Notify. There’s no way of seeing this info from the API either, because a key can only get notifications created with a key of that type. It doesn’t make sense to make this a ‘mode’ of the dashboard or activity because the information about notifications that developers need is also different. So this commit adds up to 50 of the most recent notifications sent via the API to the page that developers use as their ‘home’ page. This also lets us explain the 7 days thing to developers via the empty slate state of this area of the page.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import ago
|
||||
import os
|
||||
import re
|
||||
import urllib
|
||||
import dateutil
|
||||
from datetime import datetime, timedelta, timezone
|
||||
import pytz
|
||||
from flask import (
|
||||
Flask,
|
||||
@@ -115,6 +117,7 @@ def create_app():
|
||||
application.add_template_filter(format_date)
|
||||
application.add_template_filter(format_date_normal)
|
||||
application.add_template_filter(format_date_short)
|
||||
application.add_template_filter(format_delta)
|
||||
application.add_template_filter(format_notification_status)
|
||||
application.add_template_filter(format_notification_status_as_time)
|
||||
application.add_template_filter(format_notification_status_as_field_status)
|
||||
@@ -251,6 +254,19 @@ def format_date_short(date):
|
||||
return gmt_timezones(date).strftime('%d %B').lstrip('0')
|
||||
|
||||
|
||||
def format_delta(date):
|
||||
return ago.human(
|
||||
(
|
||||
datetime.now(timezone.utc)
|
||||
) - (
|
||||
dateutil.parser.parse(date)
|
||||
),
|
||||
future_tense='{} from now', # No-one should ever see this
|
||||
past_tense='{} ago',
|
||||
precision=1
|
||||
)
|
||||
|
||||
|
||||
def valid_phone_number(phone_number):
|
||||
try:
|
||||
validate_phone_number(phone_number)
|
||||
|
||||
Reference in New Issue
Block a user