Add game management features: create MusikGame model, implement game creation and detail views, and update group detail template
This commit is contained in:
parent
19e6eb32c8
commit
f7baa91132
10 changed files with 275 additions and 2 deletions
|
@ -13,3 +13,16 @@ class GroupAddMembersForm(forms.ModelForm):
|
|||
class Meta:
|
||||
model = models.Group
|
||||
fields = ["members"]
|
||||
|
||||
|
||||
class MusikGameForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = models.MusikGame
|
||||
fields = ["players", "n"]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
group = models.Group.objects.get(pk=kwargs.pop("group", None))
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["players"].queryset = (
|
||||
group.members.all() | models.User.objects.filter(id=group.owner.id)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue