aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views/api/feed.py
diff options
context:
space:
mode:
authorFrançois Schmidts <francois.schmidts@gmail.com>2015-01-20 17:20:07 +0100
committerFrançois Schmidts <francois.schmidts@gmail.com>2015-03-03 22:22:46 +0100
commit5ce0ce0d57c9d9976a47a120ca6235b84ade236a (patch)
tree378862500c6ed0b5a7fadc8c3ac0fd2b24398ef1 /pyaggr3g470r/views/api/feed.py
parenta first big refacto of the existing arch (diff)
downloadnewspipe-5ce0ce0d57c9d9976a47a120ca6235b84ade236a.tar.gz
newspipe-5ce0ce0d57c9d9976a47a120ca6235b84ade236a.tar.bz2
newspipe-5ce0ce0d57c9d9976a47a120ca6235b84ade236a.zip
first implementation of fetchable feeds
Diffstat (limited to 'pyaggr3g470r/views/api/feed.py')
-rw-r--r--pyaggr3g470r/views/api/feed.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/pyaggr3g470r/views/api/feed.py b/pyaggr3g470r/views/api/feed.py
index 346898b5..94a5a433 100644
--- a/pyaggr3g470r/views/api/feed.py
+++ b/pyaggr3g470r/views/api/feed.py
@@ -1,7 +1,8 @@
from flask import g
from flask.ext.restful import Resource, reqparse
-from pyaggr3g470r.controllers import FeedController
+from pyaggr3g470r.controllers.feed import FeedController, \
+ DEFAULT_MAX_ERROR, DEFAULT_LIMIT
from pyaggr3g470r.models import Feed
from pyaggr3g470r.views.api.common import authenticate, to_response, \
@@ -72,7 +73,8 @@ class FeedAPI(PyAggResource):
"Defines a RESTful API for Feed elements."
controller_cls = FeedController
editable_attrs = ['title', 'description', 'link', 'site_link',
- 'email_notification', 'enabled']
+ 'email_notification', 'enabled', 'last_refreshed',
+ 'last_error', 'error_count']
def __init__(self):
self.reqparse = reqparse.RequestParser()
@@ -87,5 +89,23 @@ class FeedAPI(PyAggResource):
super(FeedAPI, self).__init__()
+class FetchableFeedAPI(Resource):
+
+ def __init__(self):
+ self.reqparse = reqparse.RequestParser()
+ self.reqparse.add_argument('max_error', type=int, location='json',
+ default=DEFAULT_MAX_ERROR)
+ self.reqparse.add_argument('limit', type=int, location='json',
+ default=DEFAULT_LIMIT)
+ super(FetchableFeedAPI, self).__init__()
+
+ def get(self):
+ args = self.reqparse.parse_args()
+ controller = FeedController(g.user.id)
+ return {'result': [feed.dump() for feed in controller.list_fetchable(
+ max_error=args['max_error'], limit=args['limit'])]}
+
+
g.api.add_resource(FeedListAPI, '/feeds', endpoint='feeds.json')
g.api.add_resource(FeedAPI, '/feeds/<int:obj_id>', endpoint='feed.json')
+g.api.add_resource(FetchableFeedAPI, '/feeds/fetchable', endpoint='fetchable_feed.json')
bgstack15