1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

Merge pull request #72 from aavenel/master

Fix a crash in dashboard view
This commit is contained in:
Alexis Metaireau 2011-12-03 14:32:51 -08:00
commit 5c4178b3b5
2 changed files with 14 additions and 1 deletions

View file

@ -44,6 +44,10 @@ class Project(db.Model):
return balances return balances
def has_bills(self):
"""return if the project do have bills or not"""
return self.get_bills().count() != 0
def get_bills(self): def get_bills(self):
"""Return the list of bills related to this project""" """Return the list of bills related to this project"""
return Bill.query.join(Person, Project)\ return Bill.query.join(Person, Project)\

View file

@ -4,7 +4,16 @@
<table id="bill_table" class="list_bills common-table zebra-striped"> <table id="bill_table" class="list_bills common-table zebra-striped">
<thead><tr><th>{{ _("Project") }}</th><th>{{ _("Number of members") }}</th><th>{{ _("Number of bills") }}</th><th>{{_("Newest bill")}}</th><th>{{_("Oldest bill")}}</th></tr></thead> <thead><tr><th>{{ _("Project") }}</th><th>{{ _("Number of members") }}</th><th>{{ _("Number of bills") }}</th><th>{{_("Newest bill")}}</th><th>{{_("Oldest bill")}}</th></tr></thead>
<tbody>{% for project in projects %} <tbody>{% for project in projects %}
<tr><td>{{ project.name }}</td><td>{{ project.members | count }}</td><td>{{ project.get_bills().count() }}</td><td>{{ project.get_bills()[1].date }}</td><td>{{ project.get_bills()[-1].date }}</tr> <tr>
<td>{{ project.name }}</td><td>{{ project.members | count }}</td><td>{{ project.get_bills().count() }}</td>
{% if project.has_bills() %}
<td>{{ project.get_bills()[0].date }}</td>
<td>{{ project.get_bills()[-1].date }}</td>
{% else %}
<td></td>
<td></td>
{% endif %}
</tr>
{% endfor %}</tbody> {% endfor %}</tbody>
</table> </table>
{% endblock %} {% endblock %}