From 86c189c964e047a227af8ee88cc5fb20972bdb8a Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sun, 1 Mar 2015 08:42:47 +0100 Subject: [PATCH] Autoupdate for delete views Fixes: #1495 Also fixed the (example) assignment angular code --- openslides/agenda/static/js/agenda/agenda.js | 2 +- openslides/assignment/serializers.py | 12 ++++++------ .../assignment/static/js/assignments/assignments.js | 6 +++--- .../templates/assignments/assignment-detail.html | 2 +- .../templates/assignments/assignment-form.html | 4 ++-- .../templates/assignments/assignment-list.html | 2 +- openslides/core/static/js/core.js | 8 +++++++- 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/openslides/agenda/static/js/agenda/agenda.js b/openslides/agenda/static/js/agenda/agenda.js index b720052fd..bf7c5387c 100644 --- a/openslides/agenda/static/js/agenda/agenda.js +++ b/openslides/agenda/static/js/agenda/agenda.js @@ -41,7 +41,7 @@ angular.module('OpenSlidesApp.agenda', []) }) .controller('ItemListCtrl', function($scope, Agenda, i18n) { - Agenda.bindAll($scope, 'items'); + Agenda.bindAll({}, $scope, 'items'); $scope.test_plural = i18n.ngettext('test', 'tests', 2); $scope.test_singular = i18n.ngettext('test', 'tests', 1); }) diff --git a/openslides/assignment/serializers.py b/openslides/assignment/serializers.py index b3cbfb4ea..e18569b3e 100644 --- a/openslides/assignment/serializers.py +++ b/openslides/assignment/serializers.py @@ -109,10 +109,10 @@ class AssignmentFullSerializer(ModelSerializer): model = Assignment fields = ( 'id', - 'name', + 'title', 'description', - 'posts', - 'status', + 'open_posts', + 'phase', 'related_users', 'poll_description_default', 'polls', @@ -130,10 +130,10 @@ class AssignmentShortSerializer(AssignmentFullSerializer): model = Assignment fields = ( 'id', - 'name', + 'title', 'description', - 'posts', - 'status', + 'open_posts', + 'phase', 'related_users', 'poll_description_default', 'polls', diff --git a/openslides/assignment/static/js/assignments/assignments.js b/openslides/assignment/static/js/assignments/assignments.js index 071a2976a..8cfcc3e45 100644 --- a/openslides/assignment/static/js/assignments/assignments.js +++ b/openslides/assignment/static/js/assignments/assignments.js @@ -42,17 +42,17 @@ angular.module('OpenSlidesApp.assignments', []) }) .controller('AssignmentListCtrl', function($scope, Assignment) { - Assignment.bindAll($scope, 'assignments'); + Assignment.bindAll({}, $scope, 'assignments'); }) .controller('AssignmentDetailCtrl', function($scope, Assignment, assignment) { - Assignment.bindOne($scope, 'assignment', assignment.id) + Assignment.bindOne(assignment.id, $scope, 'assignment') }) .controller('AssignmentCreateCtrl', function($scope, Assignment) { $scope.assignment = {}; $scope.save = function(assignment) { - assignment.posts = 1; + assignment.open_posts = 1; assignment.tags = []; // TODO: the rest_api should do this Assignment.create(assignment); // TODO: redirect to list-view diff --git a/openslides/assignment/static/templates/assignments/assignment-detail.html b/openslides/assignment/static/templates/assignments/assignment-detail.html index 3b2050169..b3c623b6e 100644 --- a/openslides/assignment/static/templates/assignments/assignment-detail.html +++ b/openslides/assignment/static/templates/assignments/assignment-detail.html @@ -1,2 +1,2 @@ -

{{ assignment.name }}

+

{{ assignment.title }}

{{ assignment.description }} diff --git a/openslides/assignment/static/templates/assignments/assignment-form.html b/openslides/assignment/static/templates/assignments/assignment-form.html index 9e8e15f5f..fe8700e69 100644 --- a/openslides/assignment/static/templates/assignments/assignment-form.html +++ b/openslides/assignment/static/templates/assignments/assignment-form.html @@ -1,8 +1,8 @@ -

{{ assignment.name }}

+

{{ assignment.title }}

Neue Assignment

- Titel:
+ Titel:
Beschreibung:

diff --git a/openslides/assignment/static/templates/assignments/assignment-list.html b/openslides/assignment/static/templates/assignments/assignment-list.html index b9594dccd..dc67383a2 100644 --- a/openslides/assignment/static/templates/assignments/assignment-list.html +++ b/openslides/assignment/static/templates/assignments/assignment-list.html @@ -1,6 +1,6 @@ diff --git a/openslides/core/static/js/core.js b/openslides/core/static/js/core.js index 6b9b3990b..22056ac32 100644 --- a/openslides/core/static/js/core.js +++ b/openslides/core/static/js/core.js @@ -97,8 +97,14 @@ angular.module('OpenSlidesApp.core', []) autoupdate.on_message(function(data) { // TODO: when MODEL.find() is called after this // a new request is fired. This could be a bug in DS + + // TODO: Do not send the status code to the client, but make the decission + // on the server side. It is an implementation detail, that tornado + // sends request to wsgi, which should not concern the client. if (data.status_code == 200) { - DS.inject(data.collection, data.data) + DS.inject(data.collection, data.data); + } else if (data.status_code == 404) { + DS.eject(data.collection, data.id); } // TODO: handle other statuscodes });