34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
import tortoise.fields as fields
|
|
import tortoise.models as models
|
|
from tortoise.models import Model
|
|
|
|
|
|
class Admin(Model):
|
|
id = fields.IntField(pk=True)
|
|
username = fields.CharField(unique=True, max_length=255, index=True)
|
|
hashed_password = fields.CharField(max_length=255)
|
|
|
|
|
|
class Game(Model):
|
|
id = fields.IntField(pk=True)
|
|
title = fields.CharField(unique=True, max_length=255, index=True)
|
|
auto_approve = fields.BooleanField(default=False)
|
|
|
|
|
|
class GameKey(Model):
|
|
id = fields.IntField(pk=True)
|
|
key = fields.CharField(max_length=255, unique=True, index=True)
|
|
expires_at = fields.DatetimeField(null=True)
|
|
game: fields.ForeignKeyRelation = fields.ForeignKeyField(
|
|
"models.Game", related_name="keys", on_delete="CASCADE")
|
|
|
|
|
|
class Score(Model):
|
|
id = fields.IntField(pk=True)
|
|
username = fields.CharField(max_length=255)
|
|
points = fields.IntField()
|
|
created_at = fields.DatetimeField(auto_now_add=True)
|
|
game: fields.ForeignKeyRelation = fields.ForeignKeyRelation(
|
|
"models.Game", related_name="scores", on_delete="CASCADE"
|
|
)
|
|
approved = fields.BooleanField(default=False)
|