forked from PyAr/PyCamp_Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
53 lines (34 loc) · 1.17 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
import peewee as pw
db = pw.SqliteDatabase('pycamp_projects.db')
class Pycampista(pw.Model):
username = pw.CharField(unique=True)
arrive = pw.DateTimeField(null=True)
leave = pw.DateTimeField(null=True)
class Meta:
database = db
class Slot(pw.Model):
code = pw.CharField() # For example A1 for first slot first day
start = pw.DateTimeField()
class Meta:
database = db
class Project(pw.Model):
name = pw.CharField()
difficult_level = pw.IntegerField(default=1) # From 1 to 3
theme = pw.CharField(null=True)
slot = pw.ForeignKeyField(Slot, null=True)
class Meta:
database = db
class ProjectOwner(pw.Model):
project = pw.ForeignKeyField(Project)
owner = pw.ForeignKeyField(Pycampista)
class Meta:
database = db
primary_key = pw.CompositeKey('project', 'owner')
class Vote(pw.Model):
project = pw.ForeignKeyField(Project)
pycampista = pw.ForeignKeyField(Pycampista)
interest = pw.BooleanField()
class Meta:
database = db
db.connect()
db.create_tables([Pycampista, Project, Slot, ProjectOwner, Vote])