From 142b82a8de3dda2269fdb58a6676acc1ea45cf36 Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Tue, 17 Jun 2014 06:27:52 +0200 Subject: [PATCH] =?UTF-8?q?Po=20spu=C5=A1t=C4=9Bn=C3=AD=20se=20adminovi=20?= =?UTF-8?q?dopln=C3=AD=20automaticky=20pln=C3=A1=20pr=C3=A1va=20na=20v?= =?UTF-8?q?=C5=A1echny=20agendy.=20Role=20admina=20nejde=20zm=C4=9Bnit.=20?= =?UTF-8?q?U=C5=BEivatel=20admin=20nejde=20smazat.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #99: Editace uživatele admin Task-Url: https://git.bukova.info/redmine/issues/show/99 --- .../info/bukova/isspst/AppInitListener.java | 20 +++++++++++++++++++ .../info/bukova/isspst/ui/ListViewModel.java | 10 ++++++++++ .../bukova/isspst/ui/users/UsersList.java | 17 ++++++++++++++++ .../webapp/admin/permissions/permForm.zul | 2 +- src/main/webapp/admin/users/userForm.zul | 4 ++-- src/main/webapp/app/toolbar.zul | 2 +- 6 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/main/java/info/bukova/isspst/AppInitListener.java b/src/main/java/info/bukova/isspst/AppInitListener.java index d354ceed..cee7f5b8 100644 --- a/src/main/java/info/bukova/isspst/AppInitListener.java +++ b/src/main/java/info/bukova/isspst/AppInitListener.java @@ -1,5 +1,7 @@ package info.bukova.isspst; +import java.util.List; + import info.bukova.isspst.data.Permission; import info.bukova.isspst.data.Role; import info.bukova.isspst.data.User; @@ -44,6 +46,7 @@ public class AppInitListener implements ServletContextListener { checkRoles(); checkUsers(); checkPermissions(); + checkAllAdminRights(); userService.removeAccess(); loadModuleReports(); @@ -97,6 +100,23 @@ public class AppInitListener implements ServletContextListener { } } + private void checkAllAdminRights() + { + Role adminRole = roleService.getRoleByAuthority(Constants.ROLE_ADMIN); + List permissionList = adminRole.getPermissions(); + List permissionListAvailable = permService.getAll(); + + for (Permission permitionAvailable : permissionListAvailable) + { + if (!permissionList.contains(permitionAvailable)) + { + adminRole.addPermission(permitionAvailable); + } + } + + roleService.update(adminRole); + } + private void loadModuleReports() { for (Module m : Constants.MODULES) { Report rep = new Report(); diff --git a/src/main/java/info/bukova/isspst/ui/ListViewModel.java b/src/main/java/info/bukova/isspst/ui/ListViewModel.java index ccafe836..ef287118 100644 --- a/src/main/java/info/bukova/isspst/ui/ListViewModel.java +++ b/src/main/java/info/bukova/isspst/ui/ListViewModel.java @@ -54,6 +54,7 @@ public class ListViewModel { return dataList; } + @NotifyChange({"dataBean","ableToDelete"}) public void setDataBean(T data) { this.dataBean = data; } @@ -326,5 +327,14 @@ public class ListViewModel { protected void setFullFill(boolean fullFill) { this.fullFill = fullFill; } + + public boolean isRecordSelected() + { + return (dataBean != null); + } + public boolean isAbleToDelete() + { + return this.isRecordSelected(); + } } diff --git a/src/main/java/info/bukova/isspst/ui/users/UsersList.java b/src/main/java/info/bukova/isspst/ui/users/UsersList.java index 75e8175b..62f7307d 100644 --- a/src/main/java/info/bukova/isspst/ui/users/UsersList.java +++ b/src/main/java/info/bukova/isspst/ui/users/UsersList.java @@ -72,4 +72,21 @@ public class UsersList extends ListViewModel { return ret; } + @Override + public boolean isAbleToDelete() { + + if (!super.isAbleToDelete()) + { + return false; + } + + if (getDataBean().getUsername() == "admin") + { + return false; + } + + return true; + } + + } diff --git a/src/main/webapp/admin/permissions/permForm.zul b/src/main/webapp/admin/permissions/permForm.zul index 7750943a..4eb3ff55 100644 --- a/src/main/webapp/admin/permissions/permForm.zul +++ b/src/main/webapp/admin/permissions/permForm.zul @@ -15,7 +15,7 @@ diff --git a/src/main/webapp/admin/users/userForm.zul b/src/main/webapp/admin/users/userForm.zul index 52b1669e..75468493 100644 --- a/src/main/webapp/admin/users/userForm.zul +++ b/src/main/webapp/admin/users/userForm.zul @@ -19,14 +19,14 @@ - + diff --git a/src/main/webapp/app/toolbar.zul b/src/main/webapp/app/toolbar.zul index a419dfdf..74b08ea7 100644 --- a/src/main/webapp/app/toolbar.zul +++ b/src/main/webapp/app/toolbar.zul @@ -3,7 +3,7 @@ - +