Merge pull request #1580 from bertocq/feature/proposal_creation_thanks_page

Proposal creation thanks/share page
This commit is contained in:
Alberto
2017-05-31 12:25:59 +02:00
committed by GitHub
13 changed files with 153 additions and 5 deletions

View File

@@ -3,7 +3,7 @@ class ProposalsController < ApplicationController
include FlagActions
before_action :parse_tag_filter, only: :index
before_action :load_categories, only: [:index, :new, :edit, :map, :summary]
before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary]
before_action :load_geozones, only: [:edit, :map, :summary]
before_action :authenticate_user!, except: [:index, :show, :map, :summary]
@@ -22,6 +22,16 @@ class ProposalsController < ApplicationController
redirect_to proposal_path(@proposal), status: :moved_permanently if request.path != proposal_path(@proposal)
end
def create
@proposal = Proposal.new(proposal_params.merge(author: current_user))
if @proposal.save
redirect_to share_proposal_path(@proposal), notice: I18n.t('flash.actions.create.proposal')
else
render :new
end
end
def index_customization
discard_archived
load_retired
@@ -45,6 +55,12 @@ class ProposalsController < ApplicationController
def retire_form
end
def share
if Setting['proposal_improvement_url'].present?
@proposal_improvement_url = root_url + Setting['proposal_improvement_url']
end
end
def vote_featured
@proposal.register_vote(current_user, 'yes')
set_featured_proposal_votes(@proposal)

View File

@@ -4,7 +4,7 @@ module Abilities
def initialize(user)
can [:read, :map], Debate
can [:read, :map, :summary], Proposal
can [:read, :map, :summary, :share], Proposal
can :read, Comment
can :read, Poll
can :read, Poll::Question

View File

@@ -0,0 +1,47 @@
<% provide :title do %><%= @proposal.title %><% end %>
<% provide :social_media_meta_tags do %>
<%= render "shared/social_media_meta_tags",
social_url: proposal_url(@proposal),
social_title: @proposal.title,
social_description: @proposal.summary %>
<% end %>
<% content_for :canonical do %>
<%= render "shared/canonical", href: proposal_url(@proposal) %>
<% end %>
<% cache [locale_and_user_status(@proposal), @proposal, @proposal.author, Flag.flagged?(current_user, @proposal), @proposal_votes] do %>
<div class="proposal-show">
<div id="<%= dom_id(@proposal) %>" class="row">
<div class="small-12 medium-9 column">
<h1><%= t("proposals.proposal.created") %></h1>
<h2><%= @proposal.title %></h2>
<p>
<%= t("proposals.show.code") %>
<strong><%= @proposal.code %></strong>
</p>
<p><%= t("proposals.proposal.share.guide").html_safe %></p>
<%= render partial: 'shared/social_share', locals: {
title: @proposal.title,
url: proposal_url(@proposal)
} %>
<br/>
<% if @proposal_improvement_url.present? %>
<p><%= t('proposals.proposal.improve_info', improve_info_link: link_to(t('proposals.proposal.improve_info_link'), @proposal_improvement_url)).html_safe %></p>
<% end %>
<p>
<%= link_to proposal_path(@proposal), class: 'proposal' do %>
<%= t("proposals.proposal.share.view_proposal") %>
<% end %>
</p>
</div>
</div>
</div>
<% end %>

View File

@@ -1,5 +1,7 @@
<% if local_assigns[:share_title].present? %>
<div id="social-share" class="sidebar-divider"></div>
<h2><%= share_title %></h2>
<% end %>
<div class="social-share-full">
<%= social_share_button_tag("#{title} #{setting['twitter_hashtag']}") %>
<a href="whatsapp://send?text=<%= title.gsub(/\s/, '%20') %>&nbsp;<%= url %>"

View File

@@ -351,6 +351,12 @@ en:
notice:
retired: Proposal retired
proposal:
created: "You've created a new proposal!"
share:
guide: "Now you can share it through Twitter, Facebook, Google+, Telegram or Whatsapp (if you're using a mobile device) so people can start supporting.<br><br>Before it gets shared you'll be able to change the text as you like."
view_proposal: Not now, go to my proposal
improve_info: "You can also %{improve_info_link} about improving your campaign"
improve_info_link: see more information
already_supported: You have already supported this proposal. Share it!
comments:
one: 1 comment

View File

@@ -351,6 +351,12 @@ es:
notice:
retired: Propuesta retirada
proposal:
created: "¡Has creado una nueva propuesta!"
share:
guide: "Ahora puedes compartirla en Twitter, Facebook, Google+, Telegram o Whatsapp (si utilizas un dispositivo móvil) para que la gente empieze a apoyarla.<br><br>Antes de que se publique el texto en las redes sociales podrás modificarlo a tu gusto"
view_proposal: "Ahora no, ver mi propuesta"
improve_info: "También puedes %{improve_info_link} de como mejorar tu campaña"
improve_info_link: ver más información
already_supported: "¡Ya has apoyado esta propuesta, compártela!"
comments:
one: 1 Comentario

View File

@@ -44,3 +44,4 @@ en:
meta_keywords: "Keywords (SEO)"
verification_offices_url: Verification offices URL
min_age_to_participate: Minimum age needed to participate
proposal_improvement_url: Proposal improvement info internal link

View File

@@ -44,3 +44,4 @@ es:
meta_keywords: "Palabras clave (SEO)"
verification_offices_url: URL oficinas verificación
min_age_to_participate: Edad mínima para participar
proposal_improvement_url: Link a información para mejorar propuestas

View File

@@ -52,6 +52,7 @@ Rails.application.routes.draw do
put :flag
put :unflag
get :retire_form
get :share
patch :retire
end
collection do

View File

@@ -44,6 +44,7 @@ Setting.create(key: 'meta_description', value: 'Citizen Participation and Open G
Setting.create(key: 'meta_keywords', value: 'citizen participation, open government')
Setting.create(key: 'verification_offices_url', value: 'http://oficinas-atencion-ciudadano.url/')
Setting.create(key: 'min_age_to_participate', value: '16')
Setting.create(key: 'proposal_improvement_url', value: nil)
puts ""
print "Creating Geozones"

View File

@@ -103,3 +103,6 @@ Setting['mailer_from_address'] = 'noreply@consul.dev'
# Verification settings
Setting['verification_offices_url'] = 'http://oficinas-atencion-ciudadano.url/'
Setting['min_age_to_participate'] = 16
# Proposal improvement url path ('more-information/proposal-improvement')
Setting['proposal_improvement_url'] = nil

View File

@@ -90,6 +90,7 @@ feature 'Proposals' do
end
context "Embedded video" do
scenario "Show YouTube video" do
proposal = create(:proposal, video_url: "http://www.youtube.com/watch?v=a7UFm6ErMPU")
visit proposal_path(proposal)
@@ -138,6 +139,11 @@ feature 'Proposals' do
click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.'
expect(page).to have_content 'Help refugees'
expect(page).not_to have_content 'You can also see more information about improving your campaign'
click_link 'Not now, go to my proposal'
expect(page).to have_content 'Help refugees'
expect(page).to have_content '¿Would you like to give assistance to war refugees?'
expect(page).to have_content 'In summary, what we want is...'
@@ -150,6 +156,34 @@ feature 'Proposals' do
expect(page).to have_content I18n.l(Proposal.last.created_at.to_date)
end
scenario 'Create with proposal improvement info link' do
Setting['proposal_improvement_url'] = 'more-information/proposal-improvement'
author = create(:user)
login_as(author)
visit new_proposal_path
fill_in 'proposal_title', with: 'Help refugees'
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
fill_in 'proposal_summary', with: 'In summary, what we want is...'
fill_in 'proposal_description', with: 'This is very important because...'
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
fill_in 'proposal_video_url', with: 'http://youtube.com'
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
fill_in 'proposal_tag_list', with: 'Refugees, Solidarity'
check 'proposal_terms_of_service'
click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.'
expect(page).to have_content 'You can also see more information about improving your campaign'
click_link 'Not now, go to my proposal'
expect(page).to have_content 'Help refugees'
Setting['proposal_improvement_url'] = nil
end
scenario 'Create with invisible_captcha honeypot field' do
author = create(:user)
login_as(author)
@@ -210,6 +244,9 @@ feature 'Proposals' do
click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.'
click_link 'Not now, go to my proposal'
expect(Proposal.last.responsible_name).to eq('Isabel Garcia')
end
@@ -228,8 +265,11 @@ feature 'Proposals' do
check 'proposal_terms_of_service'
click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.'
click_link 'Not now, go to my proposal'
expect(Proposal.last.responsible_name).to eq(author.document_number)
end
scenario 'Errors on create' do
@@ -238,6 +278,7 @@ feature 'Proposals' do
visit new_proposal_path
click_button 'Create proposal'
expect(page).to have_content error_message
end
@@ -257,6 +298,9 @@ feature 'Proposals' do
click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.'
click_link 'Not now, go to my proposal'
expect(page).to have_content 'Testing an attack'
expect(page.html).to include '<p>This is alert("an attack");</p>'
expect(page.html).to_not include '<script>alert("an attack");</script>'
@@ -278,6 +322,9 @@ feature 'Proposals' do
click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.'
click_link 'Not now, go to my proposal'
expect(page).to have_content 'Testing auto link'
expect(page).to have_link('www.example.org', href: 'http://www.example.org')
end
@@ -297,6 +344,9 @@ feature 'Proposals' do
click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.'
click_link 'Not now, go to my proposal'
expect(page).to have_content 'Testing auto link'
expect(page).to have_link('http://example.org', href: 'http://example.org')
expect(page).not_to have_link('click me')
@@ -329,6 +379,9 @@ feature 'Proposals' do
click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.'
click_link 'Not now, go to my proposal'
within "#geozone" do
expect(page).to have_content 'All city'
end
@@ -355,6 +408,9 @@ feature 'Proposals' do
click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.'
click_link 'Not now, go to my proposal'
within "#geozone" do
expect(page).to have_content 'California'
end
@@ -1437,4 +1493,4 @@ feature 'Successful proposals' do
end
end
end
end

View File

@@ -80,6 +80,9 @@ feature 'Tags' do
click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.'
click_link 'Not now, go to my proposal'
expect(page).to have_content 'Economía'
expect(page).to have_content 'Hacienda'
end
@@ -107,6 +110,8 @@ feature 'Tags' do
expect(page).to have_content 'Proposal created successfully.'
click_link 'Not now, go to my proposal'
within "#tags_proposal_#{Proposal.last.id}" do
expect(page).to have_content 'Education'
expect(page).to_not have_content 'Health'
@@ -149,6 +154,9 @@ feature 'Tags' do
click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.'
click_link 'Not now, go to my proposal'
expect(page).to have_content 'user_id1'
expect(page).to have_content 'a3'
expect(page).to have_content 'scriptalert("hey");script'
@@ -291,4 +299,4 @@ feature 'Tags' do
expect(page).to_not have_content proposal3.title
end
end
end
end