mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
remove X messages from Y users msg
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -34,12 +34,6 @@
|
||||
</span>
|
||||
{% endcall %}
|
||||
{% endcall %}
|
||||
{% if messages %}
|
||||
<p class="table-show-more-link">
|
||||
{{ count_of_messages }} message{{ '' if 1 == count_of_messages else 's' }}
|
||||
from {{ count_of_users }} user{{ '' if 1 == count_of_users else 's' }}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{{ previous_next_navigation(prev_page, next_page) }}
|
||||
</div>
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user