diff --git a/grails-app/conf/application.groovy b/grails-app/conf/application.groovy index 824370f..cb3567b 100644 --- a/grails-app/conf/application.groovy +++ b/grails-app/conf/application.groovy @@ -161,3 +161,13 @@ elasticSearch { maxBulkRequest = 250 } +attachement { + categories = [ + [key:"National Best Practice Manual", value:"National Best Practice Manual"], + [key:"National Weed Management Guide", value:"National Weed Management Guide"], + [key:"National Strategic Plan", value:"National Strategic Plan"], + [key:"Management", value:"Management"], + [key:"Other Management Resources", value:"Other Management Resources"], + [key:"General", value:"General"] + ] +} diff --git a/grails-app/controllers/au/org/ala/profile/OpusController.groovy b/grails-app/controllers/au/org/ala/profile/OpusController.groovy index 222df75..bf7c3da 100644 --- a/grails-app/controllers/au/org/ala/profile/OpusController.groovy +++ b/grails-app/controllers/au/org/ala/profile/OpusController.groovy @@ -438,6 +438,11 @@ class OpusController extends BaseController { } } + def getCategories() { + def categories = grailsApplication.config.getProperty('attachement.categories', List) + render(categories as JSON) + } + def getTags() { render([tags: Tag.list()] as JSON) } diff --git a/grails-app/controllers/au/org/ala/profile/UrlMappings.groovy b/grails-app/controllers/au/org/ala/profile/UrlMappings.groovy index da84434..d4b1f56 100644 --- a/grails-app/controllers/au/org/ala/profile/UrlMappings.groovy +++ b/grails-app/controllers/au/org/ala/profile/UrlMappings.groovy @@ -54,6 +54,7 @@ class UrlMappings { "/opus/$opusId/attachment/$attachmentId/download" controller: "opus", action: [GET: "downloadAttachment"] "/opus/$opusId/attachment/$attachmentId" controller: "opus", action: [GET: "getAttachmentMetadata", DELETE: "deleteAttachment"] "/opus/$opusId/attachment/" controller: "opus", action: [GET: "getAttachmentMetadata", POST: "saveAttachment"] + "/attachment/categories" controller: "opus", action: [GET: "getCategories"] "/opus/$opusId" controller: "opus", action: [GET: "show", POST: "updateOpus", DELETE: "deleteOpus"] diff --git a/grails-app/domain/au/org/ala/profile/Attachment.groovy b/grails-app/domain/au/org/ala/profile/Attachment.groovy index 5140099..2fa09ca 100644 --- a/grails-app/domain/au/org/ala/profile/Attachment.groovy +++ b/grails-app/domain/au/org/ala/profile/Attachment.groovy @@ -39,6 +39,6 @@ class Attachment { } static constraints = { - category blank: true, inList: ['Management', 'General'] + category blank: true, validator: {grailsApplication.config.getProperty('attachement.categories',List).value.contains(val)} } }