Excluded already elected persons for new ballot (Fixed #2142)
- Reorder assignment ballot tabs in detail template. - Removed logic to set phase automatically to 'finished' if elected candidates reached, because autoupdate makes it unreliable.
This commit is contained in:
parent
95c19159f8
commit
ff840ab3c6
@ -272,7 +272,7 @@ class Assignment(RESTModelMixin, models.Model):
|
|||||||
description=self.poll_description_default,
|
description=self.poll_description_default,
|
||||||
pollmethod=pollmethod)
|
pollmethod=pollmethod)
|
||||||
options = []
|
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:
|
for related_user in related_users:
|
||||||
options.append({
|
options.append({
|
||||||
'candidate': related_user.user,
|
'candidate': related_user.user,
|
||||||
|
@ -405,6 +405,7 @@ angular.module('OpenSlidesApp.assignments.site', [
|
|||||||
'$scope',
|
'$scope',
|
||||||
'$http',
|
'$http',
|
||||||
'$filter',
|
'$filter',
|
||||||
|
'$timeout',
|
||||||
'filterFilter',
|
'filterFilter',
|
||||||
'gettext',
|
'gettext',
|
||||||
'ngDialog',
|
'ngDialog',
|
||||||
@ -423,7 +424,7 @@ angular.module('OpenSlidesApp.assignments.site', [
|
|||||||
'PdfCreate',
|
'PdfCreate',
|
||||||
'AssignmentPhases',
|
'AssignmentPhases',
|
||||||
'ErrorMessage',
|
'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,
|
User, assignmentId, Projector, ProjectionDefault, AssignmentContentProvider, BallotContentProvider,
|
||||||
PdfMakeDocumentProvider, PdfMakeBallotPaperProvider, gettextCatalog, PdfCreate, AssignmentPhases,
|
PdfMakeDocumentProvider, PdfMakeBallotPaperProvider, gettextCatalog, PdfCreate, AssignmentPhases,
|
||||||
ErrorMessage) {
|
ErrorMessage) {
|
||||||
@ -448,7 +449,7 @@ angular.module('OpenSlidesApp.assignments.site', [
|
|||||||
$scope.candidateSelectBox = {};
|
$scope.candidateSelectBox = {};
|
||||||
$scope.phases = AssignmentPhases;
|
$scope.phases = AssignmentPhases;
|
||||||
$scope.alert = {};
|
$scope.alert = {};
|
||||||
$scope.activeTab = 0;
|
$scope.activeTab = assignment.polls.length - 1;
|
||||||
|
|
||||||
// open edit dialog
|
// open edit dialog
|
||||||
$scope.openDialog = function (assignment) {
|
$scope.openDialog = function (assignment) {
|
||||||
@ -527,20 +528,30 @@ angular.module('OpenSlidesApp.assignments.site', [
|
|||||||
};
|
};
|
||||||
// create new ballot
|
// create new ballot
|
||||||
$scope.createBallot = function () {
|
$scope.createBallot = function () {
|
||||||
$scope.activeTab = 0;
|
|
||||||
$http.post('/rest/assignments/assignment/' + assignment.id + '/create_poll/').then(
|
$http.post('/rest/assignments/assignment/' + assignment.id + '/create_poll/').then(
|
||||||
function (success) {
|
function (success) {
|
||||||
$scope.alert.show = false;
|
$scope.alert.show = false;
|
||||||
if (assignment.phase === 0) {
|
if (assignment.phase === 0) {
|
||||||
$scope.updatePhase(1);
|
$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) {
|
}, function (error) {
|
||||||
$scope.alert = ErrorMessage.forAlert(error);
|
$scope.alert = ErrorMessage.forAlert(error);
|
||||||
});
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
// delete ballot
|
// delete ballot
|
||||||
$scope.deleteBallot = function (poll) {
|
$scope.deleteBallot = function (poll) {
|
||||||
poll.DSDestroy();
|
poll.DSDestroy().then(
|
||||||
|
function (success) {
|
||||||
|
$scope.activeTab = assignment.polls.length - 1;
|
||||||
|
}
|
||||||
|
);
|
||||||
};
|
};
|
||||||
// edit poll dialog
|
// edit poll dialog
|
||||||
$scope.editPollDialog = function (poll, ballot) {
|
$scope.editPollDialog = function (poll, ballot) {
|
||||||
@ -582,16 +593,7 @@ angular.module('OpenSlidesApp.assignments.site', [
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$http.post('/rest/assignments/assignment/' + assignment.id + '/mark_elected/', {'user': user})
|
$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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -126,10 +126,9 @@
|
|||||||
<i class="fa fa-bar-chart fa-lg"></i>
|
<i class="fa fa-bar-chart fa-lg"></i>
|
||||||
<translate>New ballot</translate>
|
<translate>New ballot</translate>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<uib-tabset ng-if="assignment.polls.length > 0" class="spacer ballot-tabs" active="activeTab">
|
<uib-tabset ng-if="assignment.polls.length > 0" class="spacer ballot-tabs" active="activeTab">
|
||||||
<uib-tab ng-repeat="poll in assignment.polls | orderBy:'-id'"
|
<uib-tab ng-repeat="poll in assignment.polls | orderBy:'id'"
|
||||||
index="$index" heading="{{ 'Ballot' | translate }} {{ assignment.polls.length - $index }}">
|
index="$index" heading="{{ 'Ballot' | translate }} {{ $index + 1 }}">
|
||||||
<div ng-controller="AssignmentPollDetailCtrl">
|
<div ng-controller="AssignmentPollDetailCtrl">
|
||||||
<!-- action buttons -->
|
<!-- action buttons -->
|
||||||
<div class="pull-right" os-perms="assignments.can_manage">
|
<div class="pull-right" os-perms="assignments.can_manage">
|
||||||
|
Loading…
Reference in New Issue
Block a user