diff --git a/src/common/templates/common/base.html b/src/common/templates/common/base.html index 372ef6c..fab751a 100644 --- a/src/common/templates/common/base.html +++ b/src/common/templates/common/base.html @@ -1,4 +1,4 @@ -{% load static django_htmx %} +{% load static django_htmx django_bootstrap5 %} @@ -22,6 +22,7 @@ {% include "common/navbar.html" %}
+ {% bootstrap_messages %} {% block content %} {% endblock %}
diff --git a/src/party/templates/party/parties_list.html b/src/party/templates/party/parties_list.html index d19471b..6a47463 100644 --- a/src/party/templates/party/parties_list.html +++ b/src/party/templates/party/parties_list.html @@ -11,7 +11,21 @@

Groupes que vous gérez

{% for party in managed_parties %} - {% include "party/snippets/party_card.html" %} +
+
+
+
+ {{ party.name }} +
+ + Accéder + + + Supprimer + +
+
+
{% empty %}
Aucun
{% endfor %} @@ -19,7 +33,19 @@

Groupes dont vous êtes membre

{% for party in played_parties %} - {% include "party/snippets/party_card.html" %} + +
+
+
+
+ {{ party.name }} +
+ + Accéder + +
+
+
{% empty %}
Aucun
{% endfor %} diff --git a/src/party/templates/party/party_delete.html b/src/party/templates/party/party_delete.html new file mode 100644 index 0000000..0ca7f63 --- /dev/null +++ b/src/party/templates/party/party_delete.html @@ -0,0 +1,18 @@ +{% extends "common/base.html" %} +{% load character_extras %} + +{% block title %}Suppression groupe {{ party.name }}{% endblock %} + +{% block content %} +

Suppression groupe {{ party.name }}

+
+ {% csrf_token %} +

+ Êtes-vous certain de vouloir supprimer le groupe {{ party.name }} ?
+ Cette action est irréversible. +

+ +
+{% endblock %} diff --git a/src/party/urls.py b/src/party/urls.py index ea0f735..dfc74e8 100644 --- a/src/party/urls.py +++ b/src/party/urls.py @@ -7,4 +7,5 @@ urlpatterns = [ path("", views.parties_list, name="list"), path("create/", views.party_create, name="create"), path("/", views.party_details, name="details"), + path("/delete/", views.party_delete, name="delete"), ] diff --git a/src/party/views.py b/src/party/views.py index 89dbd63..49fff6f 100644 --- a/src/party/views.py +++ b/src/party/views.py @@ -1,3 +1,4 @@ +from django.contrib import messages from django.contrib.auth.decorators import login_required from django.shortcuts import get_object_or_404, redirect, render @@ -35,3 +36,15 @@ def party_details(request, pk): party = get_object_or_404(Party.objects.related_to(request.user), pk=pk) context = {"party": party} return render(request, "party/party_details.html", context) + + +@login_required +def party_delete(request, pk): + party = get_object_or_404(Party.objects.managed_by(request.user), pk=pk) + context = {"party": party} + if request.method == "POST": + name = party.name + party.delete() + messages.success(request, f"Le groupe {name} a été supprimé.") + return redirect("party:list") + return render(request, "party/party_delete.html", context)