edit and del rescuer forms and urls
This commit is contained in:
parent
e48c309f3a
commit
63af20ceec
7 changed files with 137 additions and 18 deletions
|
@ -2,7 +2,7 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% block header %}
|
{% block header %}
|
||||||
<!-- Datatable CSS -->
|
<!-- Datatable CSS -->
|
||||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/dataTables.bootstrap5.min.css"/>
|
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.4/css/dataTables.bootstrap5.min.css"/>
|
||||||
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.2.9/css/responsive.bootstrap5.min.css">
|
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.2.9/css/responsive.bootstrap5.min.css">
|
||||||
|
|
||||||
<!-- jQuery -->
|
<!-- jQuery -->
|
||||||
|
@ -20,6 +20,8 @@
|
||||||
language: {
|
language: {
|
||||||
url: 'https://cdn.datatables.net/plug-ins/1.11.3/i18n/de_de.json',
|
url: 'https://cdn.datatables.net/plug-ins/1.11.3/i18n/de_de.json',
|
||||||
},
|
},
|
||||||
|
paging: false,
|
||||||
|
info: false,
|
||||||
responsive: true,
|
responsive: true,
|
||||||
columnDefs: [
|
columnDefs: [
|
||||||
{ responsivePriority: 1, targets: 0 },
|
{ responsivePriority: 1, targets: 0 },
|
||||||
|
@ -38,7 +40,7 @@
|
||||||
<a href="{% url 'rescuer_create' %}" class="btn btn-primary">Einen neuen Retter anlegen</a>
|
<a href="{% url 'rescuer_create' %}" class="btn btn-primary">Einen neuen Retter anlegen</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<table class="table table-striped table-hover" id="t__rescuer_all">
|
<table class="table table-striped table-hover display responsive nowrap" width="100%" id="t__rescuer_all">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
|
|
28
rescuer/templates/rescuer/rescuer_delete.html
Normal file
28
rescuer/templates/rescuer/rescuer_delete.html
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h1>Retter löschen</h1>
|
||||||
|
<div class="row mt-3">
|
||||||
|
<div class="col-lg-7">
|
||||||
|
<form method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="alert alert-dismissible alert-danger">
|
||||||
|
<h4 class="alert-heading">Warnung!</h4>
|
||||||
|
<p class="mb-0">Wollen Sie den Retter <strong>{{rescuer.first_name}} {{rescuer.last_name}}</strong> löschen?</p>
|
||||||
|
</div>
|
||||||
|
</p>
|
||||||
|
<a href="{% url 'rescuer_all'%}" class="btn btn-secondary">Abbruch</a>
|
||||||
|
<button class="btn btn-danger" type="submit">Löschen</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-5">
|
||||||
|
<h5>Retter löschen</h5>
|
||||||
|
<p>
|
||||||
|
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates
|
||||||
|
ducimus inventore quia, quae quam reiciendis eligendi explicabo non
|
||||||
|
deleniti aliquid, modi dignissimos ullam ipsa incidunt vel similique fuga?
|
||||||
|
Suscipit, dolores?
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
29
rescuer/templates/rescuer/rescuer_edit.html
Normal file
29
rescuer/templates/rescuer/rescuer_edit.html
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load crispy_forms_tags %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-7">
|
||||||
|
<h3>Adressänderung des Retters</h3>
|
||||||
|
<form method="post" class="form-horizontal">
|
||||||
|
<fieldset>
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">{{ form.gender|as_crispy_field }}</div>
|
||||||
|
<div class="col-6">{{ form.first_name|as_crispy_field }}</div>
|
||||||
|
<div class="col-6">{{ form.last_name|as_crispy_field }}</div>
|
||||||
|
<div class="col-8">{{ form.email|as_crispy_field }}</div>
|
||||||
|
<div class="col-4">{{ form.date_of_birth|as_crispy_field }}</div>
|
||||||
|
<div class="col-8">{{ form.street|as_crispy_field }}</div>
|
||||||
|
<div class="col-4">{{ form.street_number|as_crispy_field }}</div>
|
||||||
|
<div class="col-8">{{ form.city|as_crispy_field }}</div>
|
||||||
|
<div class="col-4">{{ form.zip_code|as_crispy_field }}</div>
|
||||||
|
<div class="col-12">{{ form.state|as_crispy_field }}</div>
|
||||||
|
</div>
|
||||||
|
<a href="{% url 'rescuer_all' %}" class="btn btn-secondary">Abbruch</a>
|
||||||
|
<button class="btn btn-primary" type="submit">Speichern</button>
|
||||||
|
</fieldset>
|
||||||
|
</form
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock content %}
|
|
@ -1,10 +1,42 @@
|
||||||
{% extends "base.html" %}
|
{% extends 'base.html' %}
|
||||||
{% load static %}
|
|
||||||
{% load crispy_forms_tags %}
|
|
||||||
{% block content %}
|
|
||||||
<h3>{{ rescuer.first_name }} {{ rescuer.last_name }}</h3>
|
|
||||||
|
|
||||||
<p> form </p>
|
{% block content %}
|
||||||
<p>änder und löschen</p>
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<h3>Stammdaten des Retters</h3>
|
||||||
|
<div class="card bg-light mb-3" style="max-width: 30rem;">
|
||||||
|
<div class="card-header">Adressdaten</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<h4 class="card-title">{{rescuer.first_name}} {{rescuer.last_name}}</h4>
|
||||||
|
<p class="card-text">
|
||||||
|
{{rescuer.city}} {{rescuer.street}}<br>
|
||||||
|
{{rescuer.zip_code}}<br>
|
||||||
|
{{rescuer.state}}<br>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a href="{% url 'rescuer_all' %}" class="btn btn-success">zurück zur Übersicht</a>
|
||||||
|
<a href="{% url 'rescuer_delete' rescuer.id %}" class="btn btn-danger">Löschen</a>
|
||||||
|
<a href="{% url 'rescuer_edit' rescuer.id %}" class="btn btn-primary">Bearbeiten</a>
|
||||||
|
</div>
|
||||||
|
<!--
|
||||||
|
<div class="col-lg-7">
|
||||||
|
<h6>eins</h6>
|
||||||
|
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officia tempore voluptatibus voluptatum possimus in iusto exercitationem perspiciatis eaque harum, nihil, praesentium debitis nisi unde eligendi, qui sapiente odit expedita aut.</p>
|
||||||
|
|
||||||
|
<h6>zwei</h6>
|
||||||
|
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officia tempore voluptatibus voluptatum possimus in iusto exercitationem perspiciatis eaque harum, nihil, praesentium debitis nisi unde eligendi, qui sapiente odit expedita aut.</p>
|
||||||
|
|
||||||
|
<h6>drei</h6>
|
||||||
|
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Officia tempore voluptatibus voluptatum possimus in iusto exercitationem perspiciatis eaque harum, nihil, praesentium debitis nisi unde eligendi, qui sapiente odit expedita aut.</p>
|
||||||
|
</div>
|
||||||
|
-->
|
||||||
|
<div class="col-lg-6">
|
||||||
|
<h5>zugehörige Patienten</h5>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
{% endblock content %}
|
{% endblock content %}
|
|
@ -1,9 +1,17 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from .views import rescuer_all, rescuer_create, rescuer_single
|
from .views import (
|
||||||
|
rescuer_all,
|
||||||
|
rescuer_create,
|
||||||
|
rescuer_single,
|
||||||
|
rescuer_delete,
|
||||||
|
rescuer_edit,
|
||||||
|
)
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("all", rescuer_all, name="rescuer_all"),
|
path("all", rescuer_all, name="rescuer_all"),
|
||||||
path("create", rescuer_create, name="rescuer_create"),
|
path("create", rescuer_create, name="rescuer_create"),
|
||||||
|
path("edit/<id>", rescuer_edit, name="rescuer_edit"),
|
||||||
|
path("delete/<id>", rescuer_delete, name="rescuer_delete"),
|
||||||
path("<id>", rescuer_single, name="rescuer_single"),
|
path("<id>", rescuer_single, name="rescuer_single"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -22,7 +22,7 @@ def rescuer_single(request, id):
|
||||||
@login_required(login_url="account_login")
|
@login_required(login_url="account_login")
|
||||||
def rescuer_create(request):
|
def rescuer_create(request):
|
||||||
form = RescuerForm()
|
form = RescuerForm()
|
||||||
if request.method == 'POST':
|
if request.method == "POST":
|
||||||
form = RescuerForm(request.POST or None)
|
form = RescuerForm(request.POST or None)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
fs = form.save(commit=False)
|
fs = form.save(commit=False)
|
||||||
|
@ -32,10 +32,30 @@ def rescuer_create(request):
|
||||||
# set customer id in session cookie
|
# set customer id in session cookie
|
||||||
# (uuid has to be cast to a string)
|
# (uuid has to be cast to a string)
|
||||||
rescuer_id = str(fs.pk)
|
rescuer_id = str(fs.pk)
|
||||||
request.session['rescuer_id'] = rescuer_id
|
request.session["rescuer_id"] = rescuer_id
|
||||||
|
|
||||||
return redirect('bird_create')
|
return redirect("bird_create")
|
||||||
context = {
|
context = {"form": form}
|
||||||
'form': form
|
return render(request, "rescuer/rescuer_create.html", context)
|
||||||
}
|
|
||||||
return render(request, 'rescuer/rescuer_create.html', context)
|
|
||||||
|
@login_required(login_url="account_login")
|
||||||
|
def rescuer_delete(request, id):
|
||||||
|
rescuer = Rescuer.objects.get(id=id)
|
||||||
|
if request.method == "POST":
|
||||||
|
rescuer.delete()
|
||||||
|
return redirect("rescuer_all")
|
||||||
|
context = {"rescuer": rescuer}
|
||||||
|
return render(request, "rescuer/rescuer_delete.html", context)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required(login_url="account_login")
|
||||||
|
def rescuer_edit(request, id):
|
||||||
|
rescuer = Rescuer.objects.get(id=id)
|
||||||
|
form = RescuerForm(request.POST or None, instance=rescuer)
|
||||||
|
if request.method == "POST":
|
||||||
|
if form.is_valid():
|
||||||
|
form.save()
|
||||||
|
return redirect("rescuer_all")
|
||||||
|
context = {"form": form}
|
||||||
|
return render(request, "rescuer/rescuer_edit.html", context)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<footer class="footer d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top">
|
<footer class="footer d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top">
|
||||||
<p class="col-md-4 mb-0 text-muted">© 2023 bird</p>
|
<p class="col-md-4 mb-0 text-muted">© 2023 fbf</p>
|
||||||
<ul class="nav col-md-5 justify-content-end">
|
<ul class="nav col-md-5 justify-content-end">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link px-2 text-muted" href="{% url 'rescuer_all' %}">Home</a>
|
<a class="nav-link px-2 text-muted" href="{% url 'rescuer_all' %}">Home</a>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue