Revert "add pagination to inbox page"

This commit is contained in:
Chris Waszczuk
2018-04-04 14:18:03 +01:00
committed by GitHub
parent 628d8ac5a8
commit 6153389e01
7 changed files with 32 additions and 90 deletions

View File

@@ -105,7 +105,7 @@ def get_sms_thread(service_id, user_number):
notification_api_client.get_notifications_for_service(service_id,
to=user_number,
template_type='sms')['notifications'] +
service_api_client.get_inbound_sms(service_id, user_number=user_number)['data']
service_api_client.get_inbound_sms(service_id, user_number=user_number)
), key=lambda notification: notification['created_at']):
is_inbound = ('notify_number' in notification)

View File

@@ -31,8 +31,6 @@ from app.utils import (
FAILURE_STATUSES,
REQUESTED_STATUSES,
Spreadsheet,
generate_next_dict,
generate_previous_dict,
get_current_financial_year,
user_has_permissions,
)
@@ -195,7 +193,7 @@ def inbox(service_id):
return render_template(
'views/dashboard/inbox.html',
partials=get_inbox_partials(service_id),
updates_url=url_for('.inbox_updates', service_id=service_id, page=request.args.get('page')),
updates_url=url_for('.inbox_updates', service_id=service_id),
)
@@ -221,7 +219,7 @@ def inbox_download(service_id):
message['user_number'],
message['content'].lstrip(('=+-@')),
format_datetime_numeric(message['created_at']),
] for message in service_api_client.get_inbound_sms(service_id)['data']]
] for message in service_api_client.get_inbound_sms(service_id)]
).as_csv_data,
mimetype='text/csv',
headers={
@@ -233,12 +231,11 @@ def inbox_download(service_id):
def get_inbox_partials(service_id):
page = int(request.args.get('page', 1))
if 'inbound_sms' not in current_service['permissions']:
abort(403)
inbound_messages_data = service_api_client.get_inbound_sms(service_id, page=page)
inbound_messages = inbound_messages_data['data']
inbound_messages = service_api_client.get_inbound_sms(service_id)
messages_to_show = {}
# get the most recent message for each number
@@ -255,22 +252,12 @@ def get_inbox_partials(service_id):
else:
inbound_number = None
prev_page = None
if page > 1:
prev_page = generate_previous_dict('main.inbox', service_id, page)
next_page = None
if inbound_messages_data['has_next']:
next_page = generate_next_dict('main.inbox', service_id, page)
return {'messages': render_template(
'views/dashboard/_inbox_messages.html',
messages=list(messages_to_show),
count_of_messages=len(inbound_messages),
count_of_users=count_of_users,
inbound_number=inbound_number,
prev_page=prev_page,
next_page=next_page
)}