Displays budget groups

This commit is contained in:
rgarcia
2016-09-09 15:43:54 +02:00
parent 1c8f4d5ff0
commit 9d4f2d1aff
9 changed files with 63 additions and 14 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,28 @@
<div class="row investment-projects-scope margin-bottom no-margin-top">
<div id="select-district" class="small-12 medium-7 column select-district">
<%# link_to participatory_budget_path, class: "back" do %>
<span class="icon-angle-left"></span>
<%= t('shared.back') %>
<%# end %>
<h2><%# t("spending_proposals.welcome.districts") %></h2>
<div class="row">
<% @group.headings.each_slice(7) do |slice| %>
<div class="small-6 medium-4 column end">
<% slice.each do |heading| %>
<span id="<%= dom_id(heading) %>"
class="<%= css_for_ballot_heading(heading) %>">
<%= link_to heading.name, budget_investments_path(heading_id: heading.id),
data: { no_turbolink: true } %><br>
</span>
<% end %>
</div>
<% end %>
</div>
</div>
<div class="medium-5 column show-for-medium text-center margin-top">
<%= image_tag "map.jpg" %>
</div>
</div>

View File

@@ -17,24 +17,12 @@
<table class="table-fixed">
<thead>
<th><%= t('budget.show.heading') %></th>
<th><%= t('budget.show.price') %></th>
</thead>
<tbody>
<tr>
<td>
<%= link_to t('budget.show.no_heading'), budget_investments_path(budget_id: @budget.id, heading_id: nil) %>
</td>
<td>
<%# format_price(@budget, @budget.price) %>
</td>
</tr>
<% @budget.headings.each do |heading| %>
<% @budget.groups.each do |group| %>
<tr>
<td>
<%= link_to heading.name, budget_investments_path(budget_id: @budget.id, heading_id: heading.id) %>
</td>
<td>
<%= format_price(@budget, heading.price) %>
<%= link_to group.name, budget_group_path(@budget, group) %>
</td>
</tr>
<% end %>

View File

@@ -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

View File

@@ -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

View File

@@ -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