aboutsummaryrefslogtreecommitdiff
path: root/src/web/models/article.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-02-03 07:11:37 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-02-03 07:11:37 +0100
commitda929a367c3f1fe5f3546be82e47111c2fa84ad3 (patch)
tree89380f41b802256d8fdbf724e7d9e63b48209b4a /src/web/models/article.py
parentMerge pull request #30 from jaesivsm/master (diff)
parentwriting a bit of doc, moving crawler together (diff)
downloadnewspipe-da929a367c3f1fe5f3546be82e47111c2fa84ad3.tar.gz
newspipe-da929a367c3f1fe5f3546be82e47111c2fa84ad3.tar.bz2
newspipe-da929a367c3f1fe5f3546be82e47111c2fa84ad3.zip
Merge pull request #31 from jaesivsm/master
redoing UI
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