diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-07-05 07:05:16 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2014-07-05 07:05:16 +0200 |
commit | e28a8a0151f247c60b111c02518ff12a23bad492 (patch) | |
tree | 3bb68eeb57a26498f0a231cfeddf6266e3376ba3 /pyaggr3g470r | |
parent | Updated NEWS.rst. (diff) | |
download | newspipe-e28a8a0151f247c60b111c02518ff12a23bad492.tar.gz newspipe-e28a8a0151f247c60b111c02518ff12a23bad492.tar.bz2 newspipe-e28a8a0151f247c60b111c02518ff12a23bad492.zip |
It is now possible to tupdate a feed with REST API.
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r-- | pyaggr3g470r/rest.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/pyaggr3g470r/rest.py b/pyaggr3g470r/rest.py index 5058d916..5732ce02 100644 --- a/pyaggr3g470r/rest.py +++ b/pyaggr3g470r/rest.py @@ -288,8 +288,12 @@ class FeedAPI(Resource): def __init__(self): self.reqparse = reqparse.RequestParser() - #self.reqparse.add_argument('like', type = bool, location = 'json') - #self.reqparse.add_argument('readed', type = bool, location = 'json') + 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(FeedAPI, self).__init__() def get(self, id=None): @@ -316,7 +320,27 @@ class FeedAPI(Resource): """ Update a feed. """ - pass + args = self.reqparse.parse_args() + feed = Feed.query.filter(Feed.id == id, Feed.user_id == g.user.id).first() + if feed is not None: + if None is not args.get('title', None): + feed.title = args['title'] + if None is not args.get('description', None): + feed.description = args['description'] + if None is not args.get('link', None): + feed.link = args['link'] + if None is not args.get('site_link', None): + feed.site_link = args['site_link'] + if None is not args.get('email_notification', None): + feed.email_notification = args['email_notification'] + if None is not args.get('enabled', None): + feed.enabled = args['enabled'] + db.session.commit() + return {"message":"ok"} + else: + response = jsonify({'code': 404, 'message': 'Feed not found'}) + response.status_code = 404 + return response def delete(self, id): """ |