[pollen] branch feature/permissionPollRestricted updated (52a6ea2 -> 2e4da27)
This is an automated email from the git hooks/post-receive script. New change to branch feature/permissionPollRestricted in repository pollen. See http://git.chorem.org/pollen.git from 52a6ea2 fix route in edit poll, fix style title in poll settings new be365f5 Add getNewVote in rest-api and improve it in service new 8694ab2 get voterId and voterListMemberId for new vote new 2e4da27 redirect if not admin in user list, fix edit vote The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 2e4da276dd2a94e2ed376da42a611b7d51cc88ba Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Aug 6 16:24:27 2014 +0200 redirect if not admin in user list, fix edit vote commit 8694ab2ab9b3419a1ae0b5695b501c980be2e2fd Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Aug 6 16:00:06 2014 +0200 get voterId and voterListMemberId for new vote commit be365f54f47c040a6a5fcae2503561aaacdbebff Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Aug 6 14:54:37 2014 +0200 Add getNewVote in rest-api and improve it in service Summary of changes: .../org/chorem/pollen/rest/api/v1/VoteApi.java | 4 +-- pollen-rest-api/src/main/resources/mapping | 2 +- .../pollen/services/service/VoteService.java | 20 ++++++------ pollen-ui-angular/src/main/webapp/js/app.js | 5 +-- .../src/main/webapp/js/controllers/pollCtrl.js | 36 +++++++++------------- .../src/main/webapp/js/controllers/userCtrl.js | 9 ++++-- pollen-ui-angular/src/main/webapp/js/services.js | 4 +++ 7 files changed, 41 insertions(+), 39 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/permissionPollRestricted in repository pollen. See http://git.chorem.org/pollen.git commit be365f54f47c040a6a5fcae2503561aaacdbebff Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Aug 6 14:54:37 2014 +0200 Add getNewVote in rest-api and improve it in service --- .../java/org/chorem/pollen/rest/api/v1/VoteApi.java | 4 ++-- pollen-rest-api/src/main/resources/mapping | 2 +- .../chorem/pollen/services/service/VoteService.java | 20 +++++++++++--------- pollen-ui-angular/src/main/webapp/js/app.js | 1 + 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteApi.java b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteApi.java index 938bccd..99f14d5 100644 --- a/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteApi.java +++ b/pollen-rest-api/src/main/java/org/chorem/pollen/rest/api/v1/VoteApi.java @@ -42,9 +42,9 @@ import java.util.List; */ public class VoteApi extends WebMotionController { - public VoteBean getNewVote(VoteService voteService) { + public VoteBean getNewVote(VoteService voteService, PollenEntityId<Poll> pollId) { - VoteBean newVote = voteService.getNewVote(); + VoteBean newVote = voteService.getNewVote(pollId.getEntityId()); return newVote; } diff --git a/pollen-rest-api/src/main/resources/mapping b/pollen-rest-api/src/main/resources/mapping index 655b776..f219150 100644 --- a/pollen-rest-api/src/main/resources/mapping +++ b/pollen-rest-api/src/main/resources/mapping @@ -164,7 +164,7 @@ DELETE /v1/polls/{pollId}/voterLists/{voterListId}/members/{memberId} Vote # VoteApi GET /v1/polls/{pollId}/votes VoteApi.getVotes -GET /v1/polls/{pollId}/votes/add VoteApi.addVote +GET /v1/polls/{pollId}/votes/new VoteApi.getNewVote GET /v1/polls/{pollId}/votes/{voteId}/edit VoteApi.editVote POST /v1/polls/{pollId}/votes VoteApi.addVote GET /v1/polls/{pollId}/votes/{voteId} VoteApi.getVote diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java index 4096c22..6367201 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/VoteService.java @@ -26,14 +26,7 @@ package org.chorem.pollen.services.service; import com.google.common.base.Function; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.chorem.pollen.persistence.entity.Choice; -import org.chorem.pollen.persistence.entity.Poll; -import org.chorem.pollen.persistence.entity.PollenPrincipal; -import org.chorem.pollen.persistence.entity.PollenUser; -import org.chorem.pollen.persistence.entity.Polls; -import org.chorem.pollen.persistence.entity.Vote; -import org.chorem.pollen.persistence.entity.VoteToChoice; -import org.chorem.pollen.persistence.entity.VoteToChoiceTopiaDao; +import org.chorem.pollen.persistence.entity.*; import org.chorem.pollen.services.bean.PollenEntityRef; import org.chorem.pollen.services.bean.VoteBean; import org.chorem.pollen.services.bean.VoteToChoiceBean; @@ -59,9 +52,11 @@ public class VoteService extends PollenServiceSupport { } }; - public VoteBean getNewVote() { + public VoteBean getNewVote(String pollId) { + checkPermission(PermissionVerb.addVote, pollId); VoteBean voteBean = new VoteBean(); + voteBean.setWeight(1d); PollenUser connectedUser = getConnectedUser(); @@ -70,6 +65,13 @@ public class VoteService extends PollenServiceSupport { voteBean.setVoterName(connectedUser.getName()); voteBean.setVoterId(connectedUser.getTopiaId()); + VoterListMember voterListMember = getVoterListMemberDao().forEquals(VoterListMember.PROPERTY_MEMBER+"."+PollenPrincipal.PROPERTY_POLLEN_USER+"."+PollenUser.PROPERTY_TOPIA_ID, connectedUser.getTopiaId()) + .addEquals(VoterListMember.PROPERTY_VOTER_LIST+"."+VoterList.PROPERTY_POLL+"."+Poll.PROPERTY_TOPIA_ID, pollId) + .findUniqueOrNull(); + if (voterListMember != null) { + voteBean.setVoterListMemberId(voterListMember.getTopiaId()); + voteBean.setWeight(voterListMember.getWeight()); + } } return voteBean; diff --git a/pollen-ui-angular/src/main/webapp/js/app.js b/pollen-ui-angular/src/main/webapp/js/app.js index 2e95217..bdc23a3 100644 --- a/pollen-ui-angular/src/main/webapp/js/app.js +++ b/pollen-ui-angular/src/main/webapp/js/app.js @@ -60,6 +60,7 @@ angular.module('pollen', ['pollenDirective', 'pollenServices', 'ngRoute', 'Polle .config(['$routeProvider', function($routeProvider) { $routeProvider.when('/', {templateUrl: './partials/home.html', controller: "HomeCtrl"}) .when('/poll/create/:tab?', {templateUrl: './partials/poll.html', controller: "PollCreateCtrl"}) + .when('/poll/edit/:pollId/:pollToken?', {templateUrl: './partials/poll.html', controller:"PollCtrl"}) .when('/poll/edit/:pollId/:pollToken?/tab/:tab?', {templateUrl: './partials/poll.html', controller:"PollCtrl"}) .when('/poll/vote/:pollId/:pollToken?', {templateUrl: './partials/poll.html', controller :"PollCtrl"}) .when('/poll/vote/:pollId/:pollToken?/vote/:voteToken', {templateUrl: './partials/poll.html', controller :"PollCtrl"}) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/permissionPollRestricted in repository pollen. See http://git.chorem.org/pollen.git commit 8694ab2ab9b3419a1ae0b5695b501c980be2e2fd Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Aug 6 16:00:06 2014 +0200 get voterId and voterListMemberId for new vote --- pollen-ui-angular/src/main/webapp/js/app.js | 4 --- .../src/main/webapp/js/controllers/pollCtrl.js | 29 +++++++++++----------- pollen-ui-angular/src/main/webapp/js/services.js | 4 +++ 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/pollen-ui-angular/src/main/webapp/js/app.js b/pollen-ui-angular/src/main/webapp/js/app.js index bdc23a3..6e9954c 100644 --- a/pollen-ui-angular/src/main/webapp/js/app.js +++ b/pollen-ui-angular/src/main/webapp/js/app.js @@ -48,10 +48,6 @@ angular.module('pollen', ['pollenDirective', 'pollenServices', 'ngRoute', 'Polle //error login or sessionToken $rootScope.$broadcast('sessionExpired'); } - if (response.status === 403) { - //access forbidden - $location.path('/'); - } return $q.reject(response); } }; diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js index 704b3d1..dd0384d 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -130,6 +130,10 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr pollDeferred.resolve('bad token') }, function (error) { + if (error.status == 403) { + $rootScope.$broadcast('newError', 'error.forbidden'); + $location.path("/"); + } pollDeferred.reject(error); }); }); @@ -1125,18 +1129,20 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr $scope.globalVariables.voteMode = true; var initVote = function () { - $scope.data.vote = {}; - $scope.data.vote.voterName = ""; - initAuthor(); - $scope.data.vote.anonymous = false; - $scope.data.vote.choice = []; + PollVote.skeletonNew({pollId:$routeParams.pollId}, function (data) { + $scope.data.vote = data; - var defaultValue = ($scope.voteCountingIsBoolean()) ? false : null; + initAuthor(); - for (var i = 0; i < $scope.data.choices.length; ++i) { + var defaultValue = ($scope.voteCountingIsBoolean()) ? false : null; - $scope.data.vote.choice.push({'choiceId':$scope.data.choices[i].id, 'voteValue': defaultValue}); - } + for (var i = 0; i < $scope.data.choices.length; ++i) { + + $scope.data.vote.choice.push({'choiceId':$scope.data.choices[i].id, 'voteValue': defaultValue}); + } + }, function (error) { + $scope.data.poll.canVote = false; + }); } $scope.voter = function () { @@ -1154,11 +1160,6 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr } PollVote.add({pollId:$routeParams.pollId, permission:$scope.globalVariables.pollToken}, sendVote, function (returnRequest) { - - if ($scope.data.poll.pollType != 'FREE') { - $scope.data.poll.canVote = false; - } - $scope.data.vote.id = returnRequest.id; $scope.data.vote.permission = returnRequest.permission; diff --git a/pollen-ui-angular/src/main/webapp/js/services.js b/pollen-ui-angular/src/main/webapp/js/services.js index 2f1b45d..6be865b 100644 --- a/pollen-ui-angular/src/main/webapp/js/services.js +++ b/pollen-ui-angular/src/main/webapp/js/services.js @@ -102,6 +102,10 @@ angular.module('pollenServices', ['ngResource']) return $resource(conf.restURL+'/polls/:pollId/votes/:voteId', {voteId : '@id', permission : '@permission'}, { + 'skeletonNew': { + method:'GET', + url:conf.restURL+'/polls/:pollId/votes/new' + }, 'add' : { method:'POST', transformRequest : function (data, headersGetter) { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/permissionPollRestricted in repository pollen. See http://git.chorem.org/pollen.git commit 2e4da276dd2a94e2ed376da42a611b7d51cc88ba Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Wed Aug 6 16:24:27 2014 +0200 redirect if not admin in user list, fix edit vote --- pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js | 7 ------- pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js | 9 +++++++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js index dd0384d..3022d8e 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -1163,12 +1163,6 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr $scope.data.vote.id = returnRequest.id; $scope.data.vote.permission = returnRequest.permission; - angular.forEach($scope.data.vote.choice, function (choice) { - if (choice.voteValue == "") { - delete choice.voteValue; - } - }); - PollVote.get({pollId:$routeParams.pollId, voteId:returnRequest.id, permission:returnRequest.permission}, function (newVote) { angular.forEach(newVote.choice, function (choice) { choice.voteValue = $scope.getVoteValue(choice.voteValue); @@ -1267,7 +1261,6 @@ angular.module('pollControllers', ['ngRoute', 'pollenServices', 'pascalprecht.tr } } - delete $scope.data.vote.restError; $rootScope.$broadcast('newSuccess', 'vote.added'); $location.url('/poll/vote/'+$routeParams.pollId+'/'+ data.permission); }, function (error) { diff --git a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js index 1d06329..9e8984b 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js @@ -133,8 +133,8 @@ angular.module('userControllers', []) } }]) -.controller('UserListCtrl', ['$scope', '$rootScope', '$routeParams', 'User', 'UserLostPassword', 'Page', - function ($scope, $rootScope, $routeParams, User, UserLostPassword, Page) { +.controller('UserListCtrl', ['$scope', '$rootScope', '$location', '$routeParams', 'User', 'UserLostPassword', 'Page', + function ($scope, $rootScope, $location, $routeParams, User, UserLostPassword, Page) { Page.setTitle('title.user.list'); @@ -162,6 +162,11 @@ angular.module('userControllers', []) User.get({paginationParameter:paginationParameter}, function (data) { $scope.data.users = data.elements; $scope.data.usersPagination = data.pagination + }, function (error) { + if (error.status == 403) { + $rootScope.$broadcast('newError', 'error.forbidden'); + $location.url('/'); + } }); $scope.saveUser = function (user) { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm