costs sum works in view fallenbirds
This commit is contained in:
parent
c06acb284a
commit
57bd930907
4 changed files with 4 additions and 6 deletions
|
@ -28,9 +28,6 @@ class FallenBird(models.Model):
|
||||||
diagnostic_finding = models.CharField(
|
diagnostic_finding = models.CharField(
|
||||||
max_length=256, verbose_name=_("Diagnose bei Fund")
|
max_length=256, verbose_name=_("Diagnose bei Fund")
|
||||||
)
|
)
|
||||||
# costs = models.DecimalField(
|
|
||||||
# max_digits=5, decimal_places=2, default="0.00", verbose_name=_("Kosten")
|
|
||||||
# )
|
|
||||||
rescuer = models.ForeignKey(
|
rescuer = models.ForeignKey(
|
||||||
Rescuer,
|
Rescuer,
|
||||||
on_delete=models.SET_NULL,
|
on_delete=models.SET_NULL,
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
<td>{{ bird.place }}</td>
|
<td>{{ bird.place }}</td>
|
||||||
<td>{{ bird.status }}</td>
|
<td>{{ bird.status }}</td>
|
||||||
<td>{{ bird.aviary|default_if_none:"" }}</td>
|
<td>{{ bird.aviary|default_if_none:"" }}</td>
|
||||||
<td>{{ bird.costs }}</td>
|
<td>{{ bird.total_costs |default_if_none:"0,00" }} €</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import names
|
import names
|
||||||
|
from django.db.models import Sum
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.shortcuts import HttpResponse, redirect, render
|
from django.shortcuts import HttpResponse, redirect, render
|
||||||
from rescuer.models import Rescuer
|
from rescuer.models import Rescuer
|
||||||
|
@ -42,7 +43,7 @@ def bird_help(request):
|
||||||
|
|
||||||
@login_required(login_url="account_login")
|
@login_required(login_url="account_login")
|
||||||
def bird_all(request):
|
def bird_all(request):
|
||||||
birds = FallenBird.objects.all()
|
birds = FallenBird.objects.all().annotate(total_costs=Sum('costs__costs'))
|
||||||
rescuer_modal = Rescuer.objects.all()
|
rescuer_modal = Rescuer.objects.all()
|
||||||
context = {"birds": birds, "rescuer_modal": rescuer_modal}
|
context = {"birds": birds, "rescuer_modal": rescuer_modal}
|
||||||
# Post came from the modal form.
|
# Post came from the modal form.
|
||||||
|
|
|
@ -23,7 +23,7 @@ class CostsForm(forms.ModelForm):
|
||||||
]
|
]
|
||||||
labels = {
|
labels = {
|
||||||
"id_bird": _("Patient"),
|
"id_bird": _("Patient"),
|
||||||
"costs": _("Betrag"),
|
"costs": _("Betrag [€]"),
|
||||||
"comment": _("Bemerkung"),
|
"comment": _("Bemerkung"),
|
||||||
"created": _("Gebucht am"),
|
"created": _("Gebucht am"),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue