removes retired proposals from default index
adds a sidebar link to retired proposals list
This commit is contained in:
@@ -23,7 +23,13 @@ class ProposalsController < ApplicationController
|
||||
end
|
||||
|
||||
def index_customization
|
||||
@featured_proposals = Proposal.all.sort_by_confidence_score.limit(3) if (!@advanced_search_terms && @search_terms.blank? && @tag_filter.blank?)
|
||||
if params[:retired].present?
|
||||
@resources = @resources.retired
|
||||
else
|
||||
@resources = @resources.not_retired
|
||||
end
|
||||
|
||||
@featured_proposals = Proposal.all.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))
|
||||
|
||||
@@ -46,6 +46,7 @@ class Proposal < ActiveRecord::Base
|
||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||
scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago)}
|
||||
scope :retired, -> { where.not(retired_at: nil) }
|
||||
scope :not_retired, -> { where(retired_at: nil) }
|
||||
|
||||
def to_param
|
||||
"#{id}-#{title}".parameterize
|
||||
|
||||
6
app/views/proposals/_retired.html.erb
Normal file
6
app/views/proposals/_retired.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<div class="sidebar-divider"></div>
|
||||
<h3 class="sidebar-title"><%= t("proposals.index.retired_proposals") %></h3>
|
||||
|
||||
<p>
|
||||
<%= link_to t("proposals.index.retired_proposals_link"), proposals_path(retired: 1), class: "small" %><br>
|
||||
</p>
|
||||
@@ -22,6 +22,8 @@
|
||||
<%= page_entries_info @proposals %>
|
||||
<%= t("proposals.index.filter_topic", count: @proposals.size, topic: @tag_filter) %>
|
||||
</h2>
|
||||
<% elsif params[:retired].present? %>
|
||||
<h2><%= t("proposals.index.retired_proposals") %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -57,6 +59,7 @@
|
||||
<%= render 'categories' %>
|
||||
<%= render 'geozones' %>
|
||||
<%= render 'popular' %>
|
||||
<%= render 'retired' %>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -296,6 +296,8 @@ en:
|
||||
hot_score: most active
|
||||
most_commented: most commented
|
||||
relevance: relevance
|
||||
retired_proposals: Retired proposals
|
||||
retired_proposals_link: "Proposals retired by the author (duplicated, unfeasibles, done, etc.)"
|
||||
search_form:
|
||||
button: Search
|
||||
placeholder: Search proposals...
|
||||
|
||||
@@ -296,6 +296,8 @@ es:
|
||||
hot_score: Más activas hoy
|
||||
most_commented: Más comentadas
|
||||
relevance: Más relevantes
|
||||
retired_proposals: Propuestas retiradas
|
||||
retired_proposals_link: "Propuestas retiradas por sus autores (realizadas, en ejecución, inviables, duplicadas, etc.)"
|
||||
search_form:
|
||||
button: Buscar
|
||||
placeholder: Buscar propuestas...
|
||||
|
||||
@@ -430,7 +430,7 @@ feature 'Proposals' do
|
||||
|
||||
end
|
||||
|
||||
context 'Retire a proposal' do
|
||||
context 'Retired proposals' do
|
||||
scenario 'Retire' do
|
||||
proposal = create(:proposal)
|
||||
login_as(proposal.author)
|
||||
@@ -466,6 +466,34 @@ feature 'Proposals' do
|
||||
expect(page).to_not have_content 'Proposal retired'
|
||||
expect(page).to have_content "can't be blank", count: 2
|
||||
end
|
||||
|
||||
scenario 'Index do not list retired proposals by default' do
|
||||
create_featured_proposals
|
||||
not_retired = create(:proposal)
|
||||
retired = create(:proposal, retired_at: Time.now)
|
||||
|
||||
visit proposals_path
|
||||
|
||||
expect(page).to have_selector('#proposals .proposal', count: 1)
|
||||
within('#proposals') do
|
||||
expect(page).to have_content not_retired.title
|
||||
expect(page).to_not have_content retired.title
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Index has a link to retired proposals list' do
|
||||
create_featured_proposals
|
||||
not_retired = create(:proposal)
|
||||
retired = create(:proposal, retired_at: Time.now)
|
||||
|
||||
visit proposals_path
|
||||
|
||||
expect(page).to_not have_content retired.title
|
||||
click_link 'Proposals retired by the author (duplicated, unfeasibles, done, etc.)'
|
||||
|
||||
expect(page).to have_content retired.title
|
||||
expect(page).to_not have_content not_retired.title
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Update should not be posible if logged user is not the author' do
|
||||
|
||||
@@ -758,6 +758,13 @@ describe Proposal do
|
||||
expect(retired.size).to eq(1)
|
||||
expect(retired.first).to eq(@proposal2)
|
||||
end
|
||||
|
||||
it "scope not_retired" do
|
||||
not_retired = Proposal.not_retired
|
||||
|
||||
expect(not_retired.size).to eq(1)
|
||||
expect(not_retired.first).to eq(@proposal1)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user