Merge branch 'master' into polling-views-plus

This commit is contained in:
Juanjo Bazán
2016-10-19 13:50:08 +02:00
68 changed files with 1063 additions and 136 deletions

View File

@@ -12,7 +12,7 @@ module CommentableActions
@tag_cloud = tag_cloud
@banners = Banner.with_active
set_resource_votes(@resources)
set_resources_instance
end

View File

@@ -22,6 +22,7 @@ class DebatesController < ApplicationController
def index_customization
@featured_debates = @debates.featured
@proposal_successfull_exists = Proposal.successfull.exists?
end
def show

View File

@@ -0,0 +1,8 @@
class ProposalBallotsController < ApplicationController
skip_authorization_check
def index
@proposal_ballots = Proposal.successfull.sort_by_confidence_score
end
end

View File

@@ -12,7 +12,7 @@ class ProposalsController < ApplicationController
invisible_captcha only: [:create, :update], honeypot: :subtitle
has_orders %w{hot_score confidence_score created_at relevance}, only: :index
has_orders %w{hot_score confidence_score created_at relevance archival_date}, only: :index
has_orders %w{most_voted newest oldest}, only: :show
load_and_authorize_resource
@@ -26,8 +26,10 @@ class ProposalsController < ApplicationController
end
def index_customization
discard_archived
load_retired
load_featured
load_proposal_ballots
load_featured unless @proposal_successfull_exists
end
def vote
@@ -80,6 +82,10 @@ class ProposalsController < ApplicationController
@featured_proposals_votes = current_user ? current_user.proposal_votes(proposals) : {}
end
def discard_archived
@resources = @resources.not_archived unless @current_order == "archival_date"
end
def load_retired
if params[:retired].present?
@resources = @resources.retired
@@ -90,11 +96,15 @@ class ProposalsController < ApplicationController
end
def load_featured
@featured_proposals = Proposal.all.sort_by_confidence_score.limit(3) if (!@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank?)
@featured_proposals = Proposal.not_archived.sort_by_confidence_score.limit(3) if (!@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank?)
if @featured_proposals.present?
set_featured_proposal_votes(@featured_proposals)
@resources = @resources.where('proposals.id NOT IN (?)', @featured_proposals.map(&:id))
end
end
def load_proposal_ballots
@proposal_successfull_exists = Proposal.successfull.exists?
end
end