-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
80 lines (64 loc) · 2.47 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from tortoise import Model, fields
class ThankModel(Model):
id = fields.IntField(pk=True)
guild = fields.ForeignKeyField(
model_name="main.GuildModel",
related_name="all_thanks",
description="Guild in which the user was thanked",
)
thanker = fields.ForeignKeyField(
model_name="main.UserModel",
related_name="sent_thanks",
description="The member who sent the thanks",
)
thanked = fields.ForeignKeyField(
model_name="main.UserModel",
related_name="thanks",
description="The member who was thanked",
)
time = fields.DatetimeField(auto_now_add=True)
description = fields.CharField(max_length=100)
class Meta:
table = "thanks"
table_description = "Represents a 'thank' given from one user to another"
class GuildModel(Model):
id = fields.BigIntField(pk=True, description="Discord ID of the guild")
all_thanks: fields.ForeignKeyRelation[ThankModel]
prefix = fields.CharField(
max_length=10, default=".", description="Custom prefix of the guild"
)
class Meta:
table = "guilds"
table_description = "Represents a discord guild's settings"
class UserModel(Model):
id = fields.BigIntField(pk=True, description="Discord ID of the user")
# External references
github_oauth_token = fields.CharField(
max_length=50, null=True, description="Github OAuth2 access token of the user"
)
stackoverflow_oauth_token = fields.CharField(
max_length=50,
null=True,
description="Stackoverflow OAuth2 access token of the user",
)
thanks: fields.ForeignKeyRelation[ThankModel]
sent_thanks: fields.ForeignKeyRelation[ThankModel]
class Meta:
table = "users"
table_description = "Represents all users"
class JokeModel(Model):
id = fields.IntField(pk=True, description="Joke ID")
setup = fields.CharField(max_length=150, description="Joke setup")
end = fields.CharField(max_length=150, description="Joke end")
tags = fields.JSONField(default=[], description="List of tags")
accepted = fields.BooleanField(
default=False, description="Whether the joke has been accepted in"
)
creator = fields.ForeignKeyField(
model_name="main.UserModel",
related_name="joke_submissions",
description="User who submitted this Joke",
)
class Meta:
table = "jokes"
table_description = "User submitted jokes being collected"