diff --git a/app/controllers/budgets/groups_controller.rb b/app/controllers/budgets/groups_controller.rb new file mode 100644 index 000000000..e55974a6a --- /dev/null +++ b/app/controllers/budgets/groups_controller.rb @@ -0,0 +1,10 @@ +module Budgets + class GroupsController < ApplicationController + load_and_authorize_resource :budget + load_and_authorize_resource :group, class: "Budget::Group" + + def show + end + + end +end \ No newline at end of file diff --git a/app/helpers/budget_helper.rb b/app/helpers/budget_helper.rb index 745ea88f6..af239f074 100644 --- a/app/helpers/budget_helper.rb +++ b/app/helpers/budget_helper.rb @@ -24,4 +24,13 @@ module BudgetHelper def display_budget_countdown?(budget) budget.balloting? end + + def css_for_ballot_heading(heading) + return '' unless current_ballot.present? + current_ballot.has_lines_in_heading?(heading) ? 'active' : '' + end + + def current_ballot + Budget::Ballot.where(user: current_user, budget: @budget).first + end end diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb index 30c1c3b55..cf8af477b 100644 --- a/app/models/abilities/everyone.rb +++ b/app/models/abilities/everyone.rb @@ -13,6 +13,7 @@ module Abilities can :read, User can [:search, :read], Annotation can [:read], Budget + can [:read], Budget::Group can [:read], Budget::Investment can :new, DirectMessage end diff --git a/app/models/budget/ballot.rb b/app/models/budget/ballot.rb index 848e2f22d..b28c7d859 100644 --- a/app/models/budget/ballot.rb +++ b/app/models/budget/ballot.rb @@ -40,6 +40,10 @@ class Budget self.heading_id.present? end + def has_lines_in_heading?(heading) + investments.by_heading(heading.id).any? + end + def has_investment?(investment) self.investment_ids.include?(investment.id) end diff --git a/app/views/budgets/groups/show.html.erb b/app/views/budgets/groups/show.html.erb new file mode 100644 index 000000000..8f9f9ae86 --- /dev/null +++ b/app/views/budgets/groups/show.html.erb @@ -0,0 +1,28 @@ +
+
+ <%# link_to participatory_budget_path, class: "back" do %> + + <%= t('shared.back') %> + <%# end %> + +

<%# t("spending_proposals.welcome.districts") %>

+ +
+ <% @group.headings.each_slice(7) do |slice| %> +
+ <% slice.each do |heading| %> + + <%= link_to heading.name, budget_investments_path(heading_id: heading.id), + data: { no_turbolink: true } %>
+
+ <% end %> +
+ <% end %> +
+
+ +
+ <%= image_tag "map.jpg" %> +
+
\ No newline at end of file diff --git a/app/views/budgets/show.html.erb b/app/views/budgets/show.html.erb index 521b6fb06..1e4fed892 100644 --- a/app/views/budgets/show.html.erb +++ b/app/views/budgets/show.html.erb @@ -17,24 +17,12 @@ - - - - - - <% @budget.headings.each do |heading| %> + <% @budget.groups.each do |group| %> - <% end %> diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml index ae8c6b08a..953c263d3 100644 --- a/config/locales/budgets.en.yml +++ b/config/locales/budgets.en.yml @@ -18,6 +18,9 @@ en: selecting: Selecting balloting: Balloting finished: Finished + groups: + index: + group_title: "Groups" headings: none: Whole City all: All scopes @@ -101,6 +104,7 @@ en: check_ballot: Check my ballot different_heading_active: You have active votes in another district. show: + group: Group heading: Heading price: Price no_heading: No Heading \ No newline at end of file diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml index 667b39617..db9e480da 100644 --- a/config/locales/budgets.es.yml +++ b/config/locales/budgets.es.yml @@ -18,6 +18,9 @@ es: selecting: Fase de selección balloting: Fase de Votación finished: Terminado + groups: + index: + group_title: "Grupos" headings: none: Toda la ciudad all: Todos los ámbitos @@ -101,6 +104,7 @@ es: check_ballot: Revisar mis votos different_heading_active: Ya apoyaste propuestas de otro distrito. show: + group: Grupo heading: Partida price: Cantidad no_heading: Sin línea \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index c10b4ba2b..19cdf89b3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -70,6 +70,7 @@ Rails.application.routes.draw do end resources :budgets, only: [:show, :index] do + resources :groups, controller: "budgets/groups", only: [:show] resources :investments, controller: "budgets/investments", only: [:index, :new, :create, :show, :destroy] do member { post :vote } end
<%= t('budget.show.heading') %><%= t('budget.show.price') %>
- <%= link_to t('budget.show.no_heading'), budget_investments_path(budget_id: @budget.id, heading_id: nil) %> - - <%# format_price(@budget, @budget.price) %> -
- <%= link_to heading.name, budget_investments_path(budget_id: @budget.id, heading_id: heading.id) %> - - <%= format_price(@budget, heading.price) %> + <%= link_to group.name, budget_group_path(@budget, group) %>