diff --git a/grails-app/views/paratoo/_projectRole.gson b/grails-app/views/paratoo/_projectRole.gson index a5d8f4623..a6aabae7d 100644 --- a/grails-app/views/paratoo/_projectRole.gson +++ b/grails-app/views/paratoo/_projectRole.gson @@ -4,4 +4,4 @@ model { ParatooProject project } -json([(project.id):project.paratooAccessLevel]) +json([(project.id):[name:project.paratooAccessLevelName, type:project.paratooAccessLevelType]]) diff --git a/src/main/groovy/au/org/ala/ecodata/paratoo/ParatooProject.groovy b/src/main/groovy/au/org/ala/ecodata/paratoo/ParatooProject.groovy index 6a4608fb6..ed8e69134 100644 --- a/src/main/groovy/au/org/ala/ecodata/paratoo/ParatooProject.groovy +++ b/src/main/groovy/au/org/ala/ecodata/paratoo/ParatooProject.groovy @@ -32,9 +32,10 @@ class ParatooProject { project.getMonitoringProtocolCategories() } - String getParatooAccessLevel() { + String getParatooAccessLevelType() { String paratooAccessLevel = READ_ONLY switch (accessLevel) { + case AccessLevel.editor: case AccessLevel.admin: case AccessLevel.caseManager: paratooAccessLevel = EDITABLE @@ -42,4 +43,16 @@ class ParatooProject { } paratooAccessLevel } + + String getParatooAccessLevelName() { + String paratooAccessLevelName = 'Authenticated' + switch (accessLevel) { + case AccessLevel.editor: + case AccessLevel.admin: + case AccessLevel.caseManager: + paratooAccessLevelName = 'Project Admin' + break; + } + paratooAccessLevelName + } } diff --git a/src/test/groovy/au/org/ala/ecodata/ParatooJsonViewSpec.groovy b/src/test/groovy/au/org/ala/ecodata/ParatooJsonViewSpec.groovy index 28f91faba..d1802afaa 100644 --- a/src/test/groovy/au/org/ala/ecodata/ParatooJsonViewSpec.groovy +++ b/src/test/groovy/au/org/ala/ecodata/ParatooJsonViewSpec.groovy @@ -47,13 +47,14 @@ class ParatooJsonViewSpec extends Specification implements JsonViewTest { when: int[][] projectSpec = [[3, 1, 0], [0, 0, 1], [1, 0, 0]] as int[][] List projects = buildProjectsForRendering(projectSpec) + projects[2].accessLevel = AccessLevel.readOnly def result = render(view: "/paratoo/userRoles", model:[projects:projects]) then:"The json is correct" - result.json[0] == [(projects[0].id):'project_admin'] - result.json[1] == [(projects[1].id):'project_admin'] - result.json[2] == [(projects[2].id):'project_admin'] + result.json[0] == [(projects[0].id):[name:"Project Admin", type:'project_admin']] + result.json[1] == [(projects[1].id):[name:"Project Admin", type:'project_admin']] + result.json[2] == [(projects[2].id):[name:"Authenticated", type:'authenticated']] }