From 1d32c766e8d771f6c149f152b8a624e36aec632e Mon Sep 17 00:00:00 2001 From: chrisw Date: Wed, 4 Apr 2018 15:39:50 +0100 Subject: [PATCH] remove X messages from Y users msg --- app/main/views/dashboard.py | 15 +-------------- .../views/dashboard/_inbox_messages.html | 6 ------ tests/app/main/views/test_dashboard.py | 8 ++++---- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/app/main/views/dashboard.py b/app/main/views/dashboard.py index 3d6692dbc..e401c498f 100644 --- a/app/main/views/dashboard.py +++ b/app/main/views/dashboard.py @@ -12,7 +12,6 @@ from flask import ( url_for, ) from flask_login import login_required -from notifications_utils.recipients import format_phone_number_human_readable from werkzeug.utils import redirect from app import ( @@ -242,16 +241,6 @@ def get_inbox_partials(service_id): inbound_messages_data = service_api_client.get_inbound_sms(service_id, page=page) inbound_messages = inbound_messages_data['data'] - messages_to_show = {} - # get the most recent message for each number - for message in inbound_messages: - human_readable = format_phone_number_human_readable(message['user_number']) - if human_readable not in messages_to_show: - messages_to_show[human_readable] = message - - count_of_users = len(messages_to_show) - messages_to_show = sorted(messages_to_show.values(), key=lambda x: x['created_at'], reverse=True) - if not inbound_messages: inbound_number = inbound_number_client.get_inbound_sms_number_for_service(service_id)['data']['number'] else: @@ -266,9 +255,7 @@ def get_inbox_partials(service_id): 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, + messages=inbound_messages, inbound_number=inbound_number, prev_page=prev_page, next_page=next_page diff --git a/app/templates/views/dashboard/_inbox_messages.html b/app/templates/views/dashboard/_inbox_messages.html index 1a1a3108e..37d9a317b 100644 --- a/app/templates/views/dashboard/_inbox_messages.html +++ b/app/templates/views/dashboard/_inbox_messages.html @@ -34,12 +34,6 @@ {% endcall %} {% endcall %} - {% if messages %} - - {% endif %} {{ previous_next_navigation(prev_page, next_page) }} diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index def6412c4..3f2d3ad0f 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -164,10 +164,13 @@ def test_inbound_messages_shows_count_of_messages( @pytest.mark.parametrize('index, expected_row', enumerate([ '07900 900000 message-1 1 hour ago', + '07900 900000 message-2 1 hour ago', + '07900 900000 message-3 1 hour ago', '07900 900002 message-4 3 hours ago', '07900 900004 message-5 5 hours ago', '07900 900006 message-6 7 hours ago', '07900 900008 message-7 9 hours ago', + '07900 900008 message-8 9 hours ago', ])) def test_inbox_showing_inbound_messages( logged_in_client, @@ -189,11 +192,8 @@ def test_inbox_showing_inbound_messages( assert response.status_code == 200 rows = page.select('tbody tr') - assert len(rows) == 5 + assert len(rows) == 8 assert normalize_spaces(rows[index].text) == expected_row - assert normalize_spaces(page.select('.table-show-more-link')) == ( - '8 messages from 5 users' - ) assert page.select_one('a[download]')['href'] == url_for( 'main.inbox_download', service_id=SERVICE_ONE_ID,