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>
|
||||
<nav>
|
||||
<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 %}
|
||||
<li>{{ user.username }}</li>
|
||||
<li>
|
||||
|
|
|
@ -16,13 +16,28 @@
|
|||
<h2>
|
||||
<i class="ri-play-circle-fill"></i> Parties
|
||||
</h2>
|
||||
<ul>
|
||||
<table class="striped">
|
||||
<thead>
|
||||
<th>Date</th>
|
||||
<th>Joueurs</th>
|
||||
<th>
|
||||
<i class="ri-delete-bin-fill"></i>
|
||||
</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for game in group.musikgame_set.all %}
|
||||
<li>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url "game_detail" pk=game.pk %}">{{ game.date }}</a>
|
||||
</li>
|
||||
</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 %}
|
||||
</ul>
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
<h2>
|
||||
<i class="ri-group-2-fill"></i> Membres
|
||||
|
|
|
@ -26,6 +26,11 @@ urlpatterns = [
|
|||
views.GroupRemoveMusicView.as_view(),
|
||||
name="group_remove_music",
|
||||
),
|
||||
path(
|
||||
"group/remove_game/<int:pk>/",
|
||||
views.GroupRemoveGameView.as_view(),
|
||||
name="group_remove_game",
|
||||
),
|
||||
path(
|
||||
"group/<int:pk>/start_game/", views.GameCreateView.as_view(), name="start_game"
|
||||
),
|
||||
|
|
|
@ -96,6 +96,19 @@ class GroupRemoveMusicView(OwnerFilterMixin, SingleObjectMixin, View):
|
|||
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):
|
||||
model = models.MusikGame
|
||||
form_class = forms.MusikGameForm
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue