Zustand Volieren #16
This commit is contained in:
parent
6e642a9785
commit
49c5a0fb98
5 changed files with 106 additions and 4 deletions
27
aviary/forms.py
Normal file
27
aviary/forms.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
from datetime import date
|
||||||
|
from django import forms
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
from .models import Aviary
|
||||||
|
|
||||||
|
|
||||||
|
class DateInput(forms.DateInput):
|
||||||
|
input_type = "date"
|
||||||
|
|
||||||
|
|
||||||
|
class AviaryEditForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
widgets = {
|
||||||
|
"last_ward_round": DateInput(format="%Y-%m-%d", attrs={"value": date.today})
|
||||||
|
}
|
||||||
|
model = Aviary
|
||||||
|
fields = [
|
||||||
|
"description",
|
||||||
|
"condition",
|
||||||
|
"last_ward_round",
|
||||||
|
]
|
||||||
|
labels = {
|
||||||
|
"description": _("Bezeichnung"),
|
||||||
|
"condition": _("Zustand"),
|
||||||
|
"last_ward_round": _("Letzte Inspektion"),
|
||||||
|
}
|
26
aviary/migrations/0003_alter_aviary_condition.py
Normal file
26
aviary/migrations/0003_alter_aviary_condition.py
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# Generated by Django 4.2.2 on 2023-07-09 20:22
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("aviary", "0002_alter_aviary_condition"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="aviary",
|
||||||
|
name="condition",
|
||||||
|
field=models.CharField(
|
||||||
|
choices=[
|
||||||
|
("Offen", "Offen"),
|
||||||
|
("Geschlossen", "Geschlossen"),
|
||||||
|
("Gesperrt", "Gesperrt"),
|
||||||
|
],
|
||||||
|
max_length=256,
|
||||||
|
verbose_name="Zustand",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -3,14 +3,14 @@ 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 _
|
||||||
|
|
||||||
AVIARY_CHOICE = [("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=AVIARY_CHOICE, 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:
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
{% block content %}
|
||||||
|
<h3>Voliere <strong>{{ aviary.description }}</strong> bearbeiten </h3>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-5 mb-3">
|
||||||
|
<form method="post" enctype="multipart/form-data">
|
||||||
|
<fieldset>
|
||||||
|
{% csrf_token %}
|
||||||
|
{{form|crispy}}
|
||||||
|
<button class="btn btn-success" type="abbort">Abbrechen</button>
|
||||||
|
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-lg-5">
|
||||||
|
<h4>
|
||||||
|
Zustand
|
||||||
|
</h4>
|
||||||
|
<p>
|
||||||
|
Lorem ipsum dolor sit, amet consectetur adipisicing elit.
|
||||||
|
Reiciendis, hic enim pariatur, exercitationem, repellat quasi sit
|
||||||
|
temporibus dicta voluptate in voluptates. Alias deserunt sint
|
||||||
|
suscipit explicabo et. Perferendis, dolor praesentium.
|
||||||
|
</p>
|
||||||
|
<h4>
|
||||||
|
Letzte Inspektion
|
||||||
|
</h4>
|
||||||
|
<p>
|
||||||
|
Lorem ipsum dolor sit, amet consectetur adipisicing elit.
|
||||||
|
Reiciendis, hic enim pariatur, exercitationem, repellat quasi sit
|
||||||
|
temporibus dicta voluptate in voluptates. Alias deserunt sint
|
||||||
|
suscipit explicabo et. Perferendis, dolor praesentium.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="{% static 'js/bird.js' %}"></script
|
||||||
|
|
||||||
|
{% endblock content %}
|
|
@ -1,7 +1,8 @@
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render, redirect
|
||||||
|
|
||||||
from .models import Aviary
|
from .models import Aviary
|
||||||
|
from .forms import AviaryEditForm
|
||||||
|
|
||||||
|
|
||||||
@login_required(login_url="account_login")
|
@login_required(login_url="account_login")
|
||||||
|
@ -14,5 +15,11 @@ def aviary_all(request):
|
||||||
@login_required(login_url="account_login")
|
@login_required(login_url="account_login")
|
||||||
def aviary_single(request, id):
|
def aviary_single(request, id):
|
||||||
aviary = Aviary.objects.get(id=id)
|
aviary = Aviary.objects.get(id=id)
|
||||||
context = {"aviary": aviary}
|
form = AviaryEditForm(request.POST or None, instance=aviary)
|
||||||
|
if request.method == "POST":
|
||||||
|
if form.is_valid():
|
||||||
|
form.save()
|
||||||
|
return redirect("aviary_all")
|
||||||
|
|
||||||
|
context = {"aviary": aviary, "form": form}
|
||||||
return render(request, "aviary/aviary_single.html", context)
|
return render(request, "aviary/aviary_single.html", context)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue