-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.py
76 lines (53 loc) · 1.87 KB
/
database.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
from peewee import *
from app import db
class EnumField(CharField):
def __init__(self, enum_class, *args, **kwargs):
super().__init__(*args, **kwargs)
self.enum_class = enum_class
self.max_length = 255
def db_value(self, value):
return value.name
def python_value(self, value):
return self.enum_class(value)
class Instance(db.Model):
name = CharField(primary_key=True)
api_key = CharField()
hostname = CharField()
class Event(db.Model):
name = CharField()
event_id = IntegerField(primary_key=True)
registration_id = CharField(unique=True, null=True)
instance = ForeignKeyField(Instance, backref='events')
class Application(db.Model):
application_id = IntegerField(primary_key=True)
first_name = CharField()
last_name = CharField()
email = CharField()
count = CharField()
message = CharField(max_length=10000)
class EventManager(db.Model):
username = CharField(primary_key=True)
password = CharField()
site_admin = BooleanField(default=False)
email = CharField()
class EventManagerRelation(db.Model):
class Meta:
primary_key = CompositeKey('manager', 'event')
manager = ForeignKeyField(EventManager)
event = ForeignKeyField(Event)
class Groups(db.Model):
id = IntegerField(primary_key=True)
name = CharField()
group_id = CharField()
event = ForeignKeyField(Event)
has_synced_npcs = BooleanField()
class EventAttendee(db.Model):
name = CharField()
event = ForeignKeyField(Event)
group = ForeignKeyField(Groups)
__all__ = ('Instance', 'EventManager', 'Event', 'EventManagerRelation', 'Groups', 'EventAttendee', 'Application')
# lmao was für ein idiot hat das geschrieben
# ah, ja genau: ich
db.database.create_tables([
Instance, EventManager, Event, EventManagerRelation, Groups, EventAttendee, Application
], safe=True)