Add group detail link and implement game removal functionality in views
This commit is contained in:
parent
122ae40570
commit
dfe312d47d
4 changed files with 47 additions and 7 deletions
|
@ -31,6 +31,13 @@
|
||||||
</a>
|
</a>
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
|
{% if object.group %}
|
||||||
|
<li>
|
||||||
|
<a href="{% url 'group_detail' pk=object.group.pk %}">
|
||||||
|
<i class="ri-group-2-fill"></i> {{ object.group.name }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
<li>{{ user.username }}</li>
|
<li>{{ user.username }}</li>
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -16,13 +16,28 @@
|
||||||
<h2>
|
<h2>
|
||||||
<i class="ri-play-circle-fill"></i> Parties
|
<i class="ri-play-circle-fill"></i> Parties
|
||||||
</h2>
|
</h2>
|
||||||
<ul>
|
<table class="striped">
|
||||||
{% for game in group.musikgame_set.all %}
|
<thead>
|
||||||
<li>
|
<th>Date</th>
|
||||||
<a href="{% url "game_detail" pk=game.pk %}">{{ game.date }}</a>
|
<th>Joueurs</th>
|
||||||
</li>
|
<th>
|
||||||
{% endfor %}
|
<i class="ri-delete-bin-fill"></i>
|
||||||
</ul>
|
</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for game in group.musikgame_set.all %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<a href="{% url "game_detail" pk=game.pk %}">{{ game.date }}</a>
|
||||||
|
</td>
|
||||||
|
<td>{{ game.players.all|join:", " }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{% url "group_remove_game" pk=game.pk %}"><i class="ri-close-fill" alt="Supprimer"></i></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<h2>
|
<h2>
|
||||||
<i class="ri-group-2-fill"></i> Membres
|
<i class="ri-group-2-fill"></i> Membres
|
||||||
|
|
|
@ -26,6 +26,11 @@ urlpatterns = [
|
||||||
views.GroupRemoveMusicView.as_view(),
|
views.GroupRemoveMusicView.as_view(),
|
||||||
name="group_remove_music",
|
name="group_remove_music",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"group/remove_game/<int:pk>/",
|
||||||
|
views.GroupRemoveGameView.as_view(),
|
||||||
|
name="group_remove_game",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"group/<int:pk>/start_game/", views.GameCreateView.as_view(), name="start_game"
|
"group/<int:pk>/start_game/", views.GameCreateView.as_view(), name="start_game"
|
||||||
),
|
),
|
||||||
|
|
|
@ -96,6 +96,19 @@ class GroupRemoveMusicView(OwnerFilterMixin, SingleObjectMixin, View):
|
||||||
return redirect(group)
|
return redirect(group)
|
||||||
|
|
||||||
|
|
||||||
|
class GroupRemoveGameView(SingleObjectMixin, View):
|
||||||
|
model = models.MusikGame
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
return super().get_queryset().filter(group__owner=self.request.user)
|
||||||
|
|
||||||
|
def get(self, request, pk):
|
||||||
|
game = self.get_object()
|
||||||
|
group = game.group
|
||||||
|
game.delete()
|
||||||
|
return redirect(group)
|
||||||
|
|
||||||
|
|
||||||
class GameCreateView(LoginRequiredMixin, CreateView):
|
class GameCreateView(LoginRequiredMixin, CreateView):
|
||||||
model = models.MusikGame
|
model = models.MusikGame
|
||||||
form_class = forms.MusikGameForm
|
form_class = forms.MusikGameForm
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue