Fix publish assignment poll function.
Set 'votes' to required=False in AssignmentAllPollSerializer.
This commit is contained in:
parent
99b4e8c494
commit
6b8aa56e87
@ -79,7 +79,8 @@ class AssignmentAllPollSerializer(ModelSerializer):
|
|||||||
votes = ListField(
|
votes = ListField(
|
||||||
child=DictField(
|
child=DictField(
|
||||||
child=IntegerField(min_value=-2)),
|
child=IntegerField(min_value=-2)),
|
||||||
write_only=True)
|
write_only=True,
|
||||||
|
required=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = AssignmentPoll
|
model = AssignmentPoll
|
||||||
|
@ -235,12 +235,13 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
|
|||||||
.controller('AssignmentDetailCtrl', [
|
.controller('AssignmentDetailCtrl', [
|
||||||
'$scope',
|
'$scope',
|
||||||
'$http',
|
'$http',
|
||||||
|
'gettext',
|
||||||
'ngDialog',
|
'ngDialog',
|
||||||
'operator',
|
'operator',
|
||||||
'Assignment',
|
'Assignment',
|
||||||
'User',
|
'User',
|
||||||
'assignment',
|
'assignment',
|
||||||
function($scope, $http, ngDialog, operator, Assignment, User, assignment) {
|
function($scope, $http, gettext, ngDialog, operator, Assignment, User, assignment) {
|
||||||
User.bindAll({}, $scope, 'users');
|
User.bindAll({}, $scope, 'users');
|
||||||
Assignment.bindOne(assignment.id, $scope, 'assignment');
|
Assignment.bindOne(assignment.id, $scope, 'assignment');
|
||||||
Assignment.loadRelations(assignment, 'agenda_item');
|
Assignment.loadRelations(assignment, 'agenda_item');
|
||||||
@ -336,15 +337,21 @@ angular.module('OpenSlidesApp.assignments.site', ['OpenSlidesApp.assignments'])
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
// publish ballot
|
// publish ballot
|
||||||
$scope.publishBallot = function () {
|
$scope.publishBallot = function (poll, isPublished) {
|
||||||
// TODO poll.DSUpdate()
|
poll.DSUpdate({
|
||||||
$http.put('/rest/assignments/assignment/' + assignment.id + '/publish_poll/')
|
assignment_id: assignment.id,
|
||||||
.success(function(data){
|
published: isPublished,
|
||||||
$scope.alert.show = false;
|
})
|
||||||
})
|
.then(function(success) {
|
||||||
.error(function(data){
|
$scope.alert.show = false;
|
||||||
$scope.alert = { type: 'danger', msg: data.detail, show: true };
|
})
|
||||||
});
|
.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.
|
// Just mark some vote value strings for translation.
|
||||||
|
@ -97,15 +97,15 @@
|
|||||||
class="btn btn-default btn-sm">
|
class="btn btn-default btn-sm">
|
||||||
<i class="fa fa-file-pdf-o"></i> Ballot paper
|
<i class="fa fa-file-pdf-o"></i> Ballot paper
|
||||||
</a>
|
</a>
|
||||||
<button os-perms-lite="assignments.can_manage" ng-if="!poll.published" ng-click="publishBallot(poll)"
|
<button os-perms-lite="assignments.can_manage" ng-if="!poll.published" ng-click="publishBallot(poll, true)"
|
||||||
class="btn btn-primary btn-sm">
|
|
||||||
<i class="fa fa-globe"></i>
|
|
||||||
<translate>Publish result</translate>
|
|
||||||
</button>
|
|
||||||
<button os-perms-lite="assignments.can_manage" ng-if="poll.published" ng-click="unpublishBallot(poll)"
|
|
||||||
class="btn btn-default btn-sm">
|
class="btn btn-default btn-sm">
|
||||||
<i class="fa fa-globe"></i>
|
<i class="fa fa-toggle-off"></i>
|
||||||
<translate>Unpublish result</translate>
|
<translate>Not published</translate>
|
||||||
|
</button>
|
||||||
|
<button os-perms-lite="assignments.can_manage" ng-if="poll.published" ng-click="publishBallot(poll, false)"
|
||||||
|
class="btn btn-default btn-sm">
|
||||||
|
<i class="fa fa-toggle-on"></i>
|
||||||
|
<translate>Published</translate>
|
||||||
</button>
|
</button>
|
||||||
<a ng-click="deleteBallot(poll)" class="btn btn-default btn-sm">
|
<a ng-click="deleteBallot(poll)" class="btn btn-default btn-sm">
|
||||||
<i class="fa fa-times"></i>
|
<i class="fa fa-times"></i>
|
||||||
|
Loading…
Reference in New Issue
Block a user