Merge pull request #3081 from consul/featured-proposals
[Backport] Featured proposals
This commit is contained in:
@@ -44,8 +44,7 @@ class ProposalsController < ApplicationController
|
|||||||
def index_customization
|
def index_customization
|
||||||
discard_archived
|
discard_archived
|
||||||
load_retired
|
load_retired
|
||||||
load_successful_proposals
|
load_featured
|
||||||
load_featured unless @proposal_successful_exists
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def vote
|
def vote
|
||||||
@@ -131,21 +130,20 @@ class ProposalsController < ApplicationController
|
|||||||
|
|
||||||
def load_featured
|
def load_featured
|
||||||
return unless !@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank? && @current_order != "recommendations"
|
return unless !@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank? && @current_order != "recommendations"
|
||||||
@featured_proposals = Proposal.not_archived.sort_by_confidence_score.limit(3)
|
if Setting['feature.featured_proposals']
|
||||||
|
@featured_proposals = Proposal.not_archived.unsuccessful
|
||||||
|
.sort_by_confidence_score.limit(Setting['featured_proposals_number'])
|
||||||
if @featured_proposals.present?
|
if @featured_proposals.present?
|
||||||
set_featured_proposal_votes(@featured_proposals)
|
set_featured_proposal_votes(@featured_proposals)
|
||||||
@resources = @resources.where('proposals.id NOT IN (?)', @featured_proposals.map(&:id))
|
@resources = @resources.where('proposals.id NOT IN (?)', @featured_proposals.map(&:id))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def set_view
|
def set_view
|
||||||
@view = (params[:view] == "minimal") ? "minimal" : "default"
|
@view = (params[:view] == "minimal") ? "minimal" : "default"
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_successful_proposals
|
|
||||||
@proposal_successful_exists = Proposal.successful.exists?
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy_map_location_association
|
def destroy_map_location_association
|
||||||
map_location = params[:proposal][:map_location_attributes]
|
map_location = params[:proposal][:map_location_attributes]
|
||||||
if map_location && (map_location[:longitude] && map_location[:latitude]).blank? && !map_location[:id].blank?
|
if map_location && (map_location[:longitude] && map_location[:latitude]).blank? && !map_location[:id].blank?
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ en:
|
|||||||
max_votes_for_debate_edit_description: "From this number of votes the author of a Debate can no longer edit it"
|
max_votes_for_debate_edit_description: "From this number of votes the author of a Debate can no longer edit it"
|
||||||
proposal_code_prefix: "Prefix for Proposal codes"
|
proposal_code_prefix: "Prefix for Proposal codes"
|
||||||
proposal_code_prefix_description: "This prefix will appear in the Proposals before the creation date and its ID"
|
proposal_code_prefix_description: "This prefix will appear in the Proposals before the creation date and its ID"
|
||||||
|
featured_proposals_number: "Number of featured proposals"
|
||||||
|
featured_proposals_number_description: "Number of featured proposals that will be displayed if the Featured proposals feature is active"
|
||||||
votes_for_proposal_success: "Number of votes necessary for approval of a Proposal"
|
votes_for_proposal_success: "Number of votes necessary for approval of a Proposal"
|
||||||
votes_for_proposal_success_description: "When a proposal reaches this number of supports it will no longer be able to receive more supports and is considered successful"
|
votes_for_proposal_success_description: "When a proposal reaches this number of supports it will no longer be able to receive more supports and is considered successful"
|
||||||
months_to_archive_proposals: "Months to archive Proposals"
|
months_to_archive_proposals: "Months to archive Proposals"
|
||||||
@@ -85,6 +87,8 @@ en:
|
|||||||
google_login_description: "Allow users to sign up with their Google Account"
|
google_login_description: "Allow users to sign up with their Google Account"
|
||||||
proposals: "Proposals"
|
proposals: "Proposals"
|
||||||
proposals_description: "Citizens' proposals are an opportunity for neighbours and collectives to decide directly how they want their city to be, after getting sufficient support and submitting to a citizens' vote"
|
proposals_description: "Citizens' proposals are an opportunity for neighbours and collectives to decide directly how they want their city to be, after getting sufficient support and submitting to a citizens' vote"
|
||||||
|
featured_proposals: "Featured proposals"
|
||||||
|
featured_proposals_description: "Shows featured proposals on index proposals page"
|
||||||
debates: "Debates"
|
debates: "Debates"
|
||||||
debates_description: "The citizens' debate space is aimed at anyone who can present issues that concern them and about which they want to share their views with others"
|
debates_description: "The citizens' debate space is aimed at anyone who can present issues that concern them and about which they want to share their views with others"
|
||||||
polls: "Polls"
|
polls: "Polls"
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ es:
|
|||||||
max_votes_for_debate_edit_description: "A partir de este número de votos el autor de un Debate ya no podrá editarlo"
|
max_votes_for_debate_edit_description: "A partir de este número de votos el autor de un Debate ya no podrá editarlo"
|
||||||
proposal_code_prefix: "Prefijo para los códigos de Propuestas"
|
proposal_code_prefix: "Prefijo para los códigos de Propuestas"
|
||||||
proposal_code_prefix_description: "Este prefijo aparecerá en las Propuestas delante de la fecha de creación y su ID"
|
proposal_code_prefix_description: "Este prefijo aparecerá en las Propuestas delante de la fecha de creación y su ID"
|
||||||
votes_for_proposal_success: "Número de votos necesarios para aprobar una Propuesta"
|
featured_proposals_number: "Número de propuestas destacadas"
|
||||||
|
featured_proposals_number_description: "Número de propuestas destacadas que se mostrarán si la funcionalidad Propuestas destacadas está activa"
|
||||||
|
votes_for_proposal_success: "Número de apoyos necesarios para aprobar una Propuesta"
|
||||||
votes_for_proposal_success_description: "Cuando una propuesta alcance este número de apoyos ya no podrá recibir más y se considera exitosa"
|
votes_for_proposal_success_description: "Cuando una propuesta alcance este número de apoyos ya no podrá recibir más y se considera exitosa"
|
||||||
months_to_archive_proposals: "Meses para archivar las Propuestas"
|
months_to_archive_proposals: "Meses para archivar las Propuestas"
|
||||||
months_to_archive_proposals_description: Pasado este número de meses las Propuestas se archivarán y ya no podrán recoger apoyos
|
months_to_archive_proposals_description: Pasado este número de meses las Propuestas se archivarán y ya no podrán recoger apoyos
|
||||||
@@ -85,6 +87,8 @@ es:
|
|||||||
google_login_description: "Permitir que los usuarios se registren con su cuenta de Google"
|
google_login_description: "Permitir que los usuarios se registren con su cuenta de Google"
|
||||||
proposals: "Propuestas"
|
proposals: "Propuestas"
|
||||||
proposals_description: "Las propuestas ciudadanas son una oportunidad para que los vecinos y colectivos decidan directamente cómo quieren que sea su ciudad, después de conseguir los apoyos suficientes y de someterse a votación ciudadana"
|
proposals_description: "Las propuestas ciudadanas son una oportunidad para que los vecinos y colectivos decidan directamente cómo quieren que sea su ciudad, después de conseguir los apoyos suficientes y de someterse a votación ciudadana"
|
||||||
|
featured_proposals: "Propuestas destacadas"
|
||||||
|
featured_proposals_description: "Muestra propuestas destacadas en la página principal de propuestas"
|
||||||
debates: "Debates"
|
debates: "Debates"
|
||||||
debates_description: "El espacio de debates ciudadanos está dirigido a que cualquier persona pueda exponer temas que le preocupan y sobre los que quiera compartir puntos de vista con otras personas"
|
debates_description: "El espacio de debates ciudadanos está dirigido a que cualquier persona pueda exponer temas que le preocupan y sobre los que quiera compartir puntos de vista con otras personas"
|
||||||
polls: "Votaciones"
|
polls: "Votaciones"
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ section "Creating Settings" do
|
|||||||
|
|
||||||
Setting.create(key: 'feature.debates', value: "true")
|
Setting.create(key: 'feature.debates', value: "true")
|
||||||
Setting.create(key: 'feature.proposals', value: "true")
|
Setting.create(key: 'feature.proposals', value: "true")
|
||||||
|
Setting.create(key: 'feature.featured_proposals', value: "true")
|
||||||
Setting.create(key: 'feature.polls', value: "true")
|
Setting.create(key: 'feature.polls', value: "true")
|
||||||
Setting.create(key: 'feature.spending_proposals', value: nil)
|
Setting.create(key: 'feature.spending_proposals', value: nil)
|
||||||
Setting.create(key: 'feature.spending_proposal_features.voting_allowed', value: nil)
|
Setting.create(key: 'feature.spending_proposal_features.voting_allowed', value: nil)
|
||||||
@@ -65,6 +66,8 @@ section "Creating Settings" do
|
|||||||
Setting.create(key: 'map_latitude', value: 40.41)
|
Setting.create(key: 'map_latitude', value: 40.41)
|
||||||
Setting.create(key: 'map_longitude', value: -3.7)
|
Setting.create(key: 'map_longitude', value: -3.7)
|
||||||
Setting.create(key: 'map_zoom', value: 10)
|
Setting.create(key: 'map_zoom', value: 10)
|
||||||
|
Setting.create(key: 'featured_proposals_number', value: 3)
|
||||||
|
|
||||||
Setting.create(key: 'related_content_score_threshold', value: -0.3)
|
Setting.create(key: 'related_content_score_threshold', value: -0.3)
|
||||||
|
|
||||||
Setting['feature.homepage.widgets.feeds.proposals'] = true
|
Setting['feature.homepage.widgets.feeds.proposals'] = true
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ Setting["meta_keywords"] = nil
|
|||||||
# Feature flags
|
# Feature flags
|
||||||
Setting['feature.debates'] = true
|
Setting['feature.debates'] = true
|
||||||
Setting['feature.proposals'] = true
|
Setting['feature.proposals'] = true
|
||||||
|
Setting['feature.featured_proposals'] = true
|
||||||
Setting['feature.spending_proposals'] = nil
|
Setting['feature.spending_proposals'] = nil
|
||||||
Setting['feature.polls'] = true
|
Setting['feature.polls'] = true
|
||||||
Setting['feature.twitter_login'] = true
|
Setting['feature.twitter_login'] = true
|
||||||
@@ -115,6 +116,9 @@ Setting['mailer_from_address'] = 'noreply@consul.dev'
|
|||||||
Setting['verification_offices_url'] = 'http://oficinas-atencion-ciudadano.url/'
|
Setting['verification_offices_url'] = 'http://oficinas-atencion-ciudadano.url/'
|
||||||
Setting['min_age_to_participate'] = 16
|
Setting['min_age_to_participate'] = 16
|
||||||
|
|
||||||
|
# Featured proposals
|
||||||
|
Setting['featured_proposals_number'] = 3
|
||||||
|
|
||||||
# Proposal improvement url path ('/help/proposal-improvement')
|
# Proposal improvement url path ('/help/proposal-improvement')
|
||||||
Setting['proposal_improvement_path'] = nil
|
Setting['proposal_improvement_path'] = nil
|
||||||
|
|
||||||
|
|||||||
@@ -25,4 +25,10 @@ namespace :settings do
|
|||||||
Setting['feature.help_page'] = true
|
Setting['feature.help_page'] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "Enable Featured proposals"
|
||||||
|
task enable_featured_proposals: :environment do
|
||||||
|
Setting['feature.featured_proposals'] = true
|
||||||
|
Setting['featured_proposals_number'] = 3
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ feature 'Proposals' do
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
Setting['feature.allow_images'] = true
|
Setting['feature.allow_images'] = true
|
||||||
|
Setting['feature.featured_proposals'] = true
|
||||||
|
Setting['featured_proposals_number'] = 3
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
@@ -92,6 +94,7 @@ feature 'Proposals' do
|
|||||||
click_link "Next", exact: false
|
click_link "Next", exact: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expect(page).to have_selector('#proposals .proposal-featured', count: 3)
|
||||||
expect(page).to have_selector('#proposals .proposal', count: 2)
|
expect(page).to have_selector('#proposals .proposal', count: 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ module Proposals
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_featured_proposals
|
def create_featured_proposals
|
||||||
[create(:proposal, :with_confidence_score, cached_votes_up: 100),
|
[create(:proposal, :with_confidence_score, cached_votes_up: 200),
|
||||||
create(:proposal, :with_confidence_score, cached_votes_up: 90),
|
create(:proposal, :with_confidence_score, cached_votes_up: 100),
|
||||||
create(:proposal, :with_confidence_score, cached_votes_up: 80)]
|
create(:proposal, :with_confidence_score, cached_votes_up: 90)]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user