mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 22:40:31 -04:00
Refactor history off the service model
Directly referencing the `ModelList` instances will let us more easily make choices at the view layer about which kinds of events to show, and is one less layer of indirection to jump through.
This commit is contained in:
@@ -4,6 +4,7 @@ from flask import render_template
|
||||
|
||||
from app import current_service, format_date_numeric
|
||||
from app.main import main
|
||||
from app.models.event import APIKeyEvents, ServiceEvents
|
||||
from app.utils import user_has_permissions
|
||||
|
||||
|
||||
@@ -12,10 +13,16 @@ from app.utils import user_has_permissions
|
||||
def history(service_id):
|
||||
return render_template(
|
||||
'views/temp-history.html',
|
||||
days=_chunk_events_by_day(current_service.history)
|
||||
days=_chunk_events_by_day(
|
||||
_get_events(current_service.id)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def _get_events(service_id):
|
||||
return APIKeyEvents(service_id) + ServiceEvents(service_id)
|
||||
|
||||
|
||||
def _chunk_events_by_day(events):
|
||||
|
||||
days = defaultdict(list)
|
||||
|
||||
Reference in New Issue
Block a user