aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-07-01 07:45:37 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-07-01 07:45:37 +0200
commit3e7236a68870ac8dd755b09203280ced96528602 (patch)
treefff25d29783e25791eeeafc3b2ca59071ddbe6ca /pyaggr3g470r
parentNow using jQuery v2.1.1. (diff)
downloadnewspipe-3e7236a68870ac8dd755b09203280ced96528602.tar.gz
newspipe-3e7236a68870ac8dd755b09203280ced96528602.tar.bz2
newspipe-3e7236a68870ac8dd755b09203280ced96528602.zip
Added FeedListAPI ressource (todo: FeedAPI ressource).
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/rest.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/pyaggr3g470r/rest.py b/pyaggr3g470r/rest.py
index f5c315c4..fa7def90 100644
--- a/pyaggr3g470r/rest.py
+++ b/pyaggr3g470r/rest.py
@@ -226,3 +226,46 @@ class ArticleAPI(Resource):
api.add_resource(ArticleListAPI, '/api/v1.0/articles', endpoint = 'articles.json')
api.add_resource(ArticleAPI, '/api/v1.0/articles/<int:id>', endpoint = 'article.json')
+
+class FeedListAPI(Resource):
+ """
+ Defines a RESTful API for Feed elements.
+ """
+ method_decorators = [authenticate]
+
+ def __init__(self):
+ self.reqparse = reqparse.RequestParser()
+ self.reqparse.add_argument('title', type = unicode, location = 'json')
+ self.reqparse.add_argument('description', type = unicode, location = 'json')
+ self.reqparse.add_argument('link', type = unicode, location = 'json')
+ self.reqparse.add_argument('site_link', type = unicode, location = 'json')
+ self.reqparse.add_argument('email_notification', type = bool, location = 'json')
+ self.reqparse.add_argument('enabled', type = bool, location = 'json')
+ super(FeedListAPI, self).__init__()
+
+ def get(self):
+ """
+ Returns a list of feeds.
+ """
+ return jsonify(result= [{
+ "id": feed.id,
+ "title": feed.title,
+ "description": feed.description,
+ "link": feed.link,
+ "site_link": feed.site_link,
+ "email_notification": feed.email_notification,
+ "enabled": feed.enabled,
+ "created_date": feed.created_date,
+ "nb_articles": feed.articles.count()
+ }
+ for feed in g.user.feeds]
+ )
+
+ def post(self):
+ """
+ POST method - Create a new feed.
+ """
+ pass
+
+api.add_resource(FeedListAPI, '/api/v1.0/feeds', endpoint = 'feeds.json')
+#api.add_resource(FeedAPI, '/api/v1.0/feeds/<int:id>', endpoint = 'feeds.json') \ No newline at end of file
bgstack15