translations
This commit is contained in:
parent
e1f85e48e5
commit
bd75085b78
10 changed files with 135 additions and 31 deletions
|
@ -3,14 +3,22 @@ from uuid import uuid4
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
CHOICE_AVIARY = [("Offen","Offen"), ("Geschlossen", "Geschlossen"), ("Gesperrt", "Gesperrt")]
|
|
||||||
|
CHOICE_AVIARY = [
|
||||||
|
("Offen", "Offen"),
|
||||||
|
("Geschlossen", "Geschlossen"),
|
||||||
|
("Gesperrt", "Gesperrt")]
|
||||||
|
|
||||||
|
|
||||||
class Aviary(models.Model):
|
class Aviary(models.Model):
|
||||||
id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
|
id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
|
||||||
description = models.CharField(
|
description = models.CharField(
|
||||||
max_length=256, verbose_name=_("Beschreibung"), unique=True
|
max_length=256, verbose_name=_("Beschreibung"), unique=True
|
||||||
)
|
)
|
||||||
condition = models.CharField(max_length=256, choices=CHOICE_AVIARY, verbose_name=_("Zustand"))
|
condition = models.CharField(
|
||||||
|
max_length=256,
|
||||||
|
choices=CHOICE_AVIARY,
|
||||||
|
verbose_name=_("Zustand"))
|
||||||
last_ward_round = models.DateField(verbose_name=_("letzte Visite"))
|
last_ward_round = models.DateField(verbose_name=_("letzte Visite"))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -5,7 +5,13 @@ from .models import Bird, FallenBird, BirdStatus, Circumstance
|
||||||
|
|
||||||
@admin.register(FallenBird)
|
@admin.register(FallenBird)
|
||||||
class FallenBirdAdmin(admin.ModelAdmin):
|
class FallenBirdAdmin(admin.ModelAdmin):
|
||||||
list_display = ["bird", "date_found", "place", "created", "updated", "user"]
|
list_display = [
|
||||||
|
"bird",
|
||||||
|
"date_found",
|
||||||
|
"place",
|
||||||
|
"created",
|
||||||
|
"updated",
|
||||||
|
"user"]
|
||||||
list_filter = ("bird", "created", "user")
|
list_filter = ("bird", "created", "user")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,10 @@ class BirdAddForm(forms.ModelForm):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
widgets = {
|
widgets = {
|
||||||
"date_found": DateInput(format="%Y-%m-%d", attrs={"value": date.today})
|
"date_found": DateInput(
|
||||||
}
|
format="%Y-%m-%d",
|
||||||
|
attrs={
|
||||||
|
"value": date.today})}
|
||||||
model = FallenBird
|
model = FallenBird
|
||||||
fields = [
|
fields = [
|
||||||
"bird_identifier",
|
"bird_identifier",
|
||||||
|
@ -26,6 +28,8 @@ class BirdAddForm(forms.ModelForm):
|
||||||
"date_found",
|
"date_found",
|
||||||
"place",
|
"place",
|
||||||
"find_circumstances",
|
"find_circumstances",
|
||||||
|
"diagnostic_finding",
|
||||||
|
"costs",
|
||||||
# "find_circumstances_new",
|
# "find_circumstances_new",
|
||||||
# "status",
|
# "status",
|
||||||
]
|
]
|
||||||
|
@ -35,6 +39,8 @@ class BirdAddForm(forms.ModelForm):
|
||||||
"date_found": _("Datum des Fundes"),
|
"date_found": _("Datum des Fundes"),
|
||||||
"place": _("Fundort"),
|
"place": _("Fundort"),
|
||||||
"find_circumstances": _("Fundumstände"),
|
"find_circumstances": _("Fundumstände"),
|
||||||
|
"diagnostic_finding": _("Diagnose bei Fund"),
|
||||||
|
"costs": _("Kosten"),
|
||||||
# "find_circumstances_new": _("neuer Fundumstand"),
|
# "find_circumstances_new": _("neuer Fundumstand"),
|
||||||
# "status": _("Status"),
|
# "status": _("Status"),
|
||||||
}
|
}
|
||||||
|
@ -52,6 +58,8 @@ class BirdEditForm(forms.ModelForm):
|
||||||
"status",
|
"status",
|
||||||
"aviary",
|
"aviary",
|
||||||
"find_circumstances",
|
"find_circumstances",
|
||||||
|
"diagnostic_finding",
|
||||||
|
"costs",
|
||||||
]
|
]
|
||||||
labels = {
|
labels = {
|
||||||
"bird": _("Vogel"),
|
"bird": _("Vogel"),
|
||||||
|
@ -60,4 +68,6 @@ class BirdEditForm(forms.ModelForm):
|
||||||
"status": _("Status"),
|
"status": _("Status"),
|
||||||
"aviary": _("Voliere"),
|
"aviary": _("Voliere"),
|
||||||
"find_circumstances": _("Fundumstände"),
|
"find_circumstances": _("Fundumstände"),
|
||||||
|
"diagnostic_finding": _("Diagnose bei Fund"),
|
||||||
|
"costs": _("Kosten"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Generated by Django 4.2.3 on 2023-07-12 06:59
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("bird", "0001_initial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="bird",
|
||||||
|
name="name",
|
||||||
|
field=models.CharField(
|
||||||
|
max_length=256, unique=True, verbose_name="Bezeichnung"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="birdstatus",
|
||||||
|
name="description",
|
||||||
|
field=models.CharField(
|
||||||
|
max_length=256, unique=True, verbose_name="Bezeichnung"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="circumstance",
|
||||||
|
name="description",
|
||||||
|
field=models.CharField(max_length=256, verbose_name="Bezeichnung"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="fallenbird",
|
||||||
|
name="costs",
|
||||||
|
field=models.DecimalField(decimal_places=2, max_digits=5),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,11 +1,10 @@
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
|
from aviary.models import Aviary
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from aviary.models import Aviary
|
|
||||||
from rescuer.models import Rescuer
|
from rescuer.models import Rescuer
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,13 +20,13 @@ class FallenBird(models.Model):
|
||||||
place = models.CharField(max_length=256, verbose_name=_("Ort des Fundes"))
|
place = models.CharField(max_length=256, verbose_name=_("Ort des Fundes"))
|
||||||
created = models.DateTimeField(auto_now_add=True, verbose_name=_("angelegt am"))
|
created = models.DateTimeField(auto_now_add=True, verbose_name=_("angelegt am"))
|
||||||
updated = models.DateTimeField(auto_now=True, verbose_name=_("geändert am"))
|
updated = models.DateTimeField(auto_now=True, verbose_name=_("geändert am"))
|
||||||
find_circumstances = models.ForeignKey("Circumstance", on_delete=models.CASCADE)
|
find_circumstances = models.ForeignKey("Circumstance", on_delete=models.CASCADE, verbose_name=_("Fundumstände"))
|
||||||
diagnostic_finding = models.CharField(max_length=256)
|
diagnostic_finding = models.CharField(max_length=256, verbose_name=_("Diagnose bei Fund"))
|
||||||
costs = models.DecimalField(max_digits=5, decimal_places=2)
|
costs = models.DecimalField(max_digits=5, decimal_places=2, verbose_name=_("Kosten"))
|
||||||
rescuer = models.ForeignKey( Rescuer, on_delete=models.SET_NULL, blank=True, null=True)
|
rescuer = models.ForeignKey( Rescuer, on_delete=models.SET_NULL, blank=True, null=True, verbose_name=_("Finder"))
|
||||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, verbose_name=_("Benutzer"))
|
||||||
status = models.ForeignKey("BirdStatus", on_delete=models.CASCADE, default=1)
|
status = models.ForeignKey("BirdStatus", on_delete=models.CASCADE, default=1)
|
||||||
aviary = models.ForeignKey(Aviary, on_delete=models.SET_NULL, blank=True, null=True)
|
aviary = models.ForeignKey(Aviary, on_delete=models.SET_NULL, blank=True, null=True, verbose_name=_("Voliere"))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Patient")
|
verbose_name = _("Patient")
|
||||||
|
|
|
@ -17,16 +17,12 @@ def bird_create(request):
|
||||||
# Just show only related rescuers in select field of the form.
|
# Just show only related rescuers in select field of the form.
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
form = BirdAddForm(request.POST or None, request.FILES or None)
|
form = BirdAddForm(request.POST or None, request.FILES or None)
|
||||||
|
|
||||||
# circumstances = Circumstance.objects.all()
|
# circumstances = Circumstance.objects.all()
|
||||||
rescuer_id = request.session.get("rescuer_id")
|
rescuer_id = request.session.get("rescuer_id")
|
||||||
rescuer = Rescuer.objects.get(id=rescuer_id, user=request.user)
|
rescuer = Rescuer.objects.get(id=rescuer_id, user=request.user)
|
||||||
|
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
# if form.cleaned_data["find_circumstances_new"]:
|
|
||||||
# circumstance = form.cleaned_data["find_circumstances_new"]
|
|
||||||
# if Circumstance.objects.filter(description=circumstance).exists():
|
|
||||||
# print("is in circumstances")
|
|
||||||
|
|
||||||
fs = form.save(commit=False)
|
fs = form.save(commit=False)
|
||||||
fs.user = request.user
|
fs.user = request.user
|
||||||
fs.rescuer_id = rescuer_id
|
fs.rescuer_id = rescuer_id
|
||||||
|
@ -47,15 +43,6 @@ 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()
|
||||||
# Sum all costs per bird from json
|
|
||||||
for bird in birds:
|
|
||||||
costs_per_bird = float()
|
|
||||||
for item in bird.costs:
|
|
||||||
costs_per_bird += float(item["cost_entry"])
|
|
||||||
if costs_per_bird == 0.0:
|
|
||||||
costs_per_bird = ""
|
|
||||||
bird.costs = costs_per_bird
|
|
||||||
|
|
||||||
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.
|
||||||
|
@ -77,7 +64,10 @@ def bird_recover_all(request):
|
||||||
@login_required(login_url="account_login")
|
@login_required(login_url="account_login")
|
||||||
def bird_single(request, id):
|
def bird_single(request, id):
|
||||||
bird = FallenBird.objects.get(id=id)
|
bird = FallenBird.objects.get(id=id)
|
||||||
form = BirdEditForm(request.POST or None, request.FILES or None, instance=bird)
|
form = BirdEditForm(
|
||||||
|
request.POST or None,
|
||||||
|
request.FILES or None,
|
||||||
|
instance=bird)
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
fs = form.save(commit=False)
|
fs = form.save(commit=False)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,8 @@
|
||||||
Django>=4.2
|
Django>=4.2
|
||||||
|
crispy-bootstrap5>=0.6
|
||||||
django-allauth>=0.50
|
django-allauth>=0.50
|
||||||
django-bootstrap-datepicker-plus>=4.0
|
django-bootstrap-datepicker-plus>=4.0
|
||||||
django-bootstrap-modal-forms>=2
|
django-bootstrap-modal-forms>=2
|
||||||
django-crispy-forms>=1
|
django-crispy-forms>=1
|
||||||
django-jazzmin>=2.6.0
|
django-jazzmin>=2.6.0
|
||||||
crispy-bootstrap5>=0.6
|
|
||||||
names>=0.3.0
|
names>=0.3.0
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
# Generated by Django 4.2.3 on 2023-07-12 06:59
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("rescuer", "0001_initial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name="rescuer",
|
||||||
|
options={"verbose_name": "Finder", "verbose_name_plural": "Finder"},
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="rescuer",
|
||||||
|
name="city",
|
||||||
|
field=models.CharField(max_length=200, verbose_name="Stadt"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="rescuer",
|
||||||
|
name="first_name",
|
||||||
|
field=models.CharField(max_length=200, verbose_name="Vorname"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="rescuer",
|
||||||
|
name="last_name",
|
||||||
|
field=models.CharField(max_length=200, verbose_name="Nachname"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="rescuer",
|
||||||
|
name="phone",
|
||||||
|
field=models.CharField(max_length=200, verbose_name="Telefon"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="rescuer",
|
||||||
|
name="street",
|
||||||
|
field=models.CharField(max_length=200, verbose_name="Straße"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="rescuer",
|
||||||
|
name="street_number",
|
||||||
|
field=models.CharField(max_length=20, verbose_name="Nummer"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="rescuer",
|
||||||
|
name="zip_code",
|
||||||
|
field=models.CharField(max_length=200, verbose_name="PLZ"),
|
||||||
|
),
|
||||||
|
]
|
|
@ -15,7 +15,9 @@ class Rescuer(models.Model):
|
||||||
city = models.CharField(max_length=200, verbose_name=_("Stadt"))
|
city = models.CharField(max_length=200, verbose_name=_("Stadt"))
|
||||||
zip_code = models.CharField(max_length=200, verbose_name=_("PLZ"))
|
zip_code = models.CharField(max_length=200, verbose_name=_("PLZ"))
|
||||||
phone = models.CharField(max_length=200, verbose_name=_("Telefon"))
|
phone = models.CharField(max_length=200, verbose_name=_("Telefon"))
|
||||||
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
user = models.ForeignKey(
|
||||||
|
settings.AUTH_USER_MODEL,
|
||||||
|
on_delete=models.CASCADE)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Finder")
|
verbose_name = _("Finder")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue