fbf updated

This commit is contained in:
gw3000 2023-06-20 21:30:10 +02:00
parent 69dd0da590
commit 359e71111a
5 changed files with 27 additions and 36 deletions

View file

@ -1,5 +1,3 @@
from datetime import date
from django import forms
from django.utils.translation import gettext_lazy as _
@ -10,7 +8,16 @@ class DateInput(forms.DateInput):
input_type = "date"
class BirdForm(forms.ModelForm):
class BirdAddForm(forms.ModelForm):
class Meta:
widgets = {"date_found": DateInput()}
model = FallenBird
fields = ["bird", "date_found", "place", ]
labels = {"bird": _("Vogel"), "date_found": _(
"Datum des Fundes"), "place": _("Fundort")}
class BirdEditForm(forms.ModelForm):
class Meta:
widgets = {"date_found": DateInput()}
model = FallenBird
@ -18,11 +25,11 @@ class BirdForm(forms.ModelForm):
"bird",
"date_found",
"place",
# "rescuer",
"rescuer",
]
labels = {
"bird": _("Vogel"),
"date_found": _("Datum des Fundes"),
"place": _("Fundort"),
# "rescuer": _("Finder"),
"rescuer": _("Retter"),
}

View file

@ -1,6 +1,8 @@
from django.db import models
from django.conf import settings
from uuid import uuid4
from django.conf import settings
from django.db import models
from rescuer.models import Rescuer

View file

@ -4,34 +4,15 @@
{% block content %}
<h3>Patient anlegen</h3>
<p>(Retter: {{rescuer.first_name}} {{rescuer.last_name}})</p>
<div class="row">
<div class="col-lg-8 mb-3">
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form|crispy }}
<button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#exampleModal">Abbruch</button>
<a href="{% url 'bird_all' %}" class="btn btn-danger">Abbruch</a>
<button class="btn btn-primary" type="submit">Patient anlegen</button>
<div class="mt-3"><small>* Pflichtfeld</small></div>
{% comment %} Modal {% endcomment %}
<div class="modal fade" id="exampleModal" tabindex="-1" data-bs-backdrop="static" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-danger">
<h5 class="modal-title text-white" id="exampleModalLabel">Achtung unvollständiger Vertrag!</h5>
</div>
<div class="modal-body">
Der Versicherungsnehmer wird bei Abbruch gelöscht, da ihm
bisher kein Vertrag zugeordnet wurde.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Schließen</button>
{% comment %} <a href="{% url 'rescuer_abbort' %}" class="btn btn-danger">Abbruch und Löschen</a> {% endcomment %}
</div>
</div>
</div>
</div>
</fieldset>
</form>
</div>
@ -61,6 +42,4 @@
</p>
</div>
</div>
<script src="{% static 'js/contract.js' %}"></script>
{% endblock content %}
{% endblock content %}

View file

@ -15,4 +15,4 @@
</fieldset>
</form>
</div>
{% endblock content %}
{% endblock content %}

View file

@ -1,7 +1,7 @@
from django.contrib.auth.decorators import login_required
from django.shortcuts import HttpResponse, redirect, render
from .forms import BirdForm
from .forms import BirdAddForm, BirdEditForm
from .models import FallenBird
from rescuer.models import Rescuer
@ -9,13 +9,13 @@ from rescuer.models import Rescuer
@login_required(login_url="account_login")
def bird_create(request):
# Rescuer for modal usage
form = BirdForm()
form = BirdAddForm()
rescuer_id = request.session.get("rescuer_id")
rescuer = Rescuer.objects.get(id=rescuer_id, user=request.user)
# just show only related rescuers in select field of the form
if request.method == "POST":
form = BirdForm(request.POST or None, request.FILES or None)
form = BirdAddForm(request.POST or None, request.FILES or None)
rescuer_id = request.session.get('rescuer_id')
rescuer = Rescuer.objects.get(id=rescuer_id, user=request.user)
@ -54,7 +54,10 @@ def bird_recover_all(request):
@login_required(login_url="account_login")
def bird_single(request, id):
bird = FallenBird.objects.get(id=id)
form = BirdForm(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 form.is_valid():
form.save()