diff --git a/src/party/templates/party/parties_list.html b/src/party/templates/party/parties_list.html
index 6a47463..e542be9 100644
--- a/src/party/templates/party/parties_list.html
+++ b/src/party/templates/party/parties_list.html
@@ -9,7 +9,7 @@
Nouveau groupe
+
{% for party in managed_parties %}
diff --git a/src/party/templates/party/party_details.html b/src/party/templates/party/party_details.html
index 7a02a1e..137a610 100644
--- a/src/party/templates/party/party_details.html
+++ b/src/party/templates/party/party_details.html
@@ -14,8 +14,7 @@
{{ character.name }}
{% if character.player == user %}
- (
- Quitter)
+ (
Quitter)
{% endif %}
{% empty %}
diff --git a/src/party/templates/party/party_create.html b/src/party/templates/party/party_form.html
similarity index 50%
rename from src/party/templates/party/party_create.html
rename to src/party/templates/party/party_form.html
index 280ff4a..bf0e5d4 100644
--- a/src/party/templates/party/party_create.html
+++ b/src/party/templates/party/party_form.html
@@ -2,13 +2,13 @@
{% load django_bootstrap5 %}
{% load character_extras %}
-{% block title %}Créer groupe{% endblock %}
+{% block title %}Gérer un groupe{% endblock %}
{% block content %}
-
Créer un groupe
-
{% endblock %}
diff --git a/src/party/templates/party/snippets/party_card.html b/src/party/templates/party/snippets/party_card.html
deleted file mode 100644
index 5db2b25..0000000
--- a/src/party/templates/party/snippets/party_card.html
+++ /dev/null
@@ -1,12 +0,0 @@
-
diff --git a/src/party/urls.py b/src/party/urls.py
index a8e46aa..0247677 100644
--- a/src/party/urls.py
+++ b/src/party/urls.py
@@ -7,6 +7,7 @@ urlpatterns = [
path("", views.parties_list, name="list"),
path("create/", views.party_create, name="create"),
path("
/", views.party_details, name="details"),
+ path("/change/", views.party_change, name="change"),
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 f36c462..5f05e2e 100644
--- a/src/party/views.py
+++ b/src/party/views.py
@@ -11,7 +11,7 @@ from party.models import Party
def parties_list(request):
context = {
"managed_parties": Party.objects.managed_by(request.user),
- "played_parties": Party.objects.played_by(request.user),
+ "played_parties": Party.objects.played_by(request.user).distinct(),
}
return render(request, "party/parties_list.html", context)
@@ -29,7 +29,7 @@ def party_create(request):
form.save_m2m()
return redirect("party:list")
context = {"form": form}
- return render(request, "party/party_create.html", context)
+ return render(request, "party/party_form.html", context)
@login_required
@@ -51,6 +51,22 @@ def party_delete(request, pk):
return render(request, "party/party_delete.html", context)
+@login_required
+def party_change(request, pk):
+ party = get_object_or_404(Party.objects.managed_by(request.user), pk=pk)
+ context = {"party": party}
+ if request.method == "GET":
+ form = PartyForm(instance=party)
+ else:
+ form = PartyForm(request.POST or None, instance=party)
+ if form.is_valid():
+ form.save()
+ messages.success(request, "Groupe modifié.")
+ return redirect("party:list")
+ context["form"] = form
+ return render(request, "party/party_form.html", context)
+
+
@login_required
def party_leave(request, pk, character_pk):
party = get_object_or_404(Party.objects.managed_by(request.user), pk=pk)