mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 18:31:13 -05:00
Move get_prev_next_pagination_links to utils
This will mean it can later be reused whereever we want
This commit is contained in:
11
app/utils.py
11
app/utils.py
@@ -29,6 +29,17 @@ def pagination_links(pagination, endpoint, **kwargs):
|
||||
return links
|
||||
|
||||
|
||||
def get_prev_next_pagination_links(current_page, next_page_exists, endpoint, **kwargs):
|
||||
if 'page' in kwargs:
|
||||
kwargs.pop('page', None)
|
||||
links = {}
|
||||
if current_page > 1:
|
||||
links['prev'] = url_for(endpoint, page=current_page - 1, **kwargs)
|
||||
if next_page_exists:
|
||||
links['next'] = url_for(endpoint, page=current_page + 1, **kwargs)
|
||||
return links
|
||||
|
||||
|
||||
def url_with_token(data, url, config, base_url=None):
|
||||
from notifications_utils.url_safe_token import generate_token
|
||||
token = generate_token(data, config['SECRET_KEY'], config['DANGEROUS_SALT'])
|
||||
|
||||
Reference in New Issue
Block a user