-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.py
46 lines (33 loc) · 1.23 KB
/
model.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
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
import app_config as config
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = config.MOCK_DB_URI
app.config.update(
DEBUG = True,
)
db = SQLAlchemy(app)
twtidPerLolid = db.Table('twitidPerLolid',
db.Column('twtid', db.String(25), db.ForeignKey('user.twtid')),
db.Column('lolid', db.Integer, db.ForeignKey('lol.id'))
)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
twtid = db.Column(db.String(25), unique=True) #getting username for mention
lang = db.Column(db.String(2))
regcode = db.Column(db.String, unique=True)
lols = db.relationship("Lol", secondary=twtidPerLolid, backref=db.backref('users', lazy='dynamic'))
def __init__(self, twtid, regcode, lang):
self.twtid = twtid
self.lang = 'en'
self.regcode = regcode
self.lang = lang
self.active = False
class Lol(db.Model):
id = db.Column(db.Integer, primary_key=True)
lolname = db.Column(db.String(25), unique=True)
lastgame = db.Column(db.Integer)
def __init__(self, lolid, lolname, lastgame):
self.id = lolid
self.lolname = lolname
self.lastgame = lastgame