mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-06 06:20:53 -04:00
Only show the filters if they will have an effect
If you never create any API keys we shouldn’t give you the option to see API-related events – it will only confuse things. And since there’s (currently) only one type of event left once you take API key events out of the picture it doesn’t make sense to show the filters at all.
This commit is contained in:
@@ -4,17 +4,21 @@ from flask import render_template, request
|
||||
|
||||
from app import current_service, format_date_numeric
|
||||
from app.main import main
|
||||
from app.models.event import APIKeyEvents, ServiceEvents
|
||||
from app.models.event import APIKeyEvent, APIKeyEvents, ServiceEvents
|
||||
from app.utils import user_has_permissions
|
||||
|
||||
|
||||
@main.route("/services/<service_id>/history")
|
||||
@user_has_permissions('manage_service')
|
||||
def history(service_id):
|
||||
|
||||
events = _get_events(current_service.id, request.args.get('selected'))
|
||||
|
||||
return render_template(
|
||||
'views/temp-history.html',
|
||||
days=_chunk_events_by_day(
|
||||
_get_events(current_service.id, request.args.get('selected'))
|
||||
days=_chunk_events_by_day(events),
|
||||
show_navigation=request.args.get('selected') or any(
|
||||
isinstance(event, APIKeyEvent) for event in events
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -11,15 +11,19 @@
|
||||
|
||||
{{ page_header("Audit events") }}
|
||||
|
||||
{{ pill(
|
||||
[
|
||||
('All', None, url_for('main.history', service_id=current_service.id), None),
|
||||
('Service', 'service', url_for('main.history', service_id=current_service.id, selected='service'), None),
|
||||
('API keys', 'api', url_for('main.history', service_id=current_service.id, selected='api'), None),
|
||||
],
|
||||
request.args.get('selected'),
|
||||
show_count=False
|
||||
) }}
|
||||
{% if show_navigation %}
|
||||
<div class="bottom-gutter">
|
||||
{{ pill(
|
||||
[
|
||||
('All', None, url_for('main.history', service_id=current_service.id), None),
|
||||
('Service settings', 'service', url_for('main.history', service_id=current_service.id, selected='service'), None),
|
||||
('API keys', 'api', url_for('main.history', service_id=current_service.id, selected='api'), None),
|
||||
],
|
||||
request.args.get('selected'),
|
||||
show_count=False
|
||||
) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% for day, events in days %}
|
||||
<h2 class="heading-small top-gutter">
|
||||
|
||||
Reference in New Issue
Block a user