aboutsummaryrefslogtreecommitdiff
path: root/src/web/models/feed.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-10-04 11:39:25 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-10-04 11:39:25 +0200
commite36f64813e6f12d541d69bdb1619dbf29b2d8c92 (patch)
tree4fa59353ed38f9c0ccc87ed9de5410a40bb91248 /src/web/models/feed.py
parentRemoved duplicate glyphicon. (diff)
downloadnewspipe-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/feed.py')
-rw-r--r--src/web/models/feed.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/web/models/feed.py b/src/web/models/feed.py
index a866ac57..0e36bc79 100644
--- a/src/web/models/feed.py
+++ b/src/web/models/feed.py
@@ -28,7 +28,8 @@ __license__ = "GPLv3"
from bootstrap import db
from datetime import datetime
-from sqlalchemy import desc
+from sqlalchemy import desc, Index
+from sqlalchemy.orm import validates
from web.models.right_mixin import RightMixin
@@ -42,7 +43,7 @@ class Feed(db.Model, RightMixin):
link = db.Column(db.String())
site_link = db.Column(db.String(), default="")
enabled = db.Column(db.Boolean(), default=True)
- created_date = db.Column(db.DateTime(), default=datetime.now)
+ created_date = db.Column(db.DateTime(), default=datetime.utcnow)
filters = db.Column(db.PickleType, default=[])
# cache handling
@@ -62,6 +63,10 @@ class Feed(db.Model, RightMixin):
cascade='all,delete-orphan',
order_by=desc("date"))
+ # index
+ idx_feed_uid_cid = Index('user_id', 'category_id')
+ idx_feed_uid = Index('user_id')
+
# api whitelists
@staticmethod
def _fields_base_write():
@@ -72,5 +77,13 @@ class Feed(db.Model, RightMixin):
def _fields_base_read():
return {'id', 'user_id', 'icon_url', 'last_retrieved'}
+ @validates('title')
+ def validates_title(self, key, value):
+ return str(value).strip()
+
+ @validates('description')
+ def validates_description(self, key, value):
+ return str(value).strip()
+
def __repr__(self):
return '<Feed %r>' % (self.title)
bgstack15