Merge pull request #935 from dod-ccpo/fix-activity-log-pagination
Fix audit log pagination urls
This commit is contained in:
commit
14fd294b9c
@ -4,6 +4,7 @@ from atst.utils.localization import translate
|
||||
from flask import render_template
|
||||
from jinja2 import contextfilter
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
from urllib.parse import urlparse, urlunparse, parse_qs, urlencode
|
||||
|
||||
|
||||
def iconSvg(name):
|
||||
@ -19,6 +20,17 @@ def dollars(value):
|
||||
return "${:,.2f}".format(numberValue)
|
||||
|
||||
|
||||
def with_extra_params(url, **params):
|
||||
"""
|
||||
Takes an existing url and safely appends additional query parms.
|
||||
"""
|
||||
parsed_url = urlparse(url)
|
||||
parsed_params = parse_qs(parsed_url.query)
|
||||
new_params = {**parsed_params, **params}
|
||||
parsed_url = parsed_url._replace(query=urlencode(new_params))
|
||||
return urlunparse(parsed_url)
|
||||
|
||||
|
||||
def usPhone(number):
|
||||
if not number:
|
||||
return ""
|
||||
@ -63,6 +75,7 @@ def register_filters(app):
|
||||
app.jinja_env.filters["dateFromString"] = dateFromString
|
||||
app.jinja_env.filters["pageWindow"] = pageWindow
|
||||
app.jinja_env.filters["renderAuditEvent"] = renderAuditEvent
|
||||
app.jinja_env.filters["withExtraParams"] = with_extra_params
|
||||
|
||||
@contextfilter
|
||||
def translateWithoutCache(context, *kwargs):
|
||||
|
@ -11,7 +11,7 @@
|
||||
{% set button_class = button_class + "usa-button-secondary" %}
|
||||
{% endif %}
|
||||
|
||||
<a id="{{ label }}" type="button" class="{{ button_class }}" href="{{ url if not disabled else 'null' }}">{{ label }}</a>
|
||||
<a id="{{ label }}" type="button" class="{{ button_class }}" href="{{ url |withExtraParams(page=i) if not disabled else 'null' }}">{{ label }}</a>
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro Pagination(pagination, url) -%}
|
||||
|
Loading…
x
Reference in New Issue
Block a user