diff options
| author | Luc Donnet | 2018-01-03 11:57:42 +0100 | 
|---|---|---|
| committer | Luc Donnet | 2018-01-03 11:57:42 +0100 | 
| commit | 7cce4762c11e7d1e78433f6f88d2e12928c398dc (patch) | |
| tree | 3084d95692a70f9c5d5a842aae6f4ec0ea07a1c3 /app/controllers/referentials_controller.rb | |
| parent | 6497b23e18385121974f6cbf56d48caf897e69b1 (diff) | |
| parent | 414d0f6c4dd992696354757c4ae700952a7e4dd9 (diff) | |
| download | chouette-core-7cce4762c11e7d1e78433f6f88d2e12928c398dc.tar.bz2 | |
Merge branch 'master' into 5024-prevent-duplicate-referentials-from-being-created-during-parallel-db-transactions--rb201711271659
Diffstat (limited to 'app/controllers/referentials_controller.rb')
| -rw-r--r-- | app/controllers/referentials_controller.rb | 17 | 
1 files changed, 11 insertions, 6 deletions
| diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb index 227651a59..83e3bc56a 100644 --- a/app/controllers/referentials_controller.rb +++ b/app/controllers/referentials_controller.rb @@ -13,11 +13,16 @@ class ReferentialsController < ChouetteController    end    def create -    create! do |format| -      build_referential - -      if !!@referential.created_from_id -        format.html { redirect_to workbench_path(@referential.workbench) } +    create! do |success, failure| +      success.html do +        if @referential.created_from_id.present? +          flash[:notice] = t('notice.referentials.duplicate') +        end +        redirect_to workbench_path(@referential.workbench) +      end +      failure.html do +        Rails.logger.info "Can't create Referential : #{@referential.errors.inspect}" +        render :new        end      end    end @@ -60,7 +65,7 @@ class ReferentialsController < ChouetteController    def validate      ComplianceControlSetCopyWorker.perform_async(params[:compliance_control_set], params[:id]) -    flash[:notice] = I18n.t("referentials.operation_in_progress") +    flash[:notice] = t('notice.referentials.validate')      redirect_to(referential_path)    end | 
