diff options
Diffstat (limited to 'pyaggr3g470r/views')
-rw-r--r-- | pyaggr3g470r/views/api/common.py | 6 | ||||
-rw-r--r-- | pyaggr3g470r/views/api/feed.py | 1 | ||||
-rw-r--r-- | pyaggr3g470r/views/feed.py | 3 |
3 files changed, 8 insertions, 2 deletions
diff --git a/pyaggr3g470r/views/api/common.py b/pyaggr3g470r/views/api/common.py index b8c4dd9d..a7068807 100644 --- a/pyaggr3g470r/views/api/common.py +++ b/pyaggr3g470r/views/api/common.py @@ -143,7 +143,11 @@ class PyAggResourceExisting(PyAggAbstractResource): args = self.reqparse_args(default=False) new_values = {key: args[key] for key in set(args).intersection(self.attrs)} - self.controller.update({'id': obj_id}, new_values) + if 'user_id' in new_values and g.user.is_admin(): + controller = self.wider_controller + else: + controller = self.controller + return controller.update({'id': obj_id}, new_values), 200 def delete(self, obj_id=None): """delete a object""" diff --git a/pyaggr3g470r/views/api/feed.py b/pyaggr3g470r/views/api/feed.py index f9060263..530f3fef 100644 --- a/pyaggr3g470r/views/api/feed.py +++ b/pyaggr3g470r/views/api/feed.py @@ -16,6 +16,7 @@ from pyaggr3g470r.views.api.common import PyAggAbstractResource, \ 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': ''}, diff --git a/pyaggr3g470r/views/feed.py b/pyaggr3g470r/views/feed.py index 3556d7c7..18e110af 100644 --- a/pyaggr3g470r/views/feed.py +++ b/pyaggr3g470r/views/feed.py @@ -189,7 +189,8 @@ def process_form(feed_id=None): @feed_bp.route('/icon/<int:feed_id>', methods=['GET']) @login_required def icon(feed_id): - icon = FeedController(g.user.id).get(id=feed_id).icon + icon = FeedController(None if g.user.is_admin() else g.user.id)\ + .get(id=feed_id).icon etag = md5(icon.encode('utf8')).hexdigest() headers = {'Cache-Control': 'max-age=86400', 'ETag': etag} if request.headers.get('if-none-match') == etag: |