Update GroupDetailView to exclude blacklisted music videos and mark music as blacklisted in GameCreateView
This commit is contained in:
parent
dfe312d47d
commit
c55861c439
1 changed files with 9 additions and 2 deletions
|
@ -54,10 +54,15 @@ class GroupDetailView(MemberFilterMixin, GroupMixin, DetailView):
|
|||
|
||||
data["musics"] = data["group"].musicvideo_set.filter(owner=self.request.user)
|
||||
data["owner_count"] = (
|
||||
data["group"].musicvideo_set.filter(owner=data["group"].owner).count()
|
||||
data["group"]
|
||||
.musicvideo_set.filter(owner=data["group"].owner, blacklisted=False)
|
||||
.count()
|
||||
)
|
||||
data["members"] = data["group"].members.annotate(
|
||||
count=Count("musicvideo", filter=Q(group=data["group"]))
|
||||
count=Count(
|
||||
"musicvideo",
|
||||
filter=Q(group=data["group"], musicvideo__blacklisted=False),
|
||||
)
|
||||
)
|
||||
|
||||
return data
|
||||
|
@ -143,6 +148,8 @@ class GameCreateView(LoginRequiredMixin, CreateView):
|
|||
pm_list = list(zip(players, musics))
|
||||
random.shuffle(pm_list)
|
||||
for (player, music), order in zip(pm_list, range(len(pm_list))):
|
||||
music.blacklisted = True
|
||||
music.save()
|
||||
models.MusicGameOrder.objects.create(
|
||||
game=form.instance, player=player, music_video=music, order=order
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue