From 0e784cde3129f3dec7bf2386143eeeb1444ac601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Fri, 5 Feb 2016 23:53:56 +0100 Subject: [PATCH] Fixed problem with some REST requests during autoupdate. Fixed #1935. --- openslides/core/static/js/core/base.js | 3 ++- openslides/utils/autoupdate.py | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/openslides/core/static/js/core/base.js b/openslides/core/static/js/core/base.js index 776aa9188..657e4b1c2 100644 --- a/openslides/core/static/js/core/base.js +++ b/openslides/core/static/js/core/base.js @@ -188,7 +188,8 @@ angular.module('OpenSlidesApp.core', [ } DS.eject(data.collection, data.id); } - // TODO: handle other statuscodes + // If you want to handle more status codes, change server + // restrictions in utils/autoupdate.py. }); } ]) diff --git a/openslides/utils/autoupdate.py b/openslides/utils/autoupdate.py index 04dbb1f8b..58a8c0c89 100644 --- a/openslides/utils/autoupdate.py +++ b/openslides/utils/autoupdate.py @@ -79,14 +79,18 @@ class OpenSlidesSockJSConnection(SockJSConnection): This method is called after succesful response of AsyncHTTPClient(). See send_object(). """ - collection, obj_id = get_collection_and_id_from_url(response.request.url) - data = { - 'url': response.request.url, - 'status_code': response.code, - 'collection': collection, - 'id': obj_id, - 'data': json.loads(response.body.decode())} - self.send(data) + if response.code in (200, 404): + # Only send something to the client in case of one of these status + # codes. You have to change the client code (autoupdate.onMessage) + # if you want to handle some more codes. + collection, obj_id = get_collection_and_id_from_url(response.request.url) + data = { + 'url': response.request.url, + 'status_code': response.code, + 'collection': collection, + 'id': obj_id, + 'data': json.loads(response.body.decode())} + self.send(data) @classmethod def send_object(cls, object_url):