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 90618ddeb..7b14328df 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 - - +