Add guide to create a proposal or investment
During a Participatory Budget, some users are getting confused and creating a proposal instead of a budget investment. This intermediate page should help them create investments Adding a feature flag just in case other forks don’t need this feature and setting seeds and dev_seeds for appropriate initial setup
This commit is contained in:
8
app/controllers/guides_controller.rb
Normal file
8
app/controllers/guides_controller.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class GuidesController < ApplicationController
|
||||
|
||||
skip_authorization_check
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
end
|
||||
19
app/helpers/guides_helper.rb
Normal file
19
app/helpers/guides_helper.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
module GuidesHelper
|
||||
|
||||
def new_proposal_guide
|
||||
if feature?("guides")
|
||||
new_guide_path
|
||||
else
|
||||
new_proposal_path
|
||||
end
|
||||
end
|
||||
|
||||
def new_budget_investment_guide
|
||||
if feature?("guides")
|
||||
new_guide_path
|
||||
else
|
||||
new_budget_investment_path(current_budget)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -27,7 +27,7 @@
|
||||
<% if current_user %>
|
||||
<% if current_user.level_two_or_three_verified? %>
|
||||
<%= link_to t("budgets.investments.index.sidebar.create"),
|
||||
new_budget_investment_path(@budget),
|
||||
new_budget_investment_guide,
|
||||
class: "button margin-top expanded" %>
|
||||
<% else %>
|
||||
<div class="callout warning margin-top">
|
||||
|
||||
11
app/views/guides/new.html.erb
Normal file
11
app/views/guides/new.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<% if current_budget %>
|
||||
<div>
|
||||
<%= link_to t("guides.new_budget_investment"),
|
||||
new_budget_investment_path(current_budget) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<%= link_to t("guides.new_proposal"),
|
||||
new_proposal_path %>
|
||||
</div>
|
||||
@@ -63,7 +63,9 @@
|
||||
|
||||
<% if @proposals.any? %>
|
||||
<div class="show-for-small-only">
|
||||
<%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: 'button expanded' %>
|
||||
<%= link_to t("proposals.index.start_proposal"),
|
||||
new_proposal_guide,
|
||||
class: 'button expanded' %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -92,7 +94,9 @@
|
||||
|
||||
<div class="small-12 medium-3 column">
|
||||
<aside class="margin-bottom">
|
||||
<%= link_to t("proposals.index.start_proposal"), new_proposal_path, class: 'button expanded' %>
|
||||
<%= link_to t("proposals.index.start_proposal"),
|
||||
new_proposal_guide,
|
||||
class: 'button expanded' %>
|
||||
<% if params[:retired].blank? %>
|
||||
<%= render 'categories' %>
|
||||
<%= render "shared/tag_cloud", taggable: 'proposal' %>
|
||||
|
||||
4
config/locales/en/guides.yml
Normal file
4
config/locales/en/guides.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
en:
|
||||
guides:
|
||||
new_proposal: I want to create a proposal
|
||||
new_budget_investment: I want to create a budget investment
|
||||
4
config/locales/es/guides.yml
Normal file
4
config/locales/es/guides.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
es:
|
||||
guides:
|
||||
new_proposal: Quiero crear una propuesta
|
||||
new_budget_investment: Quiero crear un nuevo proyecto de gasto
|
||||
@@ -18,6 +18,7 @@ Rails.application.routes.draw do
|
||||
draw :direct_upload
|
||||
draw :document
|
||||
draw :graphql
|
||||
draw :guide
|
||||
draw :legislation
|
||||
draw :management
|
||||
draw :moderation
|
||||
|
||||
1
config/routes/guide.rb
Normal file
1
config/routes/guide.rb
Normal file
@@ -0,0 +1 @@
|
||||
resources :guides, only: :new
|
||||
@@ -37,6 +37,7 @@ section "Creating Settings" do
|
||||
Setting.create(key: 'url', value: 'http://localhost:3000')
|
||||
Setting.create(key: 'org_name', value: 'CONSUL')
|
||||
Setting.create(key: 'place_name', value: 'City')
|
||||
|
||||
Setting.create(key: 'feature.debates', value: "true")
|
||||
Setting.create(key: 'feature.proposals', value: "true")
|
||||
Setting.create(key: 'feature.polls', value: "true")
|
||||
@@ -53,6 +54,8 @@ section "Creating Settings" do
|
||||
Setting.create(key: 'feature.map', value: "true")
|
||||
Setting.create(key: 'feature.allow_images', value: "true")
|
||||
Setting.create(key: 'feature.public_stats', value: "true")
|
||||
Setting.create(key: 'feature.guides', value: nil)
|
||||
|
||||
Setting.create(key: 'per_page_code_head', value: "")
|
||||
Setting.create(key: 'per_page_code_body', value: "")
|
||||
Setting.create(key: 'comments_body_max_length', value: '1000')
|
||||
|
||||
@@ -85,6 +85,7 @@ Setting['feature.user.recommendations'] = true
|
||||
Setting['feature.community'] = true
|
||||
Setting['feature.map'] = nil
|
||||
Setting['feature.allow_images'] = true
|
||||
Setting['feature.guides'] = nil
|
||||
|
||||
# Spending proposals feature flags
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = nil
|
||||
|
||||
54
spec/features/guides_spec.rb
Normal file
54
spec/features/guides_spec.rb
Normal file
@@ -0,0 +1,54 @@
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Guide the user to create the correct resource' do
|
||||
|
||||
let(:user) { create(:user, :verified)}
|
||||
let!(:budget) { create(:budget, :accepting) }
|
||||
|
||||
background do
|
||||
Setting['feature.guides'] = true
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.guides'] = nil
|
||||
end
|
||||
|
||||
scenario "Proposal" do
|
||||
login_as(user)
|
||||
visit proposals_path
|
||||
|
||||
click_link "Create a proposal"
|
||||
click_link "I want to create a proposal"
|
||||
|
||||
expect(page).to have_current_path(new_proposal_path)
|
||||
end
|
||||
|
||||
scenario "Budget Investment" do
|
||||
login_as(user)
|
||||
visit budgets_path
|
||||
|
||||
click_link "Create a budget investment"
|
||||
click_link "I want to create a budget investment"
|
||||
|
||||
expect(page).to have_current_path(new_budget_investment_path(budget))
|
||||
end
|
||||
|
||||
scenario "Feature deactivated" do
|
||||
Setting['feature.guides'] = nil
|
||||
|
||||
login_as(user)
|
||||
|
||||
visit proposals_path
|
||||
click_link "Create a proposal"
|
||||
|
||||
expect(page).to_not have_link "I want to create a proposal"
|
||||
expect(page).to have_current_path(new_proposal_path)
|
||||
|
||||
visit budgets_path
|
||||
click_link "Create a budget investment"
|
||||
|
||||
expect(page).to_not have_link "I want to create a new budget investment"
|
||||
expect(page).to have_current_path(new_budget_investment_path(budget))
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user