This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See http://git.chorem.org/pollen.git commit 6c24a40ceca7b94545d7c4769c6addb7a0ee83ec Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Mon Jun 30 17:45:51 2014 +0200 change check permission in SecurityService --- .../org/chorem/pollen/services/bean/PollBean.java | 26 ---------------------- .../pollen/services/service/PollService.java | 25 ++++++++++++--------- .../services/service/security/SecurityService.java | 24 +++++++++++--------- .../src/main/webapp/js/controllers/pollCtrl.js | 11 +++++---- .../src/main/webapp/partials/poll-settings.html | 9 ++++++++ 5 files changed, 44 insertions(+), 51 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java index 93b2f5d..80a52ed 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/PollBean.java @@ -140,7 +140,6 @@ public class PollBean extends PollenBean<Poll> { setResultVisibility(entity.getResultVisibility()); setClosed(entity.getClosed()); - setFlag(); } @Override @@ -182,8 +181,6 @@ public class PollBean extends PollenBean<Poll> { public void setPermission(String permission) { this.permission = permission; - // check new permission - setFlag(); } public String getCreatorName() { @@ -354,27 +351,4 @@ public class PollBean extends PollenBean<Poll> { this.voteIsVisible = voteIsVisible; } - protected void setFlag() { - // TODO: check CommentVisibility.VOTER - if (getPermission() != null || getCommentVisibility() == CommentVisibility.EVERYBODY) { - setCommentIsVisible(true); - } else { - setCommentIsVisible(false); - } - - // TODO: check VoteVisibility.VOTER - if ((getPermission() != null || getVoteVisibility() == VoteVisibility.EVERYBODY) && getVoteVisibility() != VoteVisibility.ANONYMOUS) { - setVoteIsVisible(true); - } else { - setVoteIsVisible(false); - } - - // TODO: check ResultVisibility.VOTER - if ( (getPermission() != null || getResultVisibility() == ResultVisibility.EVERYBODY) - && (isContinuousResults() || isClosed()) ) { - setResultIsVisible(true); - } else { - setResultIsVisible(false); - } - } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java index d7e65d3..0ed03c6 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollService.java @@ -25,10 +25,7 @@ package org.chorem.pollen.services.service; import com.google.common.base.Function; import org.apache.commons.collections4.CollectionUtils; -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.*; import org.chorem.pollen.services.bean.ChoiceBean; import org.chorem.pollen.services.bean.PaginationParameterBean; import org.chorem.pollen.services.bean.PaginationResultBean; @@ -59,7 +56,15 @@ public class PollService extends PollenServiceSupport { input.setPermission(null); input.setCreatorEmail(null); input.setCreatorName(null); + } + + input.setCommentIsVisible(isPermitted(PermissionVerb.readComment, input.getEntityId())); + + input.setVoteIsVisible(isPermitted(PermissionVerb.readVote, input.getEntityId())); + + input.setResultIsVisible(isPermitted(PermissionVerb.readPollResult, input.getEntityId())); + return input; } }; @@ -71,7 +76,7 @@ public class PollService extends PollenServiceSupport { PaginationParameter page = getPaginationParameter(paginationParameter); PaginationResult<Poll> polls = getPollDao().forAll().findPage(page); - PaginationResultBean<PollBean> pollBeans = toPaginationListBean(PollBean.class, polls); + PaginationResultBean<PollBean> pollBeans = toPaginationListBean(PollBean.class, polls, pollBeanFunction); return pollBeans; } @@ -84,7 +89,7 @@ public class PollService extends PollenServiceSupport { PaginationParameter page = getPaginationParameter(paginationParameter); PaginationResult<Poll> polls = getPollDao().findAllCreated(connectedUser, page); - PaginationResultBean<PollBean> pollBeans = toPaginationListBean(PollBean.class, polls); + PaginationResultBean<PollBean> pollBeans = toPaginationListBean(PollBean.class, polls, pollBeanFunction); return pollBeans; } @@ -97,7 +102,7 @@ public class PollService extends PollenServiceSupport { PaginationParameter page = getPaginationParameter(paginationParameter); PaginationResult<Poll> polls = getPollDao().findAllInvited(connectedUser, page); - PaginationResultBean<PollBean> pollBeans = toPaginationListBean(PollBean.class, polls); + PaginationResultBean<PollBean> pollBeans = toPaginationListBean(PollBean.class, polls, pollBeanFunction); return pollBeans; } @@ -110,7 +115,7 @@ public class PollService extends PollenServiceSupport { PaginationParameter page = getPaginationParameter(paginationParameter); PaginationResult<Poll> polls = getPollDao().findAllParticipated(connectedUser, page); - PaginationResultBean<PollBean> pollBeans = toPaginationListBean(PollBean.class, polls); + PaginationResultBean<PollBean> pollBeans = toPaginationListBean(PollBean.class, polls, pollBeanFunction); return pollBeans; } @@ -190,7 +195,7 @@ public class PollService extends PollenServiceSupport { getNotificationService().onPollEdited(savedPoll); - PollBean pollBean = toBean(PollBean.class, savedPoll); + PollBean pollBean = toBean(PollBean.class, savedPoll, pollBeanFunction); return pollBean; } @@ -236,7 +241,7 @@ public class PollService extends PollenServiceSupport { savePoll(toBean(PollBean.class, poll), null); - //TODO + //TODO : check if correct commit(); getNotificationService().onPollClosed(poll); diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java index a5d0359..6ae0d90 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java @@ -33,17 +33,7 @@ import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.subject.SimplePrincipalCollection; import org.apache.shiro.subject.Subject; -import org.chorem.pollen.persistence.entity.Choice; -import org.chorem.pollen.persistence.entity.Comment; -import org.chorem.pollen.persistence.entity.FavoriteList; -import org.chorem.pollen.persistence.entity.Poll; -import org.chorem.pollen.persistence.entity.PollenPrincipal; -import org.chorem.pollen.persistence.entity.PollenPrincipalTopiaDao; -import org.chorem.pollen.persistence.entity.PollenToken; -import org.chorem.pollen.persistence.entity.PollenTokenTopiaDao; -import org.chorem.pollen.persistence.entity.PollenUser; -import org.chorem.pollen.persistence.entity.SessionToken; -import org.chorem.pollen.persistence.entity.Vote; +import org.chorem.pollen.persistence.entity.*; import org.chorem.pollen.services.bean.PollenEntityRef; import org.chorem.pollen.services.service.PollenServiceSupport; import org.nuiton.topia.persistence.TopiaEntity; @@ -380,6 +370,18 @@ public class SecurityService extends PollenServiceSupport { permissions.add(createSubjectPermission(PermissionVerb.addVote, poll)); permissions.add(createSubjectPermission(PermissionVerb.addComment, poll)); + if (poll.getCommentVisibility() == CommentVisibility.EVERYBODY) { + permissions.add(createSubjectPermission(PermissionVerb.readComment, poll)); + } + + if (poll.getVoteVisibility() == VoteVisibility.EVERYBODY) { + permissions.add(createSubjectPermission(PermissionVerb.readVote, poll)); + } + + if (poll.getResultVisibility() == ResultVisibility.EVERYBODY && (poll.isClosed() || poll.isContinuousResults())) { + permissions.add(createSubjectPermission(PermissionVerb.readPollResult, poll)); + } + // add choices permissions List<Choice> choices = getChoiceDao().forPollEquals(poll).findAll(); 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 2fde0fe..a6820e8 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@ -96,6 +96,7 @@ angular.module('pollControllers', []) pollDeferred.promise.then(function () { var baseUrl = window.location.protocol+'//'+window.location.hostname+window.location.pathname; + $scope.globalVariables.baseUrl = baseUrl; $scope.globalVariables.linkHome = baseUrl; $scope.globalVariables.linkVote = baseUrl; $scope.globalVariables.linkComment = baseUrl; @@ -791,8 +792,8 @@ angular.module('pollControllers', []) }]) -.controller('PollVoteCtrl', ['$scope', '$rootScope', '$q', '$controller', '$routeParams', 'Poll', 'PollChoice', 'PollVote', '$translate', - function ($scope, $rootScope, $q, $controller, $routeParams, Poll, PollChoice, PollVote, $translate) { +.controller('PollVoteCtrl', ['$scope', '$rootScope', '$q', '$controller', '$routeParams', 'Poll', 'PollChoice', 'PollVote', '$translate', '$location', + function ($scope, $rootScope, $q, $controller, $routeParams, Poll, PollChoice, PollVote, $translate, $location) { $controller('PollCtrl', {$scope:$scope}); $scope.tab = $scope.setTab('vote'); @@ -875,7 +876,7 @@ angular.module('pollControllers', []) // edit vote PollVote.update({pollId:$routeParams.pollId}, sendVote, function (data) { $rootScope.$broadcast('newSuccess', 'vote.added'); - $location.url('/vote/'+$routeParams.pollId+'/'+ data.permission); + $location.url('/poll/vote/'+$routeParams.pollId+'/'+ data.permission); }, function (error) { $scope.data.vote.restError = { voterName : error.data["voter.name"]}; }) @@ -889,7 +890,9 @@ angular.module('pollControllers', []) $scope.data.votants.push(angular.copy($scope.data.vote)); $rootScope.$broadcast('newSuccess', 'vote.added'); initVote(); - $location.url('/vote/'+$routeParams.pollId+'/'+ returnRequest.permission); + + $rootScope.$on('newInfo', $scope.globalVariables.baseUrl+'#/poll/vote/'+$routeParams.pollId+'/'+ returnRequest.permission, -1); + $location.url('/poll/vote/'+$routeParams.pollId+'/'+ returnRequest.permission); }, function (error) { $scope.data.vote.restError = { voterName : error.data["voter.name"]}; }); diff --git a/pollen-ui-angular/src/main/webapp/partials/poll-settings.html b/pollen-ui-angular/src/main/webapp/partials/poll-settings.html index 960d5c7..06d4df7 100644 --- a/pollen-ui-angular/src/main/webapp/partials/poll-settings.html +++ b/pollen-ui-angular/src/main/webapp/partials/poll-settings.html @@ -159,4 +159,13 @@ <button class="btn btn-default" ng-model="data.poll.anonymousVoteAllowed" btn-radio="false" auto-save="autoSavePoll()">Non</button> </div> </div> + + <div class="form-group"> + <label class="col-sm-4 control-label">Visibiliter des commentaires :</label> + <div class="col-sm-8"> + <label><input type="radio" ng-model="data.poll.commentVisibility" name="commentVisibility" value="EVERYBODY" auto-save="autoSavePoll()" /> Public</label> + <label><input type="radio" ng-model="data.poll.commentVisibility" name="commentVisibility" value="VOTER" auto-save="autoSavePoll()" /> Participants</label> + <label><input type="radio" ng-model="data.poll.commentVisibility" name="commentVisibility" value="NOBODY" auto-save="autoSavePoll()" /> Personne</label> + </div> + </div> </form> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.