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 From 5f66e6465d3822b150898de2a7fb8df39ed7fdc6 Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Sun, 11 Oct 2015 23:34:33 +0200 Subject: removing misplaced stuffs from views, more controllers use --- src/web/models/user.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/web/models') diff --git a/src/web/models/user.py b/src/web/models/user.py index c5e70036..d1b9c568 100644 --- a/src/web/models/user.py +++ b/src/web/models/user.py @@ -30,7 +30,7 @@ import re import random import hashlib from datetime import datetime -from werkzeug import generate_password_hash, check_password_hash +from werkzeug import check_password_hash from flask.ext.login import UserMixin from bootstrap import db @@ -63,12 +63,6 @@ class User(db.Model, UserMixin): """ return self.id - def set_password(self, password): - """ - Hash the password of the user. - """ - self.pwdhash = generate_password_hash(password) - def check_password(self, password): """ Check the password of the user. @@ -79,7 +73,7 @@ class User(db.Model, UserMixin): """ Return True if the user has administrator rights. """ - return len([role for role in self.roles if role.name == "admin"]) != 0 + return "admin" in [role.name for role in self.roles] def __eq__(self, other): return self.id == other.id -- cgit From 2ca3246de2b7b54452ba7d996064ae32258f9cd3 Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Mon, 12 Oct 2015 21:56:48 +0200 Subject: fixing sqlalchemy resolving warning --- src/web/models/article.py | 4 ++-- src/web/models/feed.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/web/models') diff --git a/src/web/models/article.py b/src/web/models/article.py index 44a4234d..2a5f4329 100644 --- a/src/web/models/article.py +++ b/src/web/models/article.py @@ -54,7 +54,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): """ @@ -62,7 +62,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 "' % (self.title) -- cgit From 2c0e17cb977a1e8782799b337df8b1583d019906 Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Mon, 12 Oct 2015 22:36:01 +0200 Subject: bootstraping react --- src/web/models/article.py | 1 - src/web/models/category.py | 11 +++++++++++ src/web/models/feed.py | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/web/models/category.py (limited to 'src/web/models') diff --git a/src/web/models/article.py b/src/web/models/article.py index 2a5f4329..91be9846 100644 --- a/src/web/models/article.py +++ b/src/web/models/article.py @@ -40,7 +40,6 @@ class Article(db.Model): 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) diff --git a/src/web/models/category.py b/src/web/models/category.py new file mode 100644 index 00000000..78054809 --- /dev/null +++ b/src/web/models/category.py @@ -0,0 +1,11 @@ +from bootstrap import db + + +class Category(db.Model): + id = db.Column(db.Integer(), primary_key=True) + name = db.Column(db.String()) + + user_id = db.Column(db.Integer, db.ForeignKey('user.id')) + + def dump(self): + return {key: getattr(self, key) for key in ('id', 'name', 'user_id')} diff --git a/src/web/models/feed.py b/src/web/models/feed.py index 9d08a972..29d5bc4c 100644 --- a/src/web/models/feed.py +++ b/src/web/models/feed.py @@ -67,6 +67,7 @@ class Feed(db.Model): def dump(self): return {"id": self.id, "user_id": self.user_id, + "category_id": self.category_id, "title": self.title, "description": self.description, "link": self.link, -- cgit From 56ab5f6df51ff301a4dccc458eb83917bba49afc Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Fri, 29 Jan 2016 00:27:47 +0100 Subject: wip right panel --- src/web/models/feed.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src/web/models') diff --git a/src/web/models/feed.py b/src/web/models/feed.py index 29d5bc4c..a9c49282 100644 --- a/src/web/models/feed.py +++ b/src/web/models/feed.py @@ -75,5 +75,6 @@ class Feed(db.Model): "etag": self.etag, "icon_url": self.icon_url, "error_count": self.error_count, + "created_date": self.created_date, "last_modified": self.last_modified, "last_retrieved": self.last_retrieved} -- cgit From 4098a0de815013c521618b6419d91f997c986ef0 Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Fri, 29 Jan 2016 14:26:02 +0100 Subject: draft displaying article --- src/web/models/article.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/web/models') diff --git a/src/web/models/article.py b/src/web/models/article.py index 91be9846..94fedf16 100644 --- a/src/web/models/article.py +++ b/src/web/models/article.py @@ -79,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} -- cgit From f334fb4b355d90cbf0b8d9e658a87ebeec7fbe90 Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Sat, 30 Jan 2016 01:44:13 +0100 Subject: wip redoing feed panel --- src/web/models/feed.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/web/models') diff --git a/src/web/models/feed.py b/src/web/models/feed.py index a9c49282..c5fcbe4c 100644 --- a/src/web/models/feed.py +++ b/src/web/models/feed.py @@ -73,6 +73,8 @@ class Feed(db.Model): "link": self.link, "site_link": self.site_link, "etag": self.etag, + "enabled": self.enabled, + "filters": self.filters, "icon_url": self.icon_url, "error_count": self.error_count, "created_date": self.created_date, -- cgit From 64964d2fcfa73e18b1316d788bacd11e2180bb7d Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Sun, 31 Jan 2016 18:59:36 +0100 Subject: handling errors from one page app --- src/web/models/feed.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src/web/models') diff --git a/src/web/models/feed.py b/src/web/models/feed.py index c5fcbe4c..7768ee50 100644 --- a/src/web/models/feed.py +++ b/src/web/models/feed.py @@ -77,6 +77,7 @@ class Feed(db.Model): "filters": self.filters, "icon_url": self.icon_url, "error_count": self.error_count, + "last_error": self.last_error, "created_date": self.created_date, "last_modified": self.last_modified, "last_retrieved": self.last_retrieved} -- cgit