better display of floats, better rule for on_delete on models
This commit is contained in:
@@ -12,6 +12,11 @@ class Etiquette(models.Model):
|
||||
return "%s" % self.nom
|
||||
|
||||
|
||||
def get_placeholder_label():
|
||||
print("get placeholder")
|
||||
return Etiquette.objects.get_or_create(nom="Mettez-moi à jour")[0]
|
||||
|
||||
|
||||
class MonthManager(models.Manager):
|
||||
|
||||
|
||||
@@ -75,7 +80,8 @@ class Enregistrement(models.Model):
|
||||
|
||||
date = models.DateField()
|
||||
montant = models.FloatField()
|
||||
etiquette = models.ForeignKey(Etiquette)
|
||||
etiquette = models.ForeignKey(Etiquette,
|
||||
on_delete=models.SET(get_placeholder_label))
|
||||
description = models.CharField(max_length=512)
|
||||
|
||||
def __str__(self):
|
||||
@@ -84,10 +90,13 @@ class Enregistrement(models.Model):
|
||||
class Meta:
|
||||
ordering = ('date',)
|
||||
|
||||
|
||||
|
||||
class EnregistrementRecursif(models.Model):
|
||||
jour = models.IntegerField()
|
||||
montant = models.FloatField()
|
||||
etiquette = models.ForeignKey(Etiquette)
|
||||
etiquette = models.ForeignKey(Etiquette,
|
||||
on_delete=models.SET(get_placeholder_label))
|
||||
description = models.CharField(max_length=512)
|
||||
created_date = models.DateField()
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</div>
|
||||
<div class="col-md-3 mt-3">
|
||||
<h2 class="page-title">Balance
|
||||
<span class="badge float-right badge-{% if data.balance > 0 %}success{% else %}danger{% endif%}">{{ data.balance }} €</span>
|
||||
<span class="badge float-right badge-{% if data.balance > 0 %}success{% else %}danger{% endif%}">{{ data.balance|floatformat:-2 }} €</span>
|
||||
</h2>
|
||||
<div class="card mt-3" >
|
||||
<div class="card-header">
|
||||
@@ -52,7 +52,7 @@
|
||||
<ul class="list-group list-group-flush">
|
||||
{% for label, montant in data.par_etiquette.items %}
|
||||
<li class="list-group-item">{{ label }}
|
||||
<span class="badge badge-dark p-2 align-middle float-right">{{ montant }} €</span>
|
||||
<span class="badge badge-dark p-2 align-middle float-right">{{ montant|floatformat:-2 }} €</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
Reference in New Issue
Block a user