From 462f6d3b21558ed0a283c24e0e0332eac6ccbbb3 Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Fri, 11 Sep 2015 18:28:12 +0200 Subject: base modification in model for category support --- src/web/models/__init__.py | 3 ++- src/web/models/article.py | 11 +++++------ src/web/models/feed.py | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/web/models') diff --git a/src/web/models/__init__.py b/src/web/models/__init__.py index 54168279..81ebe361 100644 --- a/src/web/models/__init__.py +++ b/src/web/models/__init__.py @@ -31,8 +31,9 @@ from .role import Role from .user import User from .article import Article from .icon import Icon +from .category import Category -__all__ = ['Feed', 'Role', 'User', 'Article', 'Icon'] +__all__ = ['Feed', 'Role', 'User', 'Article', 'Icon', 'Category'] import os diff --git a/src/web/models/article.py b/src/web/models/article.py index 54eefe75..44a4234d 100644 --- a/src/web/models/article.py +++ b/src/web/models/article.py @@ -32,10 +32,8 @@ 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()) @@ -46,8 +44,9 @@ class Article(db.Model): 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): """ diff --git a/src/web/models/feed.py b/src/web/models/feed.py index 59456a7f..87616e02 100644 --- a/src/web/models/feed.py +++ b/src/web/models/feed.py @@ -56,6 +56,7 @@ class Feed(db.Model): # relationship icon_url = db.Column(db.String(), db.ForeignKey('icon.url'), default=None) user_id = db.Column(db.Integer(), db.ForeignKey('user.id')) + category_id = db.Column(db.Integer(), db.ForeignKey('category.id')) articles = db.relationship('Article', backref='source', lazy='dynamic', cascade='all,delete-orphan', order_by=desc("Article.date")) -- cgit