Adding delete workflow

This commit is contained in:
Michael Bergbauer 2025-06-14 22:38:41 +02:00
parent e5395b6b19
commit 54d1cc810c
5 changed files with 24 additions and 1 deletions

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4">
<path fill-rule="evenodd" d="M5 3.25V4H2.75a.75.75 0 0 0 0 1.5h.3l.815 8.15A1.5 1.5 0 0 0 5.357 15h5.285a1.5 1.5 0 0 0 1.493-1.35l.815-8.15h.3a.75.75 0 0 0 0-1.5H11v-.75A2.25 2.25 0 0 0 8.75 1h-1.5A2.25 2.25 0 0 0 5 3.25Zm2.25-.75a.75.75 0 0 0-.75.75V4h3v-.75a.75.75 0 0 0-.75-.75h-1.5ZM6.05 6a.75.75 0 0 1 .787.713l.275 5.5a.75.75 0 0 1-1.498.075l-.275-5.5A.75.75 0 0 1 6.05 6Zm3.9 0a.75.75 0 0 1 .712.787l-.275 5.5a.75.75 0 0 1-1.498-.075l.275-5.5a.75.75 0 0 1 .786-.711Z" clip-rule="evenodd" />
</svg>

After

Width:  |  Height:  |  Size: 603 B

View File

@ -0,0 +1,12 @@
{% extends "master.html" %}
{% block content %}
<div class="members-table">
<h3>Mitglied löschen</h3>
<p>Möchtest du <strong>{{ person.nachname }} {{person.vorname}}</strong> wirklich löschen?</p>
<form method="post">
{% csrf_token %}
<button class="button" type="submit">Ja, löschen</button>
<a href="{% url 'members' %}" class="button" style="background:#444;">Abbrechen</a>
</form>
</div>
{% endblock %}

View File

@ -23,7 +23,7 @@
<tr>
<td><a href="{% url 'details' x.id %}"><img src="{% static 'icons/arrow-right.svg' %}" class="icon">{{ x.nachname }} {{ x.vorname}}</a> </td>
<td>{% if x.aktiv %}{% inline_svg 'icons/uxwing/check.svg' 'icon' %}{% endif %}</td>
<td><a href="{% url 'edit' x.id %}" title="Bearbeiten"><img src="{% static 'icons/heroicons/pencil.svg'%}" class="icon"></a></td>
<td><a href="{% url 'edit' x.id %}" title="Bearbeiten"><img src="{% static 'icons/heroicons/pencil.svg'%}" class="icon"></a> <a href="{% url 'delete' x.id %}" title="Löschen"><img src="{% static 'icons/heroicons/trash.svg'%}" class="icon"></a></td>
</tr>
{% endfor %}
</tbody>

View File

@ -6,4 +6,5 @@ urlpatterns = [
path('members/details/<int:id>', views.details, name="details"),
path('members/create/', views.create, name="create"),
path('members/edit/<int:id>', views.edit, name="edit"),
path('members/delete/<int:id>', views.delete, name="delete"),
]

View File

@ -40,3 +40,10 @@ def edit(request, id):
else:
form = PersonForm(instance=person)
return render(request, 'person_form.html', {'form': form, 'action': 'Bearbeiten'})
def delete(request, id):
person = get_object_or_404(Person, id=id)
if request.method == 'POST':
person.delete()
return redirect('members')
return render(request, 'confirm_delete.html', { 'person': person})