Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confirmation checkbox for case creation #670

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/controllers/cases_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/models/case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions app/views/my_cases/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down