mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 08:31:00 -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:
@@ -6,6 +6,7 @@ from datetime import datetime, time, timedelta, timezone
|
||||
from functools import wraps
|
||||
from io import BytesIO, StringIO
|
||||
from itertools import chain
|
||||
from numbers import Number
|
||||
from os import path
|
||||
from urllib.parse import urlparse
|
||||
|
||||
@@ -602,3 +603,11 @@ class PermanentRedirect(RequestRedirect):
|
||||
and Windows 8.1, so this class keeps the original status code of 301.
|
||||
"""
|
||||
code = 301
|
||||
|
||||
|
||||
def format_thousands(value):
|
||||
if isinstance(value, Number):
|
||||
return '{:,.0f}'.format(value)
|
||||
if value is None:
|
||||
return ''
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user