mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
Munge stuff into a consistent event data type
We store our audit history in two ways: 1. A list of versions of a service 2. A list of events to do with API keys In the future there could be auditing data which we want to display that is stored in other formats (for example the event table). This commit adds some objects which wrap around the different types of auditing data, and expose a consistent interface to them. This architecture will let us: - write clean code in the presentation layer to display these events on a page - add more types of events in the future by subclassing the `Event` data type, without having to rewrite anything in the presentation layer
This commit is contained in:
@@ -3,7 +3,6 @@ import os
|
||||
import urllib
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from functools import partial
|
||||
from numbers import Number
|
||||
from time import monotonic
|
||||
|
||||
import ago
|
||||
@@ -84,7 +83,7 @@ from app.notify_client.template_statistics_api_client import (
|
||||
template_statistics_client,
|
||||
)
|
||||
from app.notify_client.user_api_client import user_api_client
|
||||
from app.utils import get_logo_cdn_domain, id_safe
|
||||
from app.utils import format_thousands, get_logo_cdn_domain, id_safe
|
||||
|
||||
login_manager = LoginManager()
|
||||
csrf = CSRFProtect()
|
||||
@@ -351,14 +350,6 @@ def format_delta(date):
|
||||
)
|
||||
|
||||
|
||||
def format_thousands(value):
|
||||
if isinstance(value, Number):
|
||||
return '{:,.0f}'.format(value)
|
||||
if value is None:
|
||||
return ''
|
||||
return value
|
||||
|
||||
|
||||
def valid_phone_number(phone_number):
|
||||
try:
|
||||
validate_phone_number(phone_number)
|
||||
|
||||
Reference in New Issue
Block a user