Skip to content

Commit

Permalink
Resolve #684 Add public profile consent question
Browse files Browse the repository at this point in the history
  • Loading branch information
suninthesky committed Jul 12, 2018
1 parent 2a5626f commit 0b4c812
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/proposals_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def load_proposal
def proposal_params
params.require(:proposal).permit(
:affect_geo, :all_funding_required, :funding_duration, :funding_type,
:private, :tagline, :title, :total_costs,
:private, :public_consent, :tagline, :title, :total_costs,
district_ids: [], country_ids: [], theme_ids: []
)
end
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/signup/suitability_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def form_params
],
proposal: [
:affect_geo, :all_funding_required, :funding_duration, :private,
:tagline, :title, :total_costs, district_ids: [], country_ids: []
:public_consent, :tagline, :title, :total_costs,
district_ids: [], country_ids: []
],
user: [
:agree_to_terms, :email, :first_name, :last_name,
Expand Down
2 changes: 1 addition & 1 deletion app/models/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Proposal < ApplicationRecord
in: 0..3, message: 'please select an option'
}

validates :all_funding_required, :private, inclusion: {
validates :all_funding_required, :private, :public_consent, inclusion: {
message: 'please select an option', in: [true, false]
}

Expand Down
4 changes: 3 additions & 1 deletion app/views/proposals/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
%strong= @country.name
.fs14 To change country select ‘Across many countries’ above.

.mb30= f.input :private, as: :radio_buttons, collection: [['Yes', false], ['No', true]]
.mb20= f.input :private, as: :radio_buttons, collection: [['Yes', false], ['No', true]]

.mb30= f.input :public_consent, as: :radio_buttons

= f.submit (submit_text || 'Save'), class: 'btn-wide bg-rich-blue white shadow', data: { disable_with: 'Checking suitability...' }
1 change: 1 addition & 0 deletions app/views/signup/suitability/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@

.mb20= u.input :agree_to_terms, label: false, inline_label: "I accept the #{link_to('terms of service', terms_path, target: '_blank')} and #{link_to('privacy policy', privacy_path, target: '_blank')}".html_safe
.mb20= p.input :private, as: :radio_buttons, collection: [['Yes', false], ['No', true]]
.mb20= p.input :public_consent, as: :radio_buttons
.mb20= u.input :marketing_consent, as: :radio_buttons

= f.submit 'Check suitability', class: 'btn-wide bg-rich-blue white shadow', data: { disable_with: 'Checking...' }
Expand Down
2 changes: 2 additions & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ en:
themes: 'Select the funding themes which best describe your project'
title: 'Proposal title'
total_costs: 'How much funding are you seeking?'
public_consent: 'Include my request in the proposals directory'
# Recipient
country: 'In which country is the funding recipient based?'
employees: 'No. of employees'
Expand Down Expand Up @@ -64,6 +65,7 @@ en:
private: 'We work with funders to verify our suitability assessments. By selecting ‘Yes’, some details of your request may be shared with funders for verification purposes. No personal data is shared.'
themes: 'Proposals with fewer than 5 themes get the best results.'
title: 'This could be the name of your project, or a few words describing your proposal.'
public_consent: 'Have non-personal details about your funding request such as the amount, description and eligibility reasons included in a publicly viewable directory of recent funding searches that others can browse and learn from.'
# Recipient
name: 'This could be the name of your organisation or project.'
# User
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20180712122951_add_public_consent_to_proposals.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPublicConsentToProposals < ActiveRecord::Migration[5.1]
def change
add_column :proposals, :public_consent, :boolean
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180422155410) do
ActiveRecord::Schema.define(version: 20180712122951) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -376,6 +376,7 @@
t.jsonb "eligibility", default: {}, null: false
t.jsonb "suitability", default: {}, null: false
t.integer "funding_type"
t.boolean "public_consent"
t.index ["recipient_id"], name: "index_proposals_on_recipient_id"
t.index ["state"], name: "index_proposals_on_state"
end
Expand Down
1 change: 1 addition & 0 deletions spec/factories/proposals.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
tagline 'Description'
title 'Title'
total_costs 10_000
public_consent true

after(:build) do |proposal, _evaluator|
proposal.themes = build_list(:theme, 1) unless proposal.themes.any?
Expand Down
1 change: 1 addition & 0 deletions spec/features/proposal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def complete_proposal_form
fill_in :proposal_funding_duration, with: 12
select Theme.last.name
select 'An entire country'
choose :proposal_public_consent_true
choose :proposal_private_true
end
end
3 changes: 2 additions & 1 deletion spec/models/signup/suitability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@
private: false,
tagline: 'Desciption of project.',
title: 'Project Name',
total_costs: 10_000
total_costs: 10_000,
public_consent: true
},
user: {
agree_to_terms: true,
Expand Down
3 changes: 3 additions & 0 deletions spec/support/signup_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def complete_signup_suitability_user(params = {})
within '.signup_suitability_proposal_private' do
choose params.fetch(:private, 'Yes')
end
within '.signup_suitability_proposal_public_consent' do
choose params.fetch(:public_consent, 'Yes')
end
within '.signup_suitability_user_marketing_consent' do
choose params.fetch(:marketing_consent, 'Yes')
end
Expand Down

0 comments on commit 0b4c812

Please sign in to comment.