aboutsummaryrefslogtreecommitdiff
path: root/src/web/views/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/views/api')
-rw-r--r--src/web/views/api/__init__.py4
-rw-r--r--src/web/views/api/article.py7
-rw-r--r--src/web/views/api/category.py31
-rw-r--r--src/web/views/api/feed.py14
4 files changed, 46 insertions, 10 deletions
diff --git a/src/web/views/api/__init__.py b/src/web/views/api/__init__.py
index 24472ebe..ed3bd702 100644
--- a/src/web/views/api/__init__.py
+++ b/src/web/views/api/__init__.py
@@ -26,6 +26,6 @@ __revision__ = "$Date: 2014/07/05 $"
__copyright__ = "Copyright (c) Cedric Bonhomme"
__license__ = "AGPLv3"
-from web.views.api import article, feed
+from web.views.api import article, feed, category
-__all__ = ['article', 'feed']
+__all__ = ['article', 'feed', 'category']
diff --git a/src/web/views/api/article.py b/src/web/views/api/article.py
index 51844b20..23c5c495 100644
--- a/src/web/views/api/article.py
+++ b/src/web/views/api/article.py
@@ -13,12 +13,15 @@ from web.views.api.common import PyAggAbstractResource,\
ARTICLE_ATTRS = {'user_id': {'type': int},
'feed_id': {'type': int},
+ 'category_id': {'type': int},
'entry_id': {'type': str},
'link': {'type': str},
'title': {'type': str},
- 'readed': {'type': bool}, 'like': {'type': bool},
+ 'readed': {'type': bool},
+ 'like': {'type': bool},
'content': {'type': str},
- 'date': {'type': str}, 'retrieved_date': {'type': str}}
+ 'date': {'type': str},
+ 'retrieved_date': {'type': str}}
class ArticleNewAPI(PyAggResourceNew):
diff --git a/src/web/views/api/category.py b/src/web/views/api/category.py
new file mode 100644
index 00000000..7923279a
--- /dev/null
+++ b/src/web/views/api/category.py
@@ -0,0 +1,31 @@
+from flask import g
+
+from web.controllers.category import CategoryController
+from web.views.api.common import (PyAggResourceNew,
+ PyAggResourceExisting,
+ PyAggResourceMulti)
+
+
+CAT_ATTRS = {'name': {'type': str},
+ 'user_id': {'type': int}}
+
+
+class CategoryNewAPI(PyAggResourceNew):
+ controller_cls = CategoryController
+ attrs = CAT_ATTRS
+
+
+class CategoryAPI(PyAggResourceExisting):
+ controller_cls = CategoryController
+ attrs = CAT_ATTRS
+
+
+class CategoriesAPI(PyAggResourceMulti):
+ controller_cls = CategoryController
+ attrs = CAT_ATTRS
+
+
+g.api.add_resource(CategoryNewAPI, '/category', endpoint='category_new.json')
+g.api.add_resource(CategoryAPI, '/category/<int:obj_id>',
+ endpoint='category.json')
+g.api.add_resource(CategoriesAPI, '/categories', endpoint='categories.json')
diff --git a/src/web/views/api/feed.py b/src/web/views/api/feed.py
index 2bb9814f..604620b4 100644
--- a/src/web/views/api/feed.py
+++ b/src/web/views/api/feed.py
@@ -4,23 +4,25 @@
from flask import g
from web.controllers.feed import (FeedController,
- DEFAULT_MAX_ERROR,
- DEFAULT_LIMIT,
- DEFAULT_REFRESH_RATE)
+ DEFAULT_MAX_ERROR,
+ DEFAULT_LIMIT,
+ DEFAULT_REFRESH_RATE)
from web.views.api.common import PyAggAbstractResource, \
- PyAggResourceNew, \
- PyAggResourceExisting, \
- PyAggResourceMulti
+ PyAggResourceNew, \
+ PyAggResourceExisting, \
+ PyAggResourceMulti
FEED_ATTRS = {'title': {'type': str},
'description': {'type': str},
'link': {'type': str},
'user_id': {'type': int},
+ 'category_id': {'type': int},
'site_link': {'type': str},
'enabled': {'type': bool, 'default': True},
'etag': {'type': str, 'default': ''},
'icon_url': {'type': str, 'default': ''},
+ 'filters': {'type': list},
'last_modified': {'type': str},
'last_retrieved': {'type': str},
'last_error': {'type': str},
bgstack15