adds links to filter retired proposals by reason
This commit is contained in:
@@ -25,6 +25,7 @@ class ProposalsController < ApplicationController
|
|||||||
def index_customization
|
def index_customization
|
||||||
if params[:retired].present?
|
if params[:retired].present?
|
||||||
@resources = @resources.retired
|
@resources = @resources.retired
|
||||||
|
@resources = @resources.where(retired_reason: params[:retired]) if Proposal::RETIRE_OPTIONS.include?(params[:retired])
|
||||||
else
|
else
|
||||||
@resources = @resources.not_retired
|
@resources = @resources.not_retired
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,5 +2,12 @@
|
|||||||
<h3 class="sidebar-title"><%= t("proposals.index.retired_proposals") %></h3>
|
<h3 class="sidebar-title"><%= t("proposals.index.retired_proposals") %></h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= link_to t("proposals.index.retired_proposals_link"), proposals_path(retired: 1), class: "small" %><br>
|
<% if params[:retired].blank? %>
|
||||||
|
<%= link_to t("proposals.index.retired_proposals_link"), proposals_path(retired: 'all'), class: "small" %><br>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to t("proposals.index.retired_links.all"), proposals_path(retired: 'all'), ({class: "small"} unless params[:retired] == 'all') %><br>
|
||||||
|
<% Proposal::RETIRE_OPTIONS.each do |option| %>
|
||||||
|
<%= link_to t("proposals.index.retired_links.#{option}"), proposals_path(retired: option), ({class: "small"} unless params[:retired] == option) %><br>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render "shared/advanced_search", search_path: proposals_path(page: 1)%>
|
<%= render("shared/advanced_search", search_path: proposals_path(page: 1)) unless params[:retired].present? %>
|
||||||
|
|
||||||
<%= render 'shared/order_links', i18n_namespace: "proposals.index" %>
|
<%= render 'shared/order_links', i18n_namespace: "proposals.index" %>
|
||||||
|
|
||||||
@@ -55,10 +55,12 @@
|
|||||||
<div class="small-12 medium-3 column">
|
<div class="small-12 medium-3 column">
|
||||||
<aside class="margin-bottom">
|
<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_path, class: 'button expanded' %>
|
||||||
|
<% if params[:retired].blank? %>
|
||||||
<%= render "shared/tag_cloud", taggable: 'proposal' %>
|
<%= render "shared/tag_cloud", taggable: 'proposal' %>
|
||||||
<%= render 'categories' %>
|
<%= render 'categories' %>
|
||||||
<%= render 'geozones' %>
|
<%= render 'geozones' %>
|
||||||
<%= render 'popular' %>
|
<%= render 'popular' %>
|
||||||
|
<% end %>
|
||||||
<%= render 'retired' %>
|
<%= render 'retired' %>
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -297,7 +297,14 @@ en:
|
|||||||
most_commented: most commented
|
most_commented: most commented
|
||||||
relevance: relevance
|
relevance: relevance
|
||||||
retired_proposals: Retired proposals
|
retired_proposals: Retired proposals
|
||||||
retired_proposals_link: "Proposals retired by the author (duplicated, unfeasibles, done, etc.)"
|
retired_proposals_link: "Proposals retired by the author"
|
||||||
|
retired_links:
|
||||||
|
all: All
|
||||||
|
duplicated: Duplicated
|
||||||
|
started: Underway
|
||||||
|
unfeasible: Unfeasible
|
||||||
|
done: Done
|
||||||
|
other: Other
|
||||||
search_form:
|
search_form:
|
||||||
button: Search
|
button: Search
|
||||||
placeholder: Search proposals...
|
placeholder: Search proposals...
|
||||||
|
|||||||
@@ -297,7 +297,14 @@ es:
|
|||||||
most_commented: Más comentadas
|
most_commented: Más comentadas
|
||||||
relevance: Más relevantes
|
relevance: Más relevantes
|
||||||
retired_proposals: Propuestas retiradas
|
retired_proposals: Propuestas retiradas
|
||||||
retired_proposals_link: "Propuestas retiradas por sus autores (realizadas, en ejecución, inviables, duplicadas, etc.)"
|
retired_proposals_link: "Propuestas retiradas por sus autores"
|
||||||
|
retired_links:
|
||||||
|
all: Todas
|
||||||
|
duplicated: Duplicadas
|
||||||
|
started: Empezadas
|
||||||
|
unfeasible: Inviables
|
||||||
|
done: Hechas
|
||||||
|
other: Otras
|
||||||
search_form:
|
search_form:
|
||||||
button: Buscar
|
button: Buscar
|
||||||
placeholder: Buscar propuestas...
|
placeholder: Buscar propuestas...
|
||||||
|
|||||||
@@ -489,11 +489,39 @@ feature 'Proposals' do
|
|||||||
visit proposals_path
|
visit proposals_path
|
||||||
|
|
||||||
expect(page).to_not have_content retired.title
|
expect(page).to_not have_content retired.title
|
||||||
click_link 'Proposals retired by the author (duplicated, unfeasibles, done, etc.)'
|
click_link 'Proposals retired by the author'
|
||||||
|
|
||||||
expect(page).to have_content retired.title
|
expect(page).to have_content retired.title
|
||||||
expect(page).to_not have_content not_retired.title
|
expect(page).to_not have_content not_retired.title
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario 'Retired proposals index interface elements' do
|
||||||
|
visit proposals_path(retired: 'all')
|
||||||
|
|
||||||
|
expect(page).to_not have_content 'Advanced search'
|
||||||
|
expect(page).to_not have_content 'Categories'
|
||||||
|
expect(page).to_not have_content 'Districts'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Retired proposals index has links to filter by retired_reason' do
|
||||||
|
unfeasible = create(:proposal, retired_at: Time.now, retired_reason: 'unfeasible')
|
||||||
|
duplicated = create(:proposal, retired_at: Time.now, retired_reason: 'duplicated')
|
||||||
|
|
||||||
|
visit proposals_path(retired: 'all')
|
||||||
|
|
||||||
|
expect(page).to have_content unfeasible.title
|
||||||
|
expect(page).to have_content duplicated.title
|
||||||
|
expect(page).to have_link 'Duplicated'
|
||||||
|
expect(page).to have_link 'Underway'
|
||||||
|
expect(page).to have_link 'Unfeasible'
|
||||||
|
expect(page).to have_link 'Done'
|
||||||
|
expect(page).to have_link 'Other'
|
||||||
|
|
||||||
|
click_link 'Unfeasible'
|
||||||
|
|
||||||
|
expect(page).to have_content unfeasible.title
|
||||||
|
expect(page).to_not have_content duplicated.title
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Update should not be posible if logged user is not the author' do
|
scenario 'Update should not be posible if logged user is not the author' do
|
||||||
|
|||||||
Reference in New Issue
Block a user