ft_transcendence/games/models.py
starnakin 56cfd563d7 fix: model, limite length of
tournament.name and winner_id can be null now
2023-12-20 21:11:37 +01:00

21 lines
583 B
Python

from django.db import models
# Create your models here.
class GameModel(models.Model):
finished = models.BooleanField(default=False)
started = models.BooleanField(default=False)
winner_id = models.IntegerField(null=True, blank=True)
def create(self, users_id: [int]):
self.save()
for user_id in users_id:
GameMembersModel(game_id=self.pk, member_id=user_id).save()
return self.pk
def get_users(self):
return list(GameMembersModel.objects.filter(self.pk))
class GameMembersModel(models.Model):
game_id = models.IntegerField()
member_id = models.IntegerField()