Skip to content

Commit

Permalink
Merge branch 'staging' of https://github.com/CCAFS/MARLO into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjitm committed Sep 3, 2018
2 parents e650b0b + 88db083 commit 935b113
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.cgiar.ccafs.marlo.data.model.ProjectExpectedStudyInfo;
import org.cgiar.ccafs.marlo.data.model.SectionStatus;
import org.cgiar.ccafs.marlo.data.model.StudyType;
import org.cgiar.ccafs.marlo.security.Permission;
import org.cgiar.ccafs.marlo.utils.APConfig;

import java.util.ArrayList;
Expand Down Expand Up @@ -213,7 +214,8 @@ public void prepare() throws Exception {
myNonProjectStudies = new ArrayList<>();

if (!nonProjectStudies.isEmpty()) {
if (this.canAccessSuperAdmin() || this.canAcessCrpAdmin()) {
if (this.canAccessSuperAdmin() || this
.hasPermission(this.generatePermission(Permission.STUDIES_FULL_EDIT_PERMISSION, loggedCrp.getAcronym()))) {

for (ProjectExpectedStudy projectExpectedStudy : expectedStudies) {
if (projectExpectedStudy.getProjectExpectedStudyInfo(this.getActualPhase()) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ void setPermissionParameters(ActionInvocation invocation) throws Exception {
} else {
if (user.getId() == projectExpectedStudy.getCreatedBy().getId()) {
canEdit = true;
} else if (baseAction
.hasPermission(baseAction.generatePermission(Permission.STUDIES_FULL_EDIT_PERMISSION, crp.getAcronym()))) {
canEdit = true;
} else {
if (baseAction.hasPermission(baseAction.generatePermission(Permission.STUDIES_EDIT_PERMISSION, params))) {
canEdit = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public class Permission {

public static final String STUDIES_BASE_PERMISSION = "crp:{0}:studies:{1}";
public static final String STUDIES_EDIT_PERMISSION = "crp:{0}:studies:{1}:canEdit";
public static final String STUDIES_FULL_EDIT_PERMISSION = "crp:{0}:studies:*";

public static final String PROJECT_INNOVATIONS_BASE_PERMISSION = "crp:{0}:project:{1}:innovations";
public static final String PROJECT_INNOVATIONS_EDIT_PERMISSION = "crp:{0}:project:{1}:innovations:canEdit";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SET FOREIGN_KEY_CHECKS=0;

INSERT INTO `permissions` (`permission`, `description`, `type`) VALUES ('crp:{0}:studies:*', 'Full privilegies in studies without Projects', '0');
INSERT INTO `role_permissions` (`role_id`, `permission_id`) VALUES ((SELECT id FROM roles r WHERE r.acronym="PMU" AND r.global_unit_id=17), (SELECT id FROM permissions p WHERE p.permission="crp:{0}:studies:*"));

0 comments on commit 935b113

Please sign in to comment.