diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2015-11-25 22:45:43 +0100 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2015-11-25 22:45:43 +0100 |
commit | b2618e9404b84cc62d4becb02436233a0d53b375 (patch) | |
tree | a31f2dc76d23967fa0243374cf475923a4b7e451 /pyaggr3g470r/views/api/article.py | |
parent | Updated default platform URL (for Heroku...). (diff) | |
download | newspipe-b2618e9404b84cc62d4becb02436233a0d53b375.tar.gz newspipe-b2618e9404b84cc62d4becb02436233a0d53b375.tar.bz2 newspipe-b2618e9404b84cc62d4becb02436233a0d53b375.zip |
Rfactorization. Just a start...
Diffstat (limited to 'pyaggr3g470r/views/api/article.py')
-rw-r--r-- | pyaggr3g470r/views/api/article.py | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/pyaggr3g470r/views/api/article.py b/pyaggr3g470r/views/api/article.py deleted file mode 100644 index d2969cb0..00000000 --- a/pyaggr3g470r/views/api/article.py +++ /dev/null @@ -1,63 +0,0 @@ -#! /usr/bin/env python -# -*- coding: utf-8 - - -from flask import g -import dateutil.parser - -from pyaggr3g470r.controllers import ArticleController -from pyaggr3g470r.views.api.common import PyAggAbstractResource,\ - PyAggResourceNew, \ - PyAggResourceExisting, \ - PyAggResourceMulti - - -ARTICLE_ATTRS = {'user_id': {'type': int}, - 'feed_id': {'type': int}, - 'entry_id': {'type': str}, - 'link': {'type': str}, - 'title': {'type': str}, - 'readed': {'type': bool}, 'like': {'type': bool}, - 'content': {'type': str}, - 'date': {'type': str}, 'retrieved_date': {'type': str}} - - -class ArticleNewAPI(PyAggResourceNew): - controller_cls = ArticleController - attrs = ARTICLE_ATTRS - to_date = ['date', 'retrieved_date'] - - -class ArticleAPI(PyAggResourceExisting): - controller_cls = ArticleController - attrs = ARTICLE_ATTRS - to_date = ['date', 'retrieved_date'] - - -class ArticlesAPI(PyAggResourceMulti): - controller_cls = ArticleController - attrs = ARTICLE_ATTRS - to_date = ['date', 'retrieved_date'] - - -class ArticlesChallenge(PyAggAbstractResource): - controller_cls = ArticleController - attrs = {'ids': {'type': list, 'default': []}} - to_date = ['date', 'retrieved_date'] - - def get(self): - parsed_args = self.reqparse_args() - for id_dict in parsed_args['ids']: - for key in self.to_date: - if key in id_dict: - id_dict[key] = dateutil.parser.parse(id_dict[key]) - - result = list(self.wider_controller.challenge(parsed_args['ids'])) - return result or None, 200 if result else 204 - - -g.api.add_resource(ArticleNewAPI, '/article', endpoint='article_new.json') -g.api.add_resource(ArticleAPI, '/article/<int:obj_id>', - endpoint='article.json') -g.api.add_resource(ArticlesAPI, '/articles', endpoint='articles.json') -g.api.add_resource(ArticlesChallenge, '/articles/challenge', - endpoint='articles_challenge.json') |