fbf updated
This commit is contained in:
parent
69dd0da590
commit
359e71111a
5 changed files with 27 additions and 36 deletions
17
fbf/forms.py
17
fbf/forms.py
|
@ -1,5 +1,3 @@
|
||||||
from datetime import date
|
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
@ -10,7 +8,16 @@ class DateInput(forms.DateInput):
|
||||||
input_type = "date"
|
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:
|
class Meta:
|
||||||
widgets = {"date_found": DateInput()}
|
widgets = {"date_found": DateInput()}
|
||||||
model = FallenBird
|
model = FallenBird
|
||||||
|
@ -18,11 +25,11 @@ class BirdForm(forms.ModelForm):
|
||||||
"bird",
|
"bird",
|
||||||
"date_found",
|
"date_found",
|
||||||
"place",
|
"place",
|
||||||
# "rescuer",
|
"rescuer",
|
||||||
]
|
]
|
||||||
labels = {
|
labels = {
|
||||||
"bird": _("Vogel"),
|
"bird": _("Vogel"),
|
||||||
"date_found": _("Datum des Fundes"),
|
"date_found": _("Datum des Fundes"),
|
||||||
"place": _("Fundort"),
|
"place": _("Fundort"),
|
||||||
# "rescuer": _("Finder"),
|
"rescuer": _("Retter"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
from django.db import models
|
|
||||||
from django.conf import settings
|
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
from rescuer.models import Rescuer
|
from rescuer.models import Rescuer
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,34 +4,15 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h3>Patient anlegen</h3>
|
<h3>Patient anlegen</h3>
|
||||||
|
<p>(Retter: {{rescuer.first_name}} {{rescuer.last_name}})</p>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-8 mb-3">
|
<div class="col-lg-8 mb-3">
|
||||||
<form method="post" enctype="multipart/form-data">
|
<form method="post" enctype="multipart/form-data">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form|crispy }}
|
{{ 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>
|
<button class="btn btn-primary" type="submit">Patient anlegen</button>
|
||||||
<div class="mt-3"><small>* Pflichtfeld</small></div>
|
<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>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -61,6 +42,4 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endblock content %}
|
||||||
<script src="{% static 'js/contract.js' %}"></script>
|
|
||||||
{% endblock content %}
|
|
||||||
|
|
|
@ -15,4 +15,4 @@
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
11
fbf/views.py
11
fbf/views.py
|
@ -1,7 +1,7 @@
|
||||||
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 .forms import BirdForm
|
from .forms import BirdAddForm, BirdEditForm
|
||||||
from .models import FallenBird
|
from .models import FallenBird
|
||||||
from rescuer.models import Rescuer
|
from rescuer.models import Rescuer
|
||||||
|
|
||||||
|
@ -9,13 +9,13 @@ from rescuer.models import Rescuer
|
||||||
@login_required(login_url="account_login")
|
@login_required(login_url="account_login")
|
||||||
def bird_create(request):
|
def bird_create(request):
|
||||||
# Rescuer for modal usage
|
# Rescuer for modal usage
|
||||||
form = BirdForm()
|
form = BirdAddForm()
|
||||||
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)
|
||||||
|
|
||||||
# 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 = 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_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)
|
||||||
|
|
||||||
|
@ -54,7 +54,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 = 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 request.method == "POST":
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
form.save()
|
form.save()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue