diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-10-04 11:39:25 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-10-04 11:39:25 +0200 |
commit | e36f64813e6f12d541d69bdb1619dbf29b2d8c92 (patch) | |
tree | 4fa59353ed38f9c0ccc87ed9de5410a40bb91248 /src/web/models/user.py | |
parent | Removed duplicate glyphicon. (diff) | |
download | newspipe-e36f64813e6f12d541d69bdb1619dbf29b2d8c92.tar.gz newspipe-e36f64813e6f12d541d69bdb1619dbf29b2d8c92.tar.bz2 newspipe-e36f64813e6f12d541d69bdb1619dbf29b2d8c92.zip |
Fixed a bug when removing a user who have feeds in categories.
Diffstat (limited to 'src/web/models/user.py')
-rw-r--r-- | src/web/models/user.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/web/models/user.py b/src/web/models/user.py index 2e5d2f55..1e7e3ec0 100644 --- a/src/web/models/user.py +++ b/src/web/models/user.py @@ -35,6 +35,8 @@ from flask_login import UserMixin from bootstrap import db from web.models.right_mixin import RightMixin +from web.models.category import Category +from web.models.feed import Feed class User(db.Model, UserMixin, RightMixin): @@ -49,8 +51,8 @@ class User(db.Model, UserMixin, RightMixin): is_public_profile = db.Column(db.Boolean(), default=False) webpage = db.Column(db.String(), default="") - date_created = db.Column(db.DateTime(), default=datetime.now) - last_seen = db.Column(db.DateTime(), default=datetime.now) + date_created = db.Column(db.DateTime(), default=datetime.utcnow) + last_seen = db.Column(db.DateTime(), default=datetime.utcnow) refresh_rate = db.Column(db.Integer, default=60) # in minutes # user rights @@ -59,9 +61,12 @@ class User(db.Model, UserMixin, RightMixin): is_api = db.Column(db.Boolean(), default=False) # relationship - feeds = db.relationship('Feed', backref='subscriber', lazy='dynamic', - cascade='all,delete-orphan') - categories = db.relationship('Category', cascade='all, delete-orphan') + categories = db.relationship('Category', backref='user', + cascade='all, delete-orphan', + foreign_keys=[Category.user_id]) + feeds = db.relationship('Feed', backref='user', + cascade='all, delete-orphan', + foreign_keys=[Feed.user_id]) @staticmethod def _fields_base_write(): |