From bbbc2fb1ffe2d8714256c6701c41ec551b1a4437 Mon Sep 17 00:00:00 2001 From: Sushant G <105408469+sughics@users.noreply.github.com> Date: Mon, 24 Jul 2023 17:58:22 +1000 Subject: [PATCH] Bugfix/issue 206 providermap error (#212) * issue #206 prevent saving new ProviderMap with a collection from an existing providerMap * adding bugfix and feature branches to travis config --- .travis.yml | 4 ++-- .../au/org/ala/collectory/ProviderMapController.groovy | 7 ++++++- grails-app/i18n/messages.properties | 1 + grails-app/views/providerMap/create.gsp | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index d47c12be..09eb38fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,8 @@ branches: only: - master - develop - - feature/issue-175 - - feature/grails5 + - /^feature\/.*$/ + - /^bugfix\/.*$/ before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock diff --git a/grails-app/controllers/au/org/ala/collectory/ProviderMapController.groovy b/grails-app/controllers/au/org/ala/collectory/ProviderMapController.groovy index 80440c8d..08328530 100644 --- a/grails-app/controllers/au/org/ala/collectory/ProviderMapController.groovy +++ b/grails-app/controllers/au/org/ala/collectory/ProviderMapController.groovy @@ -48,9 +48,14 @@ class ProviderMapController { @Transactional def save () { def providerMapInstance = new ProviderMap(params) + if (providerMapInstance.collection && providerMapInstance.collection.providerMap){ + flash.message = "${message(code: 'providerMap.collection.used.label', args: [providerMapInstance.collection.uid])}" + render(view: "create", model: [providerMapInstance: providerMapInstance, returnTo: params.returnTo]) + return + } if (providerMapInstance.save(flush: true)) { flash.message = "${message(code: 'default.created.message', args: [message(code: 'providerMap.label', default: 'ProviderMap'), providerMapInstance.id])}" - redirect(action: "show", id: providerMapInstance.id, params:[returnTo: params.returnTo]) + render(view: "create", model: [providerMapInstance: providerMapInstance, returnTo: params.returnTo]) } else { render(view: "create", model: [providerMapInstance: providerMapInstance, returnTo: params.returnTo]) diff --git a/grails-app/i18n/messages.properties b/grails-app/i18n/messages.properties index f5d8b779..833c31f4 100644 --- a/grails-app/i18n/messages.properties +++ b/grails-app/i18n/messages.properties @@ -1471,6 +1471,7 @@ providerMap.dateCreated.label=Date Created providerMap.providerGroup.label=Provider Group providerMap.institution.label=Institution providerMap.collection.label=Collection +providerMap.collection.used.label= Unable to create or update ProviderMap. Collection {0} is already in use with another ProviderMap #The following messages are for the Web Service page. They are not urgent to translate diff --git a/grails-app/views/providerMap/create.gsp b/grails-app/views/providerMap/create.gsp index 9f8250c1..c69776c2 100644 --- a/grails-app/views/providerMap/create.gsp +++ b/grails-app/views/providerMap/create.gsp @@ -15,7 +15,7 @@