mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
Hide the member weights in members list if all weights are "1".
This commit is contained in:
parent
ec8fe2326b
commit
7a630b78ea
4 changed files with 31 additions and 1 deletions
|
@ -50,6 +50,10 @@ class Project(db.Model):
|
|||
|
||||
return balances
|
||||
|
||||
@property
|
||||
def uses_weights(self):
|
||||
return len([i for i in self.members if i.weight != 1]) > 0
|
||||
|
||||
def get_transactions_to_settle_bill(self):
|
||||
"""Return a list of transactions that could be made to settle the bill"""
|
||||
#cache value for better performance
|
||||
|
|
|
@ -198,6 +198,14 @@ tr.payer_line .balance-name{
|
|||
opacity: 0.3;
|
||||
}
|
||||
|
||||
.extra-info {
|
||||
display: none;
|
||||
}
|
||||
|
||||
tr:hover .extra-info {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
max-height:455px;
|
||||
}
|
||||
|
|
|
@ -67,7 +67,9 @@
|
|||
{% set balance = g.project.balance %}
|
||||
{% for member in g.project.members | sort(attribute='name') if member.activated or balance[member.id] != 0 %}
|
||||
<tr id="bal-member-{{ member.id }}" action={% if member.activated %}delete{% else %}reactivate{% endif %}>
|
||||
<td class="balance-name">{{ member.name }} <span class="light">(x{{ member.weight|minimal_round(1) }})</span></td>
|
||||
<td class="balance-name">{{ member.name }}
|
||||
<span class="light{% if not g.project.uses_weights %} extra-info{% endif %}">(x{{ member.weight|minimal_round(1) }})</span>
|
||||
</td>
|
||||
{% if member.activated %}
|
||||
<td>
|
||||
<form class="action delete" action="{{ url_for(".remove_member", member_id=member.id) }}" method="POST">
|
||||
|
|
|
@ -446,6 +446,22 @@ class BudgetTestCase(TestCase):
|
|||
balance = models.Project.query.get("raclette").balance
|
||||
self.assertEqual(set(balance.values()), set([6, -6]))
|
||||
|
||||
def test_weighted_members_list(self):
|
||||
self.post_project("raclette")
|
||||
|
||||
# add two persons
|
||||
self.app.post("/raclette/members/add", data={'name': 'alexis'})
|
||||
self.app.post("/raclette/members/add", data={'name': 'tata', 'weight': 1})
|
||||
|
||||
resp = self.app.get("/raclette/")
|
||||
self.assertIn('extra-info', resp.data)
|
||||
|
||||
self.app.post("/raclette/members/add", data={'name': 'freddy familly', 'weight': 4})
|
||||
|
||||
resp = self.app.get("/raclette/")
|
||||
self.assertNotIn('extra-info', resp.data)
|
||||
|
||||
|
||||
def test_rounding(self):
|
||||
self.post_project("raclette")
|
||||
|
||||
|
|
Loading…
Reference in a new issue