Add functionality to clear blacklisted music videos in GroupClearBlacklistView and update group detail template

This commit is contained in:
Edgar P. Burkhart 2025-06-13 23:24:21 +02:00
parent c55861c439
commit e64bb8b95a
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
3 changed files with 15 additions and 0 deletions

View file

@ -10,6 +10,7 @@
</p>
<p>
<a href="{% url "start_game" pk=group.pk %}" role="button"><i class="ri-play-fill"></i> Lancer une partie</a>
<a href="{% url "group_clear_blacklist" pk=group.pk %}" role="button"><i class="ri-history-fill"></i> Effacer la blacklist</a>
</p>
{% endif %}
{% if group.musikgame_set %}

View file

@ -41,4 +41,9 @@ urlpatterns = [
views.YoutubeCallbackView.as_view(),
name="youtube_callback",
),
path(
"group/<int:pk>/clear_blacklist/",
views.GroupClearBlacklistView.as_view(),
name="group_clear_blacklist",
),
]

View file

@ -246,3 +246,12 @@ class YoutubeCallbackView(LoginRequiredMixin, View):
},
)
return redirect("/")
class GroupClearBlacklistView(OwnerFilterMixin, SingleObjectMixin, View):
model = models.Group
def get(self, request, pk):
group = self.get_object()
group.musicvideo_set.filter(blacklisted=True).update(blacklisted=False)
return redirect(group)