Merge pull request #1778 from emanuelschuetze/fix1718
Fix publish assignment poll function. (Fixes#1718)
This commit is contained in:
commit
c63bd31db0
@ -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,14 +337,20 @@ 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,
|
||||||
|
})
|
||||||
|
.then(function(success) {
|
||||||
$scope.alert.show = false;
|
$scope.alert.show = false;
|
||||||
})
|
})
|
||||||
.error(function(data){
|
.catch(function(error) {
|
||||||
$scope.alert = { type: 'danger', msg: data.detail, show: true };
|
var message = '';
|
||||||
|
for (var e in error.data) {
|
||||||
|
message += e + ': ' + error.data[e] + ' ';
|
||||||
|
}
|
||||||
|
$scope.alert = { type: 'danger', msg: message, show: true };
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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