aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r/views/api/feed.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2015-11-25 22:45:43 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2015-11-25 22:45:43 +0100
commitb2618e9404b84cc62d4becb02436233a0d53b375 (patch)
treea31f2dc76d23967fa0243374cf475923a4b7e451 /pyaggr3g470r/views/api/feed.py
parentUpdated default platform URL (for Heroku...). (diff)
downloadnewspipe-b2618e9404b84cc62d4becb02436233a0d53b375.tar.gz
newspipe-b2618e9404b84cc62d4becb02436233a0d53b375.tar.bz2
newspipe-b2618e9404b84cc62d4becb02436233a0d53b375.zip
Rfactorization. Just a start...
Diffstat (limited to 'pyaggr3g470r/views/api/feed.py')
-rw-r--r--pyaggr3g470r/views/api/feed.py69
1 files changed, 0 insertions, 69 deletions
diff --git a/pyaggr3g470r/views/api/feed.py b/pyaggr3g470r/views/api/feed.py
deleted file mode 100644
index c80e9a9b..00000000
--- a/pyaggr3g470r/views/api/feed.py
+++ /dev/null
@@ -1,69 +0,0 @@
-#! /usr/bin/env python
-# -*- coding: utf-8 -
-
-from flask import g
-
-from pyaggr3g470r.controllers.feed import (FeedController,
- DEFAULT_MAX_ERROR,
- DEFAULT_LIMIT,
- DEFAULT_REFRESH_RATE)
-
-from pyaggr3g470r.views.api.common import PyAggAbstractResource, \
- PyAggResourceNew, \
- PyAggResourceExisting, \
- PyAggResourceMulti
-
-FEED_ATTRS = {'title': {'type': str},
- 'description': {'type': str},
- 'link': {'type': str},
- 'user_id': {'type': int},
- 'site_link': {'type': str},
- 'enabled': {'type': bool, 'default': True},
- 'etag': {'type': str, 'default': ''},
- 'icon_url': {'type': str, 'default': ''},
- 'last_modified': {'type': str},
- 'last_retrieved': {'type': str},
- 'last_error': {'type': str},
- 'error_count': {'type': int, 'default': 0}}
-
-class FeedNewAPI(PyAggResourceNew):
- controller_cls = FeedController
- attrs = FEED_ATTRS
- to_date = ['date', 'last_retrieved']
-
-class FeedAPI(PyAggResourceExisting):
- controller_cls = FeedController
- attrs = FEED_ATTRS
- to_date = ['date', 'last_retrieved']
-
-class FeedsAPI(PyAggResourceMulti):
- controller_cls = FeedController
- attrs = FEED_ATTRS
- to_date = ['date', 'last_retrieved']
-
-class FetchableFeedAPI(PyAggAbstractResource):
- controller_cls = FeedController
- to_date = ['date', 'last_retrieved']
- attrs = {'max_error': {'type': int, 'default': DEFAULT_MAX_ERROR},
- 'limit': {'type': int, 'default': DEFAULT_LIMIT},
- 'refresh_rate': {'type': int, 'default': DEFAULT_REFRESH_RATE},
- 'retreive_all': {'type': bool, 'default': False}}
-
- def get(self):
- args = self.reqparse_args()
- if g.user.refresh_rate:
- args['refresh_rate'] = g.user.refresh_rate
-
- if args.pop('retreive_all', False):
- contr = self.wider_controller
- else:
- contr = self.controller
- result = [feed for feed in contr.list_fetchable(**args)]
- return result or None, 200 if result else 204
-
-
-g.api.add_resource(FeedNewAPI, '/feed', endpoint='feed_new.json')
-g.api.add_resource(FeedAPI, '/feed/<int:obj_id>', endpoint='feed.json')
-g.api.add_resource(FeedsAPI, '/feeds', endpoint='feeds.json')
-g.api.add_resource(FetchableFeedAPI, '/feeds/fetchable',
- endpoint='fetchable_feed.json')
bgstack15