aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views/api
diff options
context:
space:
mode:
Diffstat (limited to 'pyaggr3g470r/views/api')
-rw-r--r--pyaggr3g470r/views/api/common.py2
-rw-r--r--pyaggr3g470r/views/api/feed.py24
2 files changed, 23 insertions, 3 deletions
diff --git a/pyaggr3g470r/views/api/common.py b/pyaggr3g470r/views/api/common.py
index a116b9c3..edf560da 100644
--- a/pyaggr3g470r/views/api/common.py
+++ b/pyaggr3g470r/views/api/common.py
@@ -62,7 +62,7 @@ class PyAggResource(Resource):
super(PyAggResource, self).__init__(*args, **kwargs)
def get(self, obj_id=None):
- return {'result': [self.controller.read(id=obj_id).dump()]}
+ return {'result': [self.controller.get(id=obj_id).dump()]}
def put(self, obj_id=None):
args = self.reqparse.parse_args()
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