From 8ed9deab2d58e07f8f99b4b5292e153956a32f21 Mon Sep 17 00:00:00 2001 From: starnakin Date: Wed, 20 Dec 2023 19:11:56 +0100 Subject: [PATCH] add: attribute game state to gamemodel --- games/models.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/games/models.py b/games/models.py index 9a23ad9..3c95a6b 100644 --- a/games/models.py +++ b/games/models.py @@ -2,12 +2,19 @@ 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() 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()