diff --git a/app/controllers/cases_controller.rb b/app/controllers/cases_controller.rb index 174e23763..564ed8733 100644 --- a/app/controllers/cases_controller.rb +++ b/app/controllers/cases_controller.rb @@ -57,11 +57,12 @@ def show # @route [POST] `/cases` def create @case = current_reader.my_cases.build create_case_params + if @case.save redirect_to edit_case_path(@case), notice: successfully_created else @case.errors.delete(:slug) - render :new + redirect_to my_cases_path, alert: 'You must check the license confirmation box first to confirm (UPDATE ME)' and return end end @@ -121,7 +122,7 @@ def set_group_and_deployment # Only allow a trusted parameter "white list" through. def create_case_params - params.require(:case).permit(:locale) + params.require(:case).permit(:locale, :license_confirmation) end def update_case_params diff --git a/app/models/case.rb b/app/models/case.rb index d808cbdf0..d350d797c 100644 --- a/app/models/case.rb +++ b/app/models/case.rb @@ -89,6 +89,8 @@ class Case < ApplicationRecord format: { with: /\A[a-z0-9-]+\Z/ }, length: { maximum: 100 } + validates :license_confirmation, acceptance: true + delegate :fresh?, :pdf, to: :archive, prefix: true, allow_nil: true diff --git a/app/views/my_cases/index.html.haml b/app/views/my_cases/index.html.haml index 06757f52a..442e0a0eb 100644 --- a/app/views/my_cases/index.html.haml +++ b/app/views/my_cases/index.html.haml @@ -22,6 +22,10 @@ - if reader_signed_in? .pt-dark = form_with model: Case.new, local: true do |f| + = f.check_box :license_confirmation + = f.label :license_confirmation do + I confirm my agreement with the license for Gala (UPDATE ME) #{link_to 'Placeholder Link Title', '#'} + .div = f.submit I18n.t('my_cases.index.new_case'), class: 'pt-button pt-intent-success pt-icon-add' .pt-select