aboutsummaryrefslogtreecommitdiff
path: root/src/web/models/article.py
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2016-02-02 23:15:37 +0100
committerFrançois Schmidts <francois.schmidts@gmail.com>2016-02-02 23:15:37 +0100
commit082bf39a7dd7296d4f51b6b124d185135dc00989 (patch)
tree6e12cf2b67b016aff38874c389b5bf8b5242749a /src/web/models/article.py
parentfixing logging (diff)
parentreload and fold all button (diff)
downloadnewspipe-082bf39a7dd7296d4f51b6b124d185135dc00989.tar.gz
newspipe-082bf39a7dd7296d4f51b6b124d185135dc00989.tar.bz2
newspipe-082bf39a7dd7296d4f51b6b124d185135dc00989.zip
Merge branch 'feature/categories'
close #22 close #23
Diffstat (limited to 'src/web/models/article.py')
-rw-r--r--src/web/models/article.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/web/models/article.py b/src/web/models/article.py
index 54eefe75..94fedf16 100644
--- a/src/web/models/article.py
+++ b/src/web/models/article.py
@@ -32,22 +32,20 @@ from sqlalchemy import asc, desc
class Article(db.Model):
- """
- Represent an article from a feed.
- """
- id = db.Column(db.Integer, primary_key=True)
+ "Represent an article from a feed."
+ id = db.Column(db.Integer(), primary_key=True)
entry_id = db.Column(db.String())
link = db.Column(db.String())
title = db.Column(db.String())
content = db.Column(db.String())
readed = db.Column(db.Boolean(), default=False)
like = db.Column(db.Boolean(), default=False)
- #notes = db.Column(db.String(), default="")
date = db.Column(db.DateTime(), default=datetime.now)
retrieved_date = db.Column(db.DateTime(), default=datetime.now)
- user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
- feed_id = db.Column(db.Integer, db.ForeignKey('feed.id'))
+ user_id = db.Column(db.Integer(), db.ForeignKey('user.id'))
+ feed_id = db.Column(db.Integer(), db.ForeignKey('feed.id'))
+ category_id = db.Column(db.Integer(), db.ForeignKey('category.id'))
def previous_article(self):
"""
@@ -55,7 +53,7 @@ class Article(db.Model):
"""
return Article.query.filter(Article.date < self.date,
Article.feed_id == self.feed_id)\
- .order_by(desc("Article.date")).first()
+ .order_by(desc("date")).first()
def next_article(self):
"""
@@ -63,7 +61,7 @@ class Article(db.Model):
"""
return Article.query.filter(Article.date > self.date,
Article.feed_id == self.feed_id)\
- .order_by(asc("Article.date")).first()
+ .order_by(asc("date")).first()
def __repr__(self):
return "<Article(id=%d, entry_id=%s, title=%r, " \
@@ -81,5 +79,5 @@ class Article(db.Model):
"like": self.like,
"date": self.date,
"retrieved_date": self.retrieved_date,
- "feed_id": getattr(self.source, 'id', None),
- "feed_name": getattr(self.source, 'title', None)}
+ "feed_id": self.feed_id,
+ "category_id": self.category_id}
bgstack15