From 5ec3dc0accbd5d66caa0abde249e69d35afc68e8 Mon Sep 17 00:00:00 2001 From: Glandos Date: Thu, 20 Feb 2020 09:43:50 +0100 Subject: [PATCH] Align tables in statistics (#535) * Align tables in statistics The table in sidebar is now aligned with the one in content, to avoid redundant informations. All tables are back to normal on small devices. * fix test * run black on tests --- ihatemoney/static/css/main.css | 8 ++++ ihatemoney/templates/statistics.html | 63 +++++++++++++++------------- ihatemoney/tests/tests.py | 30 ++++++++++--- 3 files changed, 66 insertions(+), 35 deletions(-) diff --git a/ihatemoney/static/css/main.css b/ihatemoney/static/css/main.css index 9c02b283..135a6840 100644 --- a/ihatemoney/static/css/main.css +++ b/ihatemoney/static/css/main.css @@ -325,6 +325,13 @@ footer .footer-left { margin-bottom: 30px; } +@media (min-width: 768px) { + .split_bills, #table_overflow.statistics { + /* The table is shifted to left, so add the spacer width on the right to match */ + width: calc(100% + 15px); + } +} + .project-actions > .delete, .project-actions > .edit { font-size: 0px; @@ -397,6 +404,7 @@ tr.payer_line .balance-name { .balance.table { table-layout: fixed; + margin-top: 30px; } #bill-form > fieldset { diff --git a/ihatemoney/templates/statistics.html b/ihatemoney/templates/statistics.html index 539781ff..73211883 100644 --- a/ihatemoney/templates/statistics.html +++ b/ihatemoney/templates/statistics.html @@ -1,12 +1,14 @@ {% extends "sidebar_table_layout.html" %} {% block sidebar %} -
+
- - - - + + + + + + {% for stat in members_stats| sort(attribute='member.name') %} @@ -21,30 +23,31 @@ {% block content %} -

{{ _("Balance") }}

-
{{ _("Balance") }}
{{ _("Who?") }}{{ _("Balance") }}
{{ stat.member.name }}
- - - {% for stat in members_stats %} - - - - - - {% endfor %} - -
{{ _("Who?") }}{{ _("Paid") }}{{ _("Spent") }}
{{ stat.member.name }}{{ "%0.2f"|format(stat.paid) }}{{ "%0.2f"|format(stat.spent) }}
-

{{ _("Expenses by Month") }}

- - - - {% for month in months %} - - - - - {% endfor %} - -
{{ _("Period") }}{{ _("Spent") }}
{{ _(month.strftime("%B")) }} {{ month.year }}{{ "%0.2f"|format(monthly_stats[month.year][month.month]) }}
+
+ + + + {% for stat in members_stats %} + + + + + + {% endfor %} + +
{{ _("Who?") }}{{ _("Paid") }}{{ _("Spent") }}
{{ stat.member.name }}{{ "%0.2f"|format(stat.paid) }}{{ "%0.2f"|format(stat.spent) }}
+

{{ _("Expenses by Month") }}

+ + + + {% for month in months %} + + + + + {% endfor %} + +
{{ _("Period") }}{{ _("Spent") }}
{{ _(month.strftime("%B")) }} {{ month.year }}{{ "%0.2f"|format(monthly_stats[month.year][month.month]) }}
+
{% endblock %} diff --git a/ihatemoney/tests/tests.py b/ihatemoney/tests/tests.py index a12613c1..c4b1585c 100644 --- a/ihatemoney/tests/tests.py +++ b/ihatemoney/tests/tests.py @@ -931,22 +931,42 @@ class BudgetTestCase(IhatemoneyTestCase): ) response = self.client.get("/raclette/statistics") + first_cell = '' + indent = "\n " self.assertIn( - "alexis\n " - + "20.00\n " + first_cell + + "alexis" + + indent + + "20.00" + + indent + "31.67\n", response.data.decode("utf-8"), ) self.assertIn( - "fred\n " + "20.00\n " + "5.83\n", + first_cell + + "fred" + + indent + + "20.00" + + indent + + "5.83\n", response.data.decode("utf-8"), ) self.assertIn( - "tata\n " + "0.00\n " + "2.50\n", + first_cell + + "tata" + + indent + + "0.00" + + indent + + "2.50\n", response.data.decode("utf-8"), ) self.assertIn( - "toto\n " + "0.00\n " + "0.00\n", + first_cell + + "toto" + + indent + + "0.00" + + indent + + "0.00\n", response.data.decode("utf-8"), )