[pollen] branch feature/adminUser updated (0074cdd -> b34d2c1)
This is an automated email from the git hooks/post-receive script. New change to branch feature/adminUser in repository pollen. See http://git.chorem.org/pollen.git from 0074cdd can give the admin right at an user in user-list new b34d2c1 add method to anonymize User The 1 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 b34d2c17b1f23ce42dfc2da8dca79d3cd1989aee Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Jul 22 11:48:32 2014 +0200 add method to anonymize User Summary of changes: .../pollen/services/service/PollenUserService.java | 29 +++++++++++++++++++--- pollen-ui-angular/src/main/webapp/i18n/en.js | 1 + pollen-ui-angular/src/main/webapp/i18n/fr.js | 1 + .../src/main/webapp/js/controllers/userCtrl.js | 9 +++++++ .../src/main/webapp/partials/user-admin-list.html | 2 +- 5 files changed, 38 insertions(+), 4 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/adminUser in repository pollen. See http://git.chorem.org/pollen.git commit b34d2c17b1f23ce42dfc2da8dca79d3cd1989aee Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Tue Jul 22 11:48:32 2014 +0200 add method to anonymize User --- .../pollen/services/service/PollenUserService.java | 29 +++++++++++++++++++--- pollen-ui-angular/src/main/webapp/i18n/en.js | 1 + pollen-ui-angular/src/main/webapp/i18n/fr.js | 1 + .../src/main/webapp/js/controllers/userCtrl.js | 9 +++++++ .../src/main/webapp/partials/user-admin-list.html | 2 +- 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java index d30fb32..a15f3d1 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/PollenUserService.java @@ -25,9 +25,7 @@ package org.chorem.pollen.services.service; import com.google.common.base.Function; import org.apache.commons.lang3.ObjectUtils; -import org.chorem.pollen.persistence.entity.PollenToken; -import org.chorem.pollen.persistence.entity.PollenUser; -import org.chorem.pollen.persistence.entity.PollenUserTopiaDao; +import org.chorem.pollen.persistence.entity.*; import org.chorem.pollen.services.PollenService; import org.chorem.pollen.services.bean.PaginationParameterBean; import org.chorem.pollen.services.bean.PollenEntityRef; @@ -38,6 +36,7 @@ import org.chorem.pollen.services.service.security.PollenInvalidPasswordExceptio import org.nuiton.util.pagination.PaginationParameter; import org.nuiton.util.pagination.PaginationResult; +import java.util.List; import java.util.Objects; import static org.nuiton.i18n.I18n.l; @@ -135,9 +134,12 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer public void deleteUser(String userId) { checkNotNull(userId); + checkIsAdmin(); PollenUser user = getUser0(userId); + anonymizeUser(user); + getPollenUserDao().delete(user); commit(); @@ -339,4 +341,25 @@ public class PollenUserService extends PollenServiceSupport implements PollenSer return parameter; } + + protected void anonymizeUser(PollenUser user) { + PollenPrincipal anonymousUser = getSecurityService().generatePollenPrincipal(); + anonymousUser.setName("?"); + + + List<Vote> votesUser = getVoteDao().forEquals(Vote.PROPERTY_VOTER + "." + PollenPrincipal.PROPERTY_POLLEN_USER, user).findAll(); + + for (Vote vote: votesUser) { + vote.setVoter(anonymousUser); + } + + List<Comment> commentsUser = getCommentDao().forEquals(Comment.PROPERTY_AUTHOR + "." + PollenPrincipal.PROPERTY_POLLEN_USER, user).findAll(); + + for (Comment comment: commentsUser) { + comment.setAuthor(anonymousUser); + } + + commit(); + + } } diff --git a/pollen-ui-angular/src/main/webapp/i18n/en.js b/pollen-ui-angular/src/main/webapp/i18n/en.js index 71dd0dc..91c302b 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/en.js +++ b/pollen-ui-angular/src/main/webapp/i18n/en.js @@ -44,6 +44,7 @@ var translateEN = { 'user.error.login' : 'Error in e-mail or password', 'user.error.login.mandatory' : 'You must be connected', 'user.error.logout.mandatory' : 'You must be disconnected', +'user.error.listEmpty' : 'No user found', 'poll.tab.vote' : 'Vote', 'poll.tab.comment' : 'Comment', diff --git a/pollen-ui-angular/src/main/webapp/i18n/fr.js b/pollen-ui-angular/src/main/webapp/i18n/fr.js index acaa9cf..7eec45b 100644 --- a/pollen-ui-angular/src/main/webapp/i18n/fr.js +++ b/pollen-ui-angular/src/main/webapp/i18n/fr.js @@ -44,6 +44,7 @@ var translateFR = { 'user.error.login' : 'Erreur sur le nom d\'utilisateur ou le mot de passe', 'user.error.login.mandatory' : 'Accès refusé, vous devez êtes connecté(e)', 'user.error.logout.mandatory' : 'Accès refusé, vous êtes connecté(e)', +'user.error.listEmpty' : 'Aucun utilisateur trouvé', 'poll.tab.vote' : 'Voter', 'poll.tab.comment' : 'Commenter', 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 0c6e424..f060a02 100644 --- a/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/userCtrl.js @@ -150,6 +150,15 @@ angular.module('userControllers', []) $scope.saveUser = function (user) { User.admin(user); }; + + $scope.deleteUser = function (user) { + User.remove({userId:user.id}, function (data) { + var userIndex = $scope.data.users.indexOf(user); + if (userIndex >= 0) { + $scope.data.users.splice(userIndex, 1); + } + }); + }; }]) .controller('UserLoginCtrl', ['$scope', 'UserLogin', 'UserLogout', 'User', 'SessionStorage', '$route', '$location', '$translate', function ($scope, UserLogin, UserLogout, User, SessionStorage, $route, $location, $translate) { diff --git a/pollen-ui-angular/src/main/webapp/partials/user-admin-list.html b/pollen-ui-angular/src/main/webapp/partials/user-admin-list.html index 3a8571c..6b3cd54 100644 --- a/pollen-ui-angular/src/main/webapp/partials/user-admin-list.html +++ b/pollen-ui-angular/src/main/webapp/partials/user-admin-list.html @@ -34,7 +34,7 @@ </td> <td class="action"> <button class="btn btn-primary" ng-click="saveUser(user)"> <span class="glyphicon glyphicon-save"></span> </button> - <button class="btn btn-danger" ng-click="deleteUser(user)" disabled> <span class="glyphicon glyphicon-trash"></span> </button> + <button class="btn btn-danger" ng-click="deleteUser(user)"> <span class="glyphicon glyphicon-trash"></span> </button> </td> </tr> <tr> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm