Merge pull request #3023 from consul/budget-executions
[Backport] Budget executions
This commit is contained in:
@@ -760,6 +760,10 @@
|
|||||||
|
|
||||||
&.past-budgets {
|
&.past-budgets {
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
|
|
||||||
|
.button ~ .button {
|
||||||
|
margin-left: $line-height / 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1691,9 +1695,10 @@
|
|||||||
|
|
||||||
img {
|
img {
|
||||||
height: $line-height * 9;
|
height: $line-height * 9;
|
||||||
|
min-width: 100%;
|
||||||
|
max-width: none;
|
||||||
transition-duration: 0.3s;
|
transition-duration: 0.3s;
|
||||||
transition-property: transform;
|
transition-property: transform;
|
||||||
width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ module Budgets
|
|||||||
.joins(:milestones).includes(:milestones)
|
.joins(:milestones).includes(:milestones)
|
||||||
.select { |i| i.milestones.published.with_status
|
.select { |i| i.milestones.published.with_status
|
||||||
.order_by_publication_date.last
|
.order_by_publication_date.last
|
||||||
.status_id == params[:status].to_i }
|
.try(:status_id) == params[:status].to_i }
|
||||||
.uniq
|
.uniq
|
||||||
.group_by(&:heading)
|
.group_by(&:heading)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -6,4 +6,9 @@ module BudgetExecutionsHelper
|
|||||||
.last.status_id == status rescue false }.count
|
.last.status_id == status rescue false }.count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def first_milestone_with_image(investment)
|
||||||
|
investment.milestones.order_by_publication_date
|
||||||
|
.select{ |milestone| milestone.image.present? }.last
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class Budget
|
|||||||
validates :publication_date, presence: true
|
validates :publication_date, presence: true
|
||||||
validate :description_or_status_present?
|
validate :description_or_status_present?
|
||||||
|
|
||||||
scope :order_by_publication_date, -> { order(publication_date: :asc) }
|
scope :order_by_publication_date, -> { order(publication_date: :asc, created_at: :asc) }
|
||||||
scope :published, -> { where("publication_date <= ?", Date.current) }
|
scope :published, -> { where("publication_date <= ?", Date.current) }
|
||||||
scope :with_status, -> { where("status_id IS NOT NULL") }
|
scope :with_status, -> { where("status_id IS NOT NULL") }
|
||||||
|
|
||||||
|
|||||||
9
app/views/budgets/executions/_image.html.erb
Normal file
9
app/views/budgets/executions/_image.html.erb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<% milestone = first_milestone_with_image(investment) %>
|
||||||
|
|
||||||
|
<% if milestone&.image.present? %>
|
||||||
|
<%= image_tag milestone.image_url(:large), alt: milestone.image.title %>
|
||||||
|
<% elsif investment.image.present? %>
|
||||||
|
<%= image_tag investment.image_url(:large), alt: investment.image.title %>
|
||||||
|
<% else %>
|
||||||
|
<%= image_tag "budget_execution_no_image.jpg", alt: investment.title %>
|
||||||
|
<% end %>
|
||||||
@@ -7,15 +7,7 @@
|
|||||||
<div class="small-12 medium-6 large-4 column end margin-bottom">
|
<div class="small-12 medium-6 large-4 column end margin-bottom">
|
||||||
<div class="budget-execution">
|
<div class="budget-execution">
|
||||||
<%= link_to budget_investment_path(@budget, investment, anchor: "tab-milestones"), data: { 'equalizer-watch': true } do %>
|
<%= link_to budget_investment_path(@budget, investment, anchor: "tab-milestones"), data: { 'equalizer-watch': true } do %>
|
||||||
<% investment.milestones.order(publication_date: :desc).limit(1).each do |milestone| %>
|
<%= render 'image', investment: investment %>
|
||||||
<% if milestone.image.present? %>
|
|
||||||
<%= image_tag milestone.image_url(:large), alt: milestone.image.title %>
|
|
||||||
<% elsif investment.image.present? %>
|
|
||||||
<%= image_tag investment.image_url(:thumb), alt: investment.image.title %>
|
|
||||||
<% else %>
|
|
||||||
<%= image_tag "budget_execution_no_image.jpg", alt: investment.title %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<div class="budget-execution-info">
|
<div class="budget-execution-info">
|
||||||
<div class="budget-execution-content">
|
<div class="budget-execution-content">
|
||||||
<h5><%= investment.title %></h5>
|
<h5><%= investment.title %></h5>
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
<div class="small-12 medium-9 large-10 column">
|
<div class="small-12 medium-9 large-10 column">
|
||||||
<%= form_tag(budget_executions_path(@budget), method: :get) do %>
|
<%= form_tag(budget_executions_path(@budget), method: :get) do %>
|
||||||
<div class="small-12 medium-3 column">
|
<div class="small-12 medium-3 column">
|
||||||
<%= label_tag t("budgets.executions.filters.label") %>
|
<%= label_tag :status, t("budgets.executions.filters.label") %>
|
||||||
<%= select_tag :status,
|
<%= select_tag :status,
|
||||||
options_from_collection_for_select(@statuses,
|
options_from_collection_for_select(@statuses,
|
||||||
:id, lambda { |s| "#{s.name} (#{filters_select_counts(s.id)})" },
|
:id, lambda { |s| "#{s.name} (#{filters_select_counts(s.id)})" },
|
||||||
|
|||||||
@@ -136,17 +136,20 @@
|
|||||||
<div class="budget-investment clear">
|
<div class="budget-investment clear">
|
||||||
<div class="panel past-budgets">
|
<div class="panel past-budgets">
|
||||||
<div class="row" data-equalizer data-equalizer-on="medium">
|
<div class="row" data-equalizer data-equalizer-on="medium">
|
||||||
<div class="small-12 medium-9 column table" data-equalizer-watch>
|
<div class="small-12 medium-6 column table" data-equalizer-watch>
|
||||||
<div class="table-cell align-middle">
|
<div class="table-cell align-middle">
|
||||||
<h3><%= budget.name %></h3>
|
<h3><%= budget.name %></h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 medium-3 column table" data-equalizer-watch>
|
<div class="small-12 medium-6 column table" data-equalizer-watch>
|
||||||
<div id="budget_<%= budget.id %>_results" class="table-cell align-middle">
|
<div id="budget_<%= budget.id %>_results" class="table-cell align-middle">
|
||||||
<%= link_to t("budgets.index.see_results"),
|
<%= link_to t("budgets.index.see_results"),
|
||||||
budget_results_path(budget.id),
|
budget_results_path(budget.id),
|
||||||
class: "button expanded" %>
|
class: "button" %>
|
||||||
|
<%= link_to t("budgets.index.milestones"),
|
||||||
|
budget_executions_path(budget.id),
|
||||||
|
class: "button" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ en:
|
|||||||
section_footer:
|
section_footer:
|
||||||
title: Help with participatory budgets
|
title: Help with participatory budgets
|
||||||
description: With the participatory budgets the citizens decide to which projects is destined a part of the budget.
|
description: With the participatory budgets the citizens decide to which projects is destined a part of the budget.
|
||||||
|
milestones: Milestones
|
||||||
investments:
|
investments:
|
||||||
form:
|
form:
|
||||||
tag_category_label: "Categories"
|
tag_category_label: "Categories"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ es:
|
|||||||
section_footer:
|
section_footer:
|
||||||
title: Ayuda sobre presupuestos participativos
|
title: Ayuda sobre presupuestos participativos
|
||||||
description: Con los presupuestos participativos la ciudadanía decide a qué proyectos va destinada una parte del presupuesto.
|
description: Con los presupuestos participativos la ciudadanía decide a qué proyectos va destinada una parte del presupuesto.
|
||||||
|
milestones: Seguimiento de proyectos
|
||||||
investments:
|
investments:
|
||||||
form:
|
form:
|
||||||
tag_category_label: "Categorías"
|
tag_category_label: "Categorías"
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ feature 'Executions' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'Images' do
|
context 'Images' do
|
||||||
|
|
||||||
scenario 'renders milestone image if available' do
|
scenario 'renders milestone image if available' do
|
||||||
milestone1 = create(:budget_investment_milestone, investment: investment1)
|
milestone1 = create(:budget_investment_milestone, investment: investment1)
|
||||||
create(:image, imageable: milestone1)
|
create(:image, imageable: milestone1)
|
||||||
@@ -101,13 +102,19 @@ feature 'Executions' do
|
|||||||
|
|
||||||
scenario "renders last milestone's image if investment has multiple milestones with images associated" do
|
scenario "renders last milestone's image if investment has multiple milestones with images associated" do
|
||||||
milestone1 = create(:budget_investment_milestone, investment: investment1,
|
milestone1 = create(:budget_investment_milestone, investment: investment1,
|
||||||
publication_date: 2.weeks.ago)
|
publication_date: Date.yesterday)
|
||||||
|
|
||||||
milestone2 = create(:budget_investment_milestone, investment: investment1,
|
milestone2 = create(:budget_investment_milestone, investment: investment1,
|
||||||
publication_date: Date.yesterday)
|
publication_date: Date.yesterday)
|
||||||
|
|
||||||
create(:image, imageable: milestone1, title: 'First milestone image')
|
milestone3 = create(:budget_investment_milestone, investment: investment1,
|
||||||
create(:image, imageable: milestone2, title: 'Second milestone image')
|
publication_date: Date.yesterday)
|
||||||
|
|
||||||
|
milestone4 = create(:budget_investment_milestone, investment: investment1,
|
||||||
|
publication_date: Date.yesterday)
|
||||||
|
|
||||||
|
create(:image, imageable: milestone2, title: 'Image for first milestone with image')
|
||||||
|
create(:image, imageable: milestone3, title: 'Image for second milestone with image')
|
||||||
|
|
||||||
visit budget_path(budget)
|
visit budget_path(budget)
|
||||||
|
|
||||||
@@ -115,9 +122,9 @@ feature 'Executions' do
|
|||||||
click_link 'Milestones'
|
click_link 'Milestones'
|
||||||
|
|
||||||
expect(page).to have_content(investment1.title)
|
expect(page).to have_content(investment1.title)
|
||||||
expect(page).to have_css("img[alt='#{milestone2.image.title}']")
|
expect(page).to have_css("img[alt='#{milestone3.image.title}']")
|
||||||
expect(page).not_to have_css("img[alt='#{milestone1.image.title}']")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'Filters' do
|
context 'Filters' do
|
||||||
@@ -249,4 +256,18 @@ feature 'Executions' do
|
|||||||
expect(m_heading.name).to appear_before(z_heading.name)
|
expect(m_heading.name).to appear_before(z_heading.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'No milestones' do
|
||||||
|
|
||||||
|
scenario 'Milestone not yet published' do
|
||||||
|
status = create(:budget_investment_status)
|
||||||
|
unpublished_milestone = create(:budget_investment_milestone, investment: investment1,
|
||||||
|
status: status, publication_date: Date.tomorrow)
|
||||||
|
|
||||||
|
visit budget_executions_path(budget, status: status.id)
|
||||||
|
|
||||||
|
expect(page).to have_content('No winner investments in this state')
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user