forked from lanmomo/lanmomo-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
73 lines (55 loc) · 2.27 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
from sqlalchemy import Table, Column, Integer, String, Binary, Boolean, ForeignKey, Date
from sqlalchemy.orm import mapper
from database import metadata, db_session
class Subscribtion():
query = db_session.query_property()
def __init__(self, email):
self.email = email
def __repr__(self):
return '<Subscribtion %r>' % (self.email)
class User():
query = db_session.query_property()
def __init__(self, username, email, password, salt):
self.username = username
self.email = email
self.password = password
self.salt = salt
def __repr__(self):
return '<User %r>' % (self.username)
class Ticket():
query = db_session.query_property()
def __init__(self, type_id, owner_id, paid=False, reserved_until=None,
reserved_at=None):
self.type_id = type_id
self.owner_id = owner_id
self.paid = paid
self.reserved_until = reserved_until
self.reserved_at = reserved_at
def __repr__(self):
return '<Ticket %r>' % (self.id)
subcribtions = Table('subcribtions', metadata,
Column('id', Integer, primary_key=True),
Column('email', String(1000), nullable=False)
)
users = Table('users', metadata,
Column('id', Integer, primary_key=True),
Column('username', String(1000), nullable=False),
Column('email', String(1000), nullable=False),
Column('password', Binary(64), nullable=False),
Column('salt', String(42), nullable=False)
)
tickets = Table('tickets', metadata,
Column('id', Integer, primary_key=True),
# pc or console
Column('type_id', Integer, nullable=False),
# avoid n-n for now...
Column('owner_id', Integer, ForeignKey("users.id"),
nullable=False),
# Look for related payment and remove this field ?
Column('paid', Boolean, default=False, nullable=False),
Column('reserved_until', Date, nullable=False),
Column('reserved_at', Date, nullable=False)
)
mapper(Subscribtion, subcribtions)
mapper(User, users)
mapper(Ticket, tickets)