From 6ab6986d9e4b7eb10299f4c987d2a74b195c67b8 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Fri, 5 May 2017 19:07:37 +0200 Subject: [PATCH] adds unselected investment link --- app/models/budget/investment.rb | 7 ++++++- app/views/budgets/groups/show.html.erb | 22 +++++++++++++++++++--- app/views/budgets/show.html.erb | 21 +++++++++++++++++---- config/locales/budgets.en.yml | 6 +++++- config/locales/budgets.es.yml | 4 ++++ 5 files changed, 51 insertions(+), 9 deletions(-) diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 0d730945b..e8fec254f 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -47,6 +47,7 @@ class Budget scope :undecided, -> { where(feasibility: "undecided") } scope :with_supports, -> { where('cached_votes_up > 0') } scope :selected, -> { where(selected: true) } + scope :unselected, -> { where(selected: false) } scope :last_week, -> { where("created_at >= ?", 7.days.ago)} scope :by_group, -> (group_id) { where(group_id: group_id) } @@ -235,11 +236,15 @@ class Budget def self.apply_filters_and_search(budget, params) investments = all - if budget.balloting? + + if budget.balloting? && params[:unfeasible].blank? && params[:unselected].blank? investments = investments.selected + elsif budget.balloting? && params[:unfeasible].blank? + investments = investments.feasible.unselected else investments = params[:unfeasible].present? ? investments.unfeasible : investments.not_unfeasible end + investments = investments.by_heading(params[:heading_id]) if params[:heading_id].present? investments = investments.search(params[:search]) if params[:search].present? investments diff --git a/app/views/budgets/groups/show.html.erb b/app/views/budgets/groups/show.html.erb index 73fb3288f..8fbe028b3 100644 --- a/app/views/budgets/groups/show.html.erb +++ b/app/views/budgets/groups/show.html.erb @@ -13,9 +13,15 @@

<%= t("budgets.groups.show.unfeasible_title") %>

+<% elsif params[:unselected] %> +
+
+

<%= t("budgets.groups.show.unselected_title") %>

+
+
<% end %> -
+
<% @group.headings.each_slice(7) do |slice| %> @@ -25,7 +31,8 @@ class="<%= css_for_ballot_heading(heading) %>"> <%= link_to heading.name, budget_investments_path(heading_id: heading.id, - unfeasible: params[:unfeasible]), + unfeasible: params[:unfeasible], + unselected: params[:unselected]), data: { no_turbolink: true } %>
<% end %> @@ -40,10 +47,19 @@
<% if params[:unfeasible].blank? %> -
+
<%= link_to t("budgets.groups.show.unfeasible"), budget_path(@budget, unfeasible: 1) %>
<% end %> + +<% if params[:unselected].blank? %> +
+
+ <%= link_to t("budgets.groups.show.unselected"), + budget_path(@budget, unselected: 1) %> +
+
+<% end %> diff --git a/app/views/budgets/show.html.erb b/app/views/budgets/show.html.erb index e49cd4252..d6a571b46 100644 --- a/app/views/budgets/show.html.erb +++ b/app/views/budgets/show.html.erb @@ -35,10 +35,12 @@
-
+
<% if params[:unfeasible] %>

<%= t("budgets.show.unfeasible_title") %>

+ <% elsif params[:unselected] %> +

<%= t("budgets.show.unselected_title") %>

<% end %> @@ -52,12 +54,14 @@ <%= link_to group.name, budget_investments_path(@budget, heading_id: group.headings.first.id, - unfeasible: params[:unfeasible]), + unfeasible: params[:unfeasible], + unselected: params[:unselected]), data: { no_turbolink: true } %> <% else %> <%= link_to group.name, budget_group_path(@budget, group, - unfeasible: params[:unfeasible]) %> + unfeasible: params[:unfeasible], + unselected: params[:unselected]) %> <% end %>
@@ -69,10 +73,19 @@ <% unless params[:unfeasible] %> -
+
<%= link_to t("budgets.show.unfeasible"), budget_path(@budget, unfeasible: 1) %>
<% end %> + +<% unless params[:unselected] %> +
+
+ <%= link_to t("budgets.show.unselected"), + budget_path(@budget, unselected: 1) %> +
+
+<% end %> diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml index 2774dcfbd..49d1558cf 100644 --- a/config/locales/budgets.en.yml +++ b/config/locales/budgets.en.yml @@ -24,6 +24,8 @@ en: title: Select an option unfeasible_title: Unfeasible investments unfeasible: See unfeasible investments + unselected_title: Investments not selected for balloting phase + unselected: See investments not selected for balloting phase phase: accepting: Accepting projects reviewing: Reviewing projects @@ -107,4 +109,6 @@ en: group: Group phase: Actual phase unfeasible_title: Unfeasible investments - unfeasible: See unfeasible investments \ No newline at end of file + unfeasible: See unfeasible investments + unselected_title: Investments not selected for balloting phase + unselected: See investments not selected for balloting phase \ No newline at end of file diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml index 84d10228a..98ef4ad4e 100644 --- a/config/locales/budgets.es.yml +++ b/config/locales/budgets.es.yml @@ -24,6 +24,8 @@ es: title: Selecciona una opción unfeasible_title: Propuestas inviables unfeasible: Ver propuestas inviables + unselected_title: Propuestas que no pasan a la votación final + unselected: Ver las propuestas que no pasan a la votación final phase: accepting: Presentación de proyectos reviewing: Revisión interna de proyectos @@ -108,3 +110,5 @@ es: phase: Fase actual unfeasible_title: Propuestas inviables unfeasible: Ver las propuestas inviables + unselected_title: Propuestas que no pasan a la votación final + unselected: Ver las propuestas que no pasan a la votación final \ No newline at end of file