From 6b8aa56e8786de57a0303789e361982613f8bdc6 Mon Sep 17 00:00:00 2001 From: Emanuel Schuetze Date: Fri, 18 Dec 2015 20:18:03 +0100 Subject: [PATCH] Fix publish assignment poll function. Set 'votes' to required=False in AssignmentAllPollSerializer. --- openslides/assignments/serializers.py | 3 ++- .../assignments/static/js/assignments/site.js | 27 ++++++++++++------- .../assignments/assignment-detail.html | 16 +++++------ 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/openslides/assignments/serializers.py b/openslides/assignments/serializers.py index 65229cd57..9a6766e9c 100644 --- a/openslides/assignments/serializers.py +++ b/openslides/assignments/serializers.py @@ -79,7 +79,8 @@ class AssignmentAllPollSerializer(ModelSerializer): votes = ListField( child=DictField( child=IntegerField(min_value=-2)), - write_only=True) + write_only=True, + required=False) class Meta: model = AssignmentPoll diff --git a/openslides/assignments/static/js/assignments/site.js b/openslides/assignments/static/js/assignments/site.js index 67d22f165..087fd7954 100644 --- a/openslides/assignments/static/js/assignments/site.js +++ b/openslides/assignments/static/js/assignments/site.js @@ -235,12 +235,13 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) .controller('AssignmentDetailCtrl', [ '$scope', '$http', + 'gettext', 'ngDialog', 'operator', 'Assignment', 'User', 'assignment', - function($scope, $http, ngDialog, operator, Assignment, User, assignment) { + function($scope, $http, gettext, ngDialog, operator, Assignment, User, assignment) { User.bindAll({}, $scope, 'users'); Assignment.bindOne(assignment.id, $scope, 'assignment'); Assignment.loadRelations(assignment, 'agenda_item'); @@ -336,15 +337,21 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments']) }); }; // publish ballot - $scope.publishBallot = function () { - // TODO poll.DSUpdate() - $http.put('/rest/assignments/assignment/' + assignment.id + '/publish_poll/') - .success(function(data){ - $scope.alert.show = false; - }) - .error(function(data){ - $scope.alert = { type: 'danger', msg: data.detail, show: true }; - }); + $scope.publishBallot = function (poll, isPublished) { + poll.DSUpdate({ + assignment_id: assignment.id, + published: isPublished, + }) + .then(function(success) { + $scope.alert.show = false; + }) + .catch(function(error) { + var message = ''; + for (var e in error.data) { + message += e + ': ' + error.data[e] + ' '; + } + $scope.alert = { type: 'danger', msg: message, show: true }; + }); }; // Just mark some vote value strings for translation. diff --git a/openslides/assignments/static/templates/assignments/assignment-detail.html b/openslides/assignments/static/templates/assignments/assignment-detail.html index 3ed3fc330..5a6c417db 100644 --- a/openslides/assignments/static/templates/assignments/assignment-detail.html +++ b/openslides/assignments/static/templates/assignments/assignment-detail.html @@ -97,15 +97,15 @@ class="btn btn-default btn-sm"> Ballot paper - - +