Merge pull request #3051 from emanuelschuetze/issues-2142
Excluded already elected persons for new ballot (Fixed #2142)
This commit is contained in:
commit
c6ced4e4a0
@ -272,7 +272,7 @@ class Assignment(RESTModelMixin, models.Model):
|
||||
description=self.poll_description_default,
|
||||
pollmethod=pollmethod)
|
||||
options = []
|
||||
related_users = AssignmentRelatedUser.objects.filter(assignment__id=self.id)
|
||||
related_users = AssignmentRelatedUser.objects.filter(assignment__id=self.id).exclude(elected=True)
|
||||
for related_user in related_users:
|
||||
options.append({
|
||||
'candidate': related_user.user,
|
||||
|
@ -405,6 +405,7 @@ angular.module('OpenSlidesApp.assignments.site', [
|
||||
'$scope',
|
||||
'$http',
|
||||
'$filter',
|
||||
'$timeout',
|
||||
'filterFilter',
|
||||
'gettext',
|
||||
'ngDialog',
|
||||
@ -423,7 +424,7 @@ angular.module('OpenSlidesApp.assignments.site', [
|
||||
'PdfCreate',
|
||||
'AssignmentPhases',
|
||||
'ErrorMessage',
|
||||
function($scope, $http, $filter, filterFilter, gettext, ngDialog, AssignmentForm, operator, Assignment,
|
||||
function($scope, $http, $filter, $timeout, filterFilter, gettext, ngDialog, AssignmentForm, operator, Assignment,
|
||||
User, assignmentId, Projector, ProjectionDefault, AssignmentContentProvider, BallotContentProvider,
|
||||
PdfMakeDocumentProvider, PdfMakeBallotPaperProvider, gettextCatalog, PdfCreate, AssignmentPhases,
|
||||
ErrorMessage) {
|
||||
@ -448,7 +449,7 @@ angular.module('OpenSlidesApp.assignments.site', [
|
||||
$scope.candidateSelectBox = {};
|
||||
$scope.phases = AssignmentPhases;
|
||||
$scope.alert = {};
|
||||
$scope.activeTab = 0;
|
||||
$scope.activeTab = assignment.polls.length - 1;
|
||||
|
||||
// open edit dialog
|
||||
$scope.openDialog = function (assignment) {
|
||||
@ -527,20 +528,30 @@ angular.module('OpenSlidesApp.assignments.site', [
|
||||
};
|
||||
// create new ballot
|
||||
$scope.createBallot = function () {
|
||||
$scope.activeTab = 0;
|
||||
$http.post('/rest/assignments/assignment/' + assignment.id + '/create_poll/').then(
|
||||
function (success) {
|
||||
$scope.alert.show = false;
|
||||
if (assignment.phase === 0) {
|
||||
$scope.updatePhase(1);
|
||||
}
|
||||
// set 'activeTab' to recently added (last) ballot tab
|
||||
// TODO: $timeout is required, see
|
||||
// https://github.com/angular-ui/bootstrap/issues/5656
|
||||
$timeout(function() {
|
||||
$scope.activeTab = assignment.polls.length - 1;
|
||||
}, 0);
|
||||
}, function (error) {
|
||||
$scope.alert = ErrorMessage.forAlert(error);
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
// delete ballot
|
||||
$scope.deleteBallot = function (poll) {
|
||||
poll.DSDestroy();
|
||||
poll.DSDestroy().then(
|
||||
function (success) {
|
||||
$scope.activeTab = assignment.polls.length - 1;
|
||||
}
|
||||
);
|
||||
};
|
||||
// edit poll dialog
|
||||
$scope.editPollDialog = function (poll, ballot) {
|
||||
@ -582,16 +593,7 @@ angular.module('OpenSlidesApp.assignments.site', [
|
||||
}
|
||||
);
|
||||
} else {
|
||||
$http.post('/rest/assignments/assignment/' + assignment.id + '/mark_elected/', {'user': user})
|
||||
.then(function(success) {
|
||||
var elected = filterFilter(assignment.assignment_related_users,{elected: true});
|
||||
// Set phase to 'finished' if there are enough (= number of open posts) elected users.
|
||||
// Note: The array 'elected' does NOT contains the candidate who is just marked as elected.
|
||||
// So add 1 to length to get the real number of all elected users.
|
||||
if (elected.length + 1 == assignment.open_posts ) {
|
||||
$scope.updatePhase(2);
|
||||
}
|
||||
});
|
||||
$http.post('/rest/assignments/assignment/' + assignment.id + '/mark_elected/', {'user': user});
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -126,10 +126,9 @@
|
||||
<i class="fa fa-bar-chart fa-lg"></i>
|
||||
<translate>New ballot</translate>
|
||||
</button>
|
||||
|
||||
<uib-tabset ng-if="assignment.polls.length > 0" class="spacer ballot-tabs" active="activeTab">
|
||||
<uib-tab ng-repeat="poll in assignment.polls | orderBy:'-id'"
|
||||
index="$index" heading="{{ 'Ballot' | translate }} {{ assignment.polls.length - $index }}">
|
||||
<uib-tab ng-repeat="poll in assignment.polls | orderBy:'id'"
|
||||
index="$index" heading="{{ 'Ballot' | translate }} {{ $index + 1 }}">
|
||||
<div ng-controller="AssignmentPollDetailCtrl">
|
||||
<!-- action buttons -->
|
||||
<div class="pull-right" os-perms="assignments.can_manage">
|
||||
|
Loading…
Reference in New Issue
Block a user