diff --git a/src/party/templates/party/party_details.html b/src/party/templates/party/party_details.html
index 4dedd0e..7a02a1e 100644
--- a/src/party/templates/party/party_details.html
+++ b/src/party/templates/party/party_details.html
@@ -6,13 +6,17 @@
{% block content %}
{{ party.name }}
+ MJ : {{ party.game_master.get_full_name|default:party.game_master.username }}
Personnages :
{% for character in party.characters.all %}
-
- {{ character.name }}
-
+ {{ character.name }}
+ {% if character.player == user %}
+ (
+ Quitter)
+ {% endif %}
{% empty %}
- Aucun...
diff --git a/src/party/templates/party/party_leave.html b/src/party/templates/party/party_leave.html
new file mode 100644
index 0000000..b773346
--- /dev/null
+++ b/src/party/templates/party/party_leave.html
@@ -0,0 +1,17 @@
+{% extends "common/base.html" %}
+{% load character_extras %}
+
+{% block title %}Quitter le groupe {{ party.name }}{% endblock %}
+
+{% block content %}
+ Quitter le groupe {{ party.name }}
+
+{% endblock %}
diff --git a/src/party/urls.py b/src/party/urls.py
index dfc74e8..a8e46aa 100644
--- a/src/party/urls.py
+++ b/src/party/urls.py
@@ -8,4 +8,5 @@ urlpatterns = [
path("create/", views.party_create, name="create"),
path("/", views.party_details, name="details"),
path("/delete/", views.party_delete, name="delete"),
+ path("/leave//", views.party_leave, name="leave"),
]
diff --git a/src/party/views.py b/src/party/views.py
index 49fff6f..f36c462 100644
--- a/src/party/views.py
+++ b/src/party/views.py
@@ -2,6 +2,7 @@ from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, redirect, render
+from character.models import Character
from party.forms import PartyForm
from party.models import Party
@@ -48,3 +49,17 @@ def party_delete(request, pk):
messages.success(request, f"Le groupe {name} a été supprimé.")
return redirect("party:list")
return render(request, "party/party_delete.html", context)
+
+
+@login_required
+def party_leave(request, pk, character_pk):
+ party = get_object_or_404(Party.objects.managed_by(request.user), pk=pk)
+ character = get_object_or_404(
+ Character.objects.owned_by(request.user), pk=character_pk
+ )
+ context = {"party": party, "character": character}
+ if request.method == "POST":
+ character.parties.remove(party)
+ messages.success(request, f"{character} a quitté le groupe {party}.")
+ return redirect("party:list")
+ return render(request, "party/party_leave.html", context)