fix: model, limite length of

tournament.name and winner_id can be null now
This commit is contained in:
starnakin 2023-12-20 21:11:37 +01:00
parent 288252ab37
commit 56cfd563d7
2 changed files with 5 additions and 3 deletions

View File

@ -5,7 +5,7 @@ class GameModel(models.Model):
finished = models.BooleanField(default=False) finished = models.BooleanField(default=False)
started = models.BooleanField(default=False) started = models.BooleanField(default=False)
winner_id = models.IntegerField() winner_id = models.IntegerField(null=True, blank=True)
def create(self, users_id: [int]): def create(self, users_id: [int]):
self.save() self.save()

View File

@ -5,7 +5,7 @@ from games.models import GameModel
# Create your models here.tu # Create your models here.tu
class TournamentModel(models.Model): class TournamentModel(models.Model):
name = models.CharField() name = models.CharField(max_length=100)
nb_players = models.IntegerField() nb_players = models.IntegerField()
nb_players_by_game = models.IntegerField() nb_players_by_game = models.IntegerField()
level = models.IntegerField() level = models.IntegerField()
@ -21,7 +21,9 @@ class TournamentModel(models.Model):
self.nb_players = nb_players self.nb_players = nb_players
self.nb_players_by_game = nb_players_by_game self.nb_players_by_game = nb_players_by_game
self.name = name self.name = name
return self.save() self.save()
return self.pk
def create_game(self, users_id): def create_game(self, users_id):
game_id = GameModel.create(users_id=users_id) game_id = GameModel.create(users_id=users_id)