I have the following (stripped down) code:
# games/models.py
side_choices = [('A', 'Attack'), ('D', 'Defense')]
position_choices = [(0, 'Commander'), (1, 'Knight'), (2, 'Mage'), (3, 'Healer')]
class Game(models.Model):
users = models.ManyToManyField(User, through='GameParticipation)) // User is Django's user
class GameParticipation(models.Model):
user = models.ForeignKey(User)
game = models.ForeignKey(Game)
side = models.CharField(choices=side_choices)
position = models.PositiveSmallIntegerField(choices=position_choices)
# games/forms.py
class JoinForm(forms.Form):
side = forms.ChoiceField(choices=side_choices)
position = forms.ChoiceField(choices=position_choices)
And I haven't a clue how I can write the code to get a list of free spaces in a game, and pass it to the JoinForm
so that users don't see options for a taken space.