-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
48 lines (37 loc) · 2.08 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
from flask_login import UserMixin
from werkzeug.security import check_password_hash, generate_password_hash
from extensions import db
class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(64), unique=True, nullable=False)
email = db.Column(db.String(120), unique=True, nullable=False)
password_hash = db.Column(db.String(128))
videos = db.relationship('Video', backref='user', lazy=True)
settings = db.relationship('UserSettings', backref='user', lazy=True, uselist=False)
def set_password(self, password):
self.password_hash = generate_password_hash(password)
def check_password(self, password):
return check_password_hash(self.password_hash, password)
class UserSettings(db.Model):
id = db.Column(db.Integer, primary_key=True)
brightness = db.Column(db.Float, nullable=False, default=1.0)
contrast = db.Column(db.Float, nullable=False, default=1.0)
saturate = db.Column(db.Float, nullable=False, default=1.0)
hueRotate = db.Column(db.Float, nullable=False, default=0.0)
user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
class Video(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(255), nullable=False)
video_filename = db.Column(db.String(255), nullable=False)
preview_filename = db.Column(db.String(255), nullable=False)
blur_timeline_filename = db.Column(db.String(255), nullable=False)
epilepsy_timeline_filename = db.Column(db.String(255), nullable=False)
user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
video_settings = db.relationship('VideoSettings', backref='video', lazy=True, uselist=False)
class VideoSettings(db.Model):
id = db.Column(db.Integer, primary_key=True)
brightness = db.Column(db.Float, nullable=False)
contrast = db.Column(db.Float, nullable=False)
saturate = db.Column(db.Float, nullable=False)
hueRotate = db.Column(db.Float, nullable=False)
video_id = db.Column(db.Integer, db.ForeignKey("video.id"), nullable=False)