from email.policy import default from tortoise.models import Model from tortoise import fields class Room(Model): id = fields.IntField(pk=True) id_code = fields.CharField(max_length=30, unique=True) name = fields.CharField(max_length=255) created_at = fields.DatetimeField(auto_now_add=True) public_result = fields.BooleanField(default=False) private = fields.BooleanField(default = True) online = fields.JSONField(default = list) users = fields.ManyToManyField('models.UserModel') class PydanticMeta: exlude=('users__email') class AnonymousMember(Model): id = fields.IntField(pk=True) id_code = fields.CharField(max_length=30, unique=True) name = fields.CharField(max_length=255) room = fields.ForeignKeyField('models.Room') class PydanticMeta: exclude=['room_owner', "id_code", 'id', 'challenger'] class Waiter(Model): id = fields.IntField(pk=True) name = fields.CharField(max_length=255) id_code = fields.CharField(max_length=30, unique=True) room = fields.ForeignKeyField('models.Room') user = fields.ForeignKeyField("models.UserModel", null=True) class RoomOwner(Model): user = fields.ForeignKeyField('models.UserModel', null = True) anonymous = fields.OneToOneField('models.AnonymousMember', null=True) room = fields.OneToOneField('models.Room', null=True) class Meta: table='room_owner' class Parcours(Model): id = fields.IntField(pk=True) id_code = fields.CharField(max_length=30, unique=True) name = fields.CharField(max_length=255) created_at = fields.DateField(auto_now_add=True) room = fields.ForeignKeyField('models.Room') timer = fields.IntField(default=10) exercices = fields.JSONField(default=list) success_condition = fields.IntField(default = 10) class Challenger(Model): parcours = fields.ForeignKeyField('models.Parcours') anonymous = fields.OneToOneField('models.AnonymousMember', null=True) user = fields.OneToOneField("models.UserModel", null=True) challenges = fields.JSONField(default=list)