accounts, add modal and many more
This commit is contained in:
parent
7a4cb2ff67
commit
81dba3e6b3
53 changed files with 829 additions and 19 deletions
6
fbf/README.md
Normal file
6
fbf/README.md
Normal file
|
@ -0,0 +1,6 @@
|
|||
# FBF App
|
||||
|
||||
- create
|
||||
- retrieve (all, single)
|
||||
- update (all, single)
|
||||
- delete (all, single)
|
|
@ -1,7 +1,15 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% block content %}
|
||||
<h3>Übersicht aller Vögel in Behandlung</h3>
|
||||
<h3>Übersicht aller Patienten in Behandlung</h3>
|
||||
<p>
|
||||
Die Übersicht aller in Behandlung befindlichen Vögel umfasst <strong>nicht</strong> die entlassenen Patienten.
|
||||
</p>
|
||||
<p>
|
||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addPatientModal">einen Patienten
|
||||
anlegen
|
||||
</button>
|
||||
</p>
|
||||
<table class="table table-striped table-hover" id="t__bids_all">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -26,4 +34,40 @@
|
|||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="modal fade" id="addPatientModal" tabindex="-1" data-bs-backdrop="static"
|
||||
aria-labelledby="addRescuerModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-primary">
|
||||
<h5 class="modal-title text-white" id="addRescuerModalLabel">(neuen) Retter zuweisen</h5>
|
||||
</div>
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<div class="modal-body">
|
||||
<label for="rescuer" class="form-label mt-3">Wählen Sie einen <strong>bereits angelegten</strong>
|
||||
Retter aus oder legen Sie einen <strong>neuen</strong> Retter an:</label>
|
||||
<select id="rescuer" class="form-select" name="rescuer_id">
|
||||
{% for rescuer in rescuer_modal %}
|
||||
<option value={{rescuer.id}}>
|
||||
{{rescuer.first_name}} {{rescuer.last_name}},
|
||||
{{rescuer.street}} {{rescuer.street_number}},
|
||||
{{rescuer.city}}
|
||||
</option>
|
||||
{% endfor %}
|
||||
<option value="new_rescuer"><strong>neuen
|
||||
Retter anlegen</strong></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">Abbruch</button>
|
||||
|
||||
<button class="btn btn-primary" type="submit">Übernehmen und
|
||||
weiter</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% endblock content %}
|
39
fbf/templates/fbf/bird_create.html
Normal file
39
fbf/templates/fbf/bird_create.html
Normal file
|
@ -0,0 +1,39 @@
|
|||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load crispy_forms_tags %}
|
||||
{% block content %}
|
||||
<h3>Patient anlegen</h3>
|
||||
<p>Legen Sie einen neuen Patienten an. Die mit <strong>*</strong> gekennzeichneten Felder sind Pflichfelder.</p>
|
||||
<div class="row">
|
||||
<div class="col-lg-6 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-danger" type="reset">Felder Rücksetzen</button>
|
||||
<button class="btn btn-primary" type="submit">Speichern und zur Übersicht</button>
|
||||
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock content %}
|
45
fbf/views.py
45
fbf/views.py
|
@ -1,22 +1,57 @@
|
|||
from django.shortcuts import render, HttpResponse, redirect
|
||||
from .models import FallenBird
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import HttpResponse, redirect, render
|
||||
|
||||
from rescuer.models import Rescuer
|
||||
|
||||
from .forms import BirdForm
|
||||
from .models import FallenBird
|
||||
|
||||
|
||||
@login_required(login_url="account_login")
|
||||
def bird_create(request):
|
||||
return HttpResponse("Create a bird")
|
||||
# Rescuer for modal usage
|
||||
# rescuer_modal = Rescuer.objects.all().filter(user=request.user)
|
||||
form = BirdForm()
|
||||
rescuer_id = request.session.get("rescuer_id")
|
||||
# rescuer = Rescuer.objects.get(id=rescuer_id, user=request.user)
|
||||
rescuer = Rescuer.objects.get(id=rescuer_id)
|
||||
|
||||
# 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)
|
||||
if form.is_valid():
|
||||
fs = form.save(commit=False)
|
||||
# fs.user = request.user
|
||||
fs.rescuer_id = rescuer_id
|
||||
fs.save()
|
||||
request.session["rescuer_id"] = None
|
||||
return redirect("bird_all")
|
||||
context = {"form": form, "rescuer": rescuer}
|
||||
return render(request, "fbf/bird_create.html")
|
||||
|
||||
|
||||
@login_required(login_url="account_login")
|
||||
def bird_all(request):
|
||||
birds = FallenBird.objects.all()
|
||||
context = {"birds": birds}
|
||||
rescuer_modal = Rescuer.objects.all()
|
||||
context = {"birds": birds, "rescuer_modal": rescuer_modal}
|
||||
# Post came from the modal form
|
||||
if request.method == "POST":
|
||||
rescuer_id = request._post["rescuer_id"]
|
||||
if rescuer_id != "new_rescuer":
|
||||
request.session["rescuer_id"] = rescuer_id
|
||||
return redirect("bird_create")
|
||||
else:
|
||||
return redirect("rescuer_create")
|
||||
return render(request, "fbf/bird_all.html", context)
|
||||
|
||||
|
||||
@login_required(login_url="account_login")
|
||||
def bird_recover_all(request):
|
||||
return HttpResponse("Show all recovered Birds")
|
||||
|
||||
|
||||
@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)
|
||||
|
@ -28,6 +63,7 @@ def bird_single(request, id):
|
|||
return render(request, "fbf/bird_single.html", context)
|
||||
|
||||
|
||||
@login_required(login_url="account_login")
|
||||
def bird_delete(request, id):
|
||||
bird = FallenBird.objects.get(id=id)
|
||||
if request.method == "POST":
|
||||
|
@ -37,5 +73,6 @@ def bird_delete(request, id):
|
|||
return render(request, "fbf/bird_delete.html", context)
|
||||
|
||||
|
||||
@login_required(login_url="account_login")
|
||||
def bird_recover(request, id):
|
||||
return HttpResponse(f"Show recover with ID {id}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue