diff --git a/budget/models.py b/budget/models.py index b889794..3dcd709 100644 --- a/budget/models.py +++ b/budget/models.py @@ -44,6 +44,10 @@ class Project(db.Model): 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): """Return the list of bills related to this project""" return Bill.query.join(Person, Project)\ diff --git a/budget/templates/dashboard.html b/budget/templates/dashboard.html index 44ece2d..796f4f4 100644 --- a/budget/templates/dashboard.html +++ b/budget/templates/dashboard.html @@ -4,7 +4,16 @@ {% for project in projects %} - + + +{% if project.has_bills() %} + + +{% else %} + + +{% endif %} + {% endfor %}
{{ _("Project") }}{{ _("Number of members") }}{{ _("Number of bills") }}{{_("Newest bill")}}{{_("Oldest bill")}}
{{ project.name }}{{ project.members | count }}{{ project.get_bills().count() }}{{ project.get_bills()[1].date }}{{ project.get_bills()[-1].date }}
{{ project.name }}{{ project.members | count }}{{ project.get_bills().count() }}{{ project.get_bills()[0].date }}{{ project.get_bills()[-1].date }}
{% endblock %}