diff --git a/src/main/java/info/bukova/isspst/Constants.java b/src/main/java/info/bukova/isspst/Constants.java index c253f435..09219cdf 100644 --- a/src/main/java/info/bukova/isspst/Constants.java +++ b/src/main/java/info/bukova/isspst/Constants.java @@ -108,16 +108,19 @@ public class Constants { public final static String PERM_SHOW_ALL_REQ = "PERM_SHOW_ALL_REQ"; public final static String PERM_EDIT_NEW = "PERM_EDIT_NEW"; public final static String PERM_EDIT_OWN = "PERM_EDIT_OWN"; + public final static String PERM_DELETE_NEW = "PERM_DELETE_NEW"; public final static String PERM_SEARCH = "PERM_SEARCH"; public final static Permission SPECIAL_PERMISSIONS[] = { new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL), + new Permission(PERM_DELETE_NEW, "Mazat neschválené", MOD_REQUIREMENTS, PermissionType.GLOBAL), new Permission(PERM_SHOW_WORKGROUP_REQ, "Zobrazení požadavků komise", MOD_REQUIREMENTS, PermissionType.WORKGROUP), new Permission(PERM_SHOW_CENTRE_REQ, "Zobrazení požadavků střediska", MOD_REQUIREMENTS, PermissionType.CENTRE), new Permission(PERM_SHOW_ALL_REQ, "Zobrazení všech požadavků", MOD_REQUIREMENTS, PermissionType.GLOBAL), new Permission(PERM_APPROVE, "Schválení", MOD_REQUIREMENTS, PermissionType.WORKGROUP), new Permission(PERM_EDIT_NEW, "Upravit neschválené", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL), + new Permission(PERM_DELETE_NEW, "Mazat neschválené", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL), new Permission(PERM_SHOW_WORKGROUP_REQ, "Zobrazení požadavků komise", MOD_TRIPREQUIREMENTS, PermissionType.WORKGROUP), new Permission(PERM_SHOW_CENTRE_REQ, "Zobrazení požadavků střediska", MOD_TRIPREQUIREMENTS, PermissionType.CENTRE), new Permission(PERM_SHOW_ALL_REQ, "Zobrazení všech požadavků", MOD_TRIPREQUIREMENTS, PermissionType.GLOBAL), diff --git a/src/main/java/info/bukova/isspst/security/AbstractRequirementEvaluator.java b/src/main/java/info/bukova/isspst/security/AbstractRequirementEvaluator.java index 4becbafb..4fff0edc 100644 --- a/src/main/java/info/bukova/isspst/security/AbstractRequirementEvaluator.java +++ b/src/main/java/info/bukova/isspst/security/AbstractRequirementEvaluator.java @@ -30,6 +30,10 @@ public abstract class AbstractRequirementEvaluator extends AbstractModuleEvaluat return req.getState() == RequirementState.NEW; } + if (permission.equals(Constants.PERM_DELETE_NEW)) { + return req.getState() == RequirementState.NEW; + } + return true; } diff --git a/src/main/java/info/bukova/isspst/security/WorkgroupAwareServiceEvaluator.java b/src/main/java/info/bukova/isspst/security/WorkgroupAwareServiceEvaluator.java index b03f8738..a5bd2e8d 100644 --- a/src/main/java/info/bukova/isspst/security/WorkgroupAwareServiceEvaluator.java +++ b/src/main/java/info/bukova/isspst/security/WorkgroupAwareServiceEvaluator.java @@ -1,6 +1,7 @@ package info.bukova.isspst.security; import info.bukova.isspst.Constants; +import info.bukova.isspst.Module; import info.bukova.isspst.data.Permission; import info.bukova.isspst.data.PermissionType; import info.bukova.isspst.data.Role; @@ -39,11 +40,22 @@ public class WorkgroupAwareServiceEvaluator implements Evaluator { } User user = (User)authentication.getPrincipal(); + String moduleId = ""; + + // TODO - v master větvi je na toto pomocná třída + for (Module m : Constants.MODULES) { + if (m.getServiceClass() != null && m.getServiceClass().isAssignableFrom(targetDomainObject.getClass())) { + moduleId = m.getId(); + break; + } + } Permission appPermission = null; for (Permission p : Constants.SPECIAL_PERMISSIONS) { - if (p.getAuthority().equals(permission)) { + if (p.getAuthority().equals(permission) + && p.getModule().equals(moduleId)) { appPermission = p; + break; } } @@ -66,7 +78,8 @@ public class WorkgroupAwareServiceEvaluator implements Evaluator { for (Role r : wgRoles) { for (Permission p : r.getPermissions()) { - if (p.getAuthority().equals(appPermission.getAuthority())) { + if (p.getAuthority().equals(appPermission.getAuthority()) + && p.getModule().equals(appPermission.getModule())) { return true; } } diff --git a/src/main/java/info/bukova/isspst/services/AbstractService.java b/src/main/java/info/bukova/isspst/services/AbstractService.java index ac74c11f..ff6bf9e5 100644 --- a/src/main/java/info/bukova/isspst/services/AbstractService.java +++ b/src/main/java/info/bukova/isspst/services/AbstractService.java @@ -59,6 +59,10 @@ public abstract class AbstractService implements Service return ""; } + public String getDeleteEntityPermission() { + return ""; + } + @Override @PreAuthorize("hasPermission(this, 'PERM_ADD')") public final T create() { @@ -101,7 +105,7 @@ public abstract class AbstractService implements Service @Override @Transactional - @PreAuthorize("hasPermission(this, 'PERM_DELETE')") + @PreAuthorize("hasPermission(this, 'PERM_DELETE') or hasPermission(#entity, this.getDeleteEntityPermission())") public void delete(T entity) { if (dao == null) { throw new IsspstException("DAO is null"); diff --git a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java index 001fb6b1..9fb504b9 100644 --- a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java @@ -7,9 +7,11 @@ import info.bukova.isspst.services.AbstractOwnedService; import info.bukova.isspst.services.LazyLoader; import java.math.BigDecimal; +import java.util.List; import org.hibernate.Hibernate; import org.hibernate.Query; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.transaction.annotation.Transactional; public class InvoicingServiceImpl extends AbstractOwnedService implements @@ -54,4 +56,13 @@ public class InvoicingServiceImpl extends AbstractOwnedService implem invoicing.setTotalInvoiced(total); } + @SuppressWarnings("unchecked") + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_READ')") + public List getAll() { + Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy order by rq.numser"); + return q.list(); + } + } diff --git a/src/main/java/info/bukova/isspst/services/orders/OrderServiceImpl.java b/src/main/java/info/bukova/isspst/services/orders/OrderServiceImpl.java index 52a37706..42f5ab84 100644 --- a/src/main/java/info/bukova/isspst/services/orders/OrderServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/orders/OrderServiceImpl.java @@ -181,6 +181,7 @@ public class OrderServiceImpl extends AbstractOwnedService implements } @Transactional + @PreAuthorize("hasPermission(this, 'PERM_EDIT') or hasPermission(#entity, this.getUpdateEntityPermission())") public void updateApprovedItems(Order order, boolean orderedChanged) { if (orderedChanged) diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java index 7a40b444..4587eab5 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementBaseServiceImpl.java @@ -382,5 +382,10 @@ public abstract class RequirementBaseServiceImpl exte public String getUpdateEntityPermission() { return Constants.PERM_EDIT_NEW; } + + @Override + public String getDeleteEntityPermission() { + return Constants.PERM_DELETE_NEW; + } } diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index a4952b0c..3f964a80 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -349,6 +349,7 @@ InvoicingInvoiceNumber=Číslo faktury InvoicingAmount=Částka InvoicingDescription=Popis InvoicingInvoiced=Fakturováno +InvoicingApplicant=Žadatel HandleComboKeyFilter=#del HandleComboKey=$#del diff --git a/src/main/webapp/main/invoicing/invoicingGrid.zul b/src/main/webapp/main/invoicing/invoicingGrid.zul index 7daee89e..57737c84 100644 --- a/src/main/webapp/main/invoicing/invoicingGrid.zul +++ b/src/main/webapp/main/invoicing/invoicingGrid.zul @@ -29,6 +29,9 @@ label="${labels.RequirementsGridWorkgroup}" width="180px"/> + +