diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss
index edb11f9b5..e7b4623df 100644
--- a/app/assets/stylesheets/participation.scss
+++ b/app/assets/stylesheets/participation.scss
@@ -462,7 +462,7 @@
word-break: break-word;
}
-.proposal-show, .investment-project-show {
+.proposal-show, .investment-project-show, .budget-investment-show {
.supports {
padding: $line-height/2 0 0;
@@ -712,6 +712,7 @@
}
.remove .icon-check-circle {
+ color: $budget;
display: block;
font-size: rem-calc(70);
line-height: rem-calc(70);
@@ -1030,7 +1031,6 @@
.amount-spent {
background: $success-bg;
- color: $success-color;
font-weight: normal;
padding: $line-height/2;
diff --git a/app/controllers/budgets/ballots_controller.rb b/app/controllers/budgets/ballots_controller.rb
index 3c163253d..ce531e145 100644
--- a/app/controllers/budgets/ballots_controller.rb
+++ b/app/controllers/budgets/ballots_controller.rb
@@ -5,14 +5,16 @@ module Budgets
before_action :load_ballot
def show
+ authorize! :show, @ballot
render template: "budgets/ballot/show"
end
private
def load_ballot
- @ballot = Budget::Ballot.where(user: current_user, budget: @budget).first_or_create
+ query = Budget::Ballot.where(user: current_user, budget: @budget)
+ @ballot = @budget.balloting? ? query.first_or_create : query.first_or_initialize
end
end
-end
\ No newline at end of file
+end
diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb
index bf8fd7574..12976de7d 100644
--- a/app/controllers/budgets/investments_controller.rb
+++ b/app/controllers/budgets/investments_controller.rb
@@ -18,7 +18,7 @@ module Budgets
feature_flag :budgets
has_orders %w{most_voted newest oldest}, only: :show
- has_orders ->(c){ c.instance_variable_get(:@budget).balloting? ? %w{random price} : %w{random confidence_score} }, only: :index
+ has_orders ->(c) { c.instance_variable_get(:@budget).investments_orders }, only: :index
invisible_captcha only: [:create, :update], honeypot: :subtitle, scope: :budget_investment
@@ -83,7 +83,7 @@ module Budgets
end
def investment_params
- params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :terms_of_service, :location, :tag_list)
+ params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :tag_list, :organization_name, :location, :terms_of_service)
end
def load_ballot
diff --git a/app/controllers/valuation/budget_investments_controller.rb b/app/controllers/valuation/budget_investments_controller.rb
index 69269f6bd..03facadb3 100644
--- a/app/controllers/valuation/budget_investments_controller.rb
+++ b/app/controllers/valuation/budget_investments_controller.rb
@@ -66,14 +66,14 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
def valid_price_params?
if /\D/.match params[:budget_investment][:price]
- @investment.errors.add(:price, I18n.t('budget.investments.wrong_price_format'))
+ @investment.errors.add(:price, I18n.t('budgets.investments.wrong_price_format'))
end
if /\D/.match params[:budget_investment][:price_first_year]
- @investment.errors.add(:price_first_year, I18n.t('budget.investments.wrong_price_format'))
+ @investment.errors.add(:price_first_year, I18n.t('budgets.investments.wrong_price_format'))
end
@investment.errors.empty?
end
-end
\ No newline at end of file
+end
diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb
index 0e3594b0a..84f04139c 100644
--- a/app/helpers/budgets_helper.rb
+++ b/app/helpers/budgets_helper.rb
@@ -1,17 +1,13 @@
module BudgetsHelper
def budget_phases_select_options
- Budget::PHASES.map { |ph| [ t("budget.phase.#{ph}"), ph ] }
+ Budget::PHASES.map { |ph| [ t("budgets.phase.#{ph}"), ph ] }
end
def budget_currency_symbol_select_options
Budget::CURRENCY_SYMBOLS.map { |cs| [ cs, cs ] }
end
- def heading_name(heading)
- heading.present? ? heading.name : t("budget.headings.none")
- end
-
def namespaced_budget_investment_path(investment, options={})
case namespace
when "management::budgets"
diff --git a/app/models/budget.rb b/app/models/budget.rb
index e2acf1de8..2741ac014 100644
--- a/app/models/budget.rb
+++ b/app/models/budget.rb
@@ -76,7 +76,7 @@ class Budget < ActiveRecord::Base
end
def translated_phase
- I18n.t "budget.phase.#{phase}"
+ I18n.t "budgets.phase.#{phase}"
end
def formatted_amount(amount)
@@ -94,6 +94,17 @@ class Budget < ActiveRecord::Base
formatted_amount(amount_spent(heading))
end
+ def investments_orders
+ case phase
+ when 'accepting', 'reviewing'
+ %w{random}
+ when 'balloting', 'reviewing_ballots'
+ %w{random price}
+ else
+ %w{random confidence_score}
+ end
+ end
+
private
def sanitize_descriptions
diff --git a/app/views/admin/budgets/index.html.erb b/app/views/admin/budgets/index.html.erb
index 7bf4b0659..87aaa8c66 100644
--- a/app/views/admin/budgets/index.html.erb
+++ b/app/views/admin/budgets/index.html.erb
@@ -25,7 +25,7 @@
<%= budget.name %>
- <%= t("budget.phase.#{budget.phase}") %>
+ <%= t("budgets.phase.#{budget.phase}") %>
|
<%= link_to t("admin.budgets.index.budget_investments"), admin_budget_budget_investments_path(budget_id: budget.id) %>
diff --git a/app/views/budgets/ballot/_ballot.html.erb b/app/views/budgets/ballot/_ballot.html.erb
index 11be78ff2..b83005185 100644
--- a/app/views/budgets/ballot/_ballot.html.erb
+++ b/app/views/budgets/ballot/_ballot.html.erb
@@ -1,22 +1,24 @@
-
+
+
+ <%= render 'shared/back_link' %>
- <%= render 'shared/back_link' %>
+ <%= t("budgets.ballots.show.title") %>
- <%= t("budgets.ballots.show.title") %>
-
-
-
- <%= t("budgets.ballots.show.voted_html",
- count: @ballot.investments.count) %>
-
-
-
- <%= t("budgets.ballots.show.voted_info_html") %>
-
-
+
+
+ <%= t("budgets.ballots.show.voted_html",
+ count: @ballot.investments.count) %>
+
+
+
+ <%= t("budgets.ballots.show.voted_info_html") %>
+
+
+
-
+
+
<% @ballot.groups.each do |group| %>
<%= t("budgets.ballots.show.zero") %>
- <%= link_to t("budgets.ballots.show.heading_link"),
- budget_investments_path(budget, heading_id: heading.id),
- data: { no_turbolink: true } %>
<% end %>
diff --git a/app/views/budgets/ballot/_investment_for_sidebar.html.erb b/app/views/budgets/ballot/_investment_for_sidebar.html.erb
index c172e6146..059951253 100644
--- a/app/views/budgets/ballot/_investment_for_sidebar.html.erb
+++ b/app/views/budgets/ballot/_investment_for_sidebar.html.erb
@@ -9,7 +9,8 @@
class: "remove-investment-project",
method: :delete,
remote: true do %>
-
+ <%= t('budgets.ballots.show.remove') %>
+
<% end %>
<% end %>
diff --git a/app/views/budgets/ballot/_progress_bar.html.erb b/app/views/budgets/ballot/_progress_bar.html.erb
index 45c338b88..ec9d28457 100644
--- a/app/views/budgets/ballot/_progress_bar.html.erb
+++ b/app/views/budgets/ballot/_progress_bar.html.erb
@@ -3,7 +3,8 @@
+ id="progress"
+ aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
<%= @ballot.formatted_amount_spent(@heading) %>
- <%= t("budget.progress_bar.available") %>
+ <%= t("budgets.progress_bar.available") %>
<%= @ballot.formatted_amount_available(@heading) %>
diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb
index 509e79d65..73fc3a697 100644
--- a/app/views/budgets/index.html.erb
+++ b/app/views/budgets/index.html.erb
@@ -1,7 +1,7 @@
- <%= t('budget.index.title') %>
+ <%= t('budgets.index.title') %>
@@ -10,8 +10,8 @@
- | <%= t('budget.index.name') %> |
- <%= t('budget.index.phase') %> |
+ <%= Budget.human_attribute_name(:name) %> |
+ <%= Budget.human_attribute_name(:phase) %> |
<% @budgets.each do |budget| %>
diff --git a/app/views/budgets/investments/_ballot.html.erb b/app/views/budgets/investments/_ballot.html.erb
index d319a8aa6..0ad43ab43 100644
--- a/app/views/budgets/investments/_ballot.html.erb
+++ b/app/views/budgets/investments/_ballot.html.erb
@@ -3,8 +3,8 @@
<% if ballot.has_investment?(investment) %>
- ">
+ ">
<%= investment.formatted_price %>
@@ -27,12 +27,12 @@
<%= investment.formatted_price %>
<% if investment.should_show_ballots? %>
- <%= link_to t("budget.investments.investment.add"),
+ <%= link_to t("budgets.investments.investment.add"),
budget_ballot_lines_url(investment_id: investment.id,
budget_id: investment.budget_id,
investments_ids: investment_ids),
class: "button button-support small expanded",
- title: t('budget.investments.investment.support_title'),
+ title: t('budgets.investments.investment.support_title'),
method: :post,
remote: true %>
<% end %>
@@ -42,7 +42,7 @@
<% if reason.present? && !ballot.has_investment?(investment) %>
-
+
<%= t("budgets.ballots.reasons_for_not_balloting.#{reason}",
verify_account: link_to(t("votes.verify_account"), verification_path),
diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb
index 61d7b83c8..f5a30dc96 100644
--- a/app/views/budgets/investments/_form.html.erb
+++ b/app/views/budgets/investments/_form.html.erb
@@ -3,8 +3,7 @@
- <%= f.label :heading_id, t("budget.investments.form.heading") %>
- <%= f.select :heading_id, budget_heading_select_options(@budget), {include_blank: true, label: false} %>
+ <%= f.select :heading_id, budget_heading_select_options(@budget), {include_blank: true, } %>
@@ -25,6 +24,10 @@
<%= f.text_field :location %>
+
+ <%= f.text_field :organization_name %>
+
+
<%= f.label :tag_list, t("budget.investments.form.tags_label") %>
<%= t("budget.investments.form.tags_instructions") %>
@@ -60,7 +63,7 @@
<% end %>
- <%= f.submit(class: "button expanded", value: t("budget.investments.form.submit_buttons.#{action_name}")) %>
+ <%= f.submit(nil, class: "button expanded") %>
<% end %>
diff --git a/app/views/budgets/investments/_header.html.erb b/app/views/budgets/investments/_header.html.erb
index ba3e8d5b8..780370ac3 100644
--- a/app/views/budgets/investments/_header.html.erb
+++ b/app/views/budgets/investments/_header.html.erb
@@ -10,7 +10,7 @@
<% end %>
<% if can? :show, @ballot %>
- <%= link_to t("budget.investments.header.check_ballot"),
+ <%= link_to t("budgets.investments.header.check_ballot"),
budget_ballot_path(@budget),
class: "button float-right" %>
<% end %>
@@ -20,13 +20,12 @@
- <%= @heading.name %>
-
- <% if can? :show, @ballot %>
- <%= link_to t("budget.investments.header.check_ballot"),
+ <%= @heading.name %>
+ <% if can? :show, @ballot %>
+
+ <%= link_to t("budgets.investments.header.check_ballot"),
budget_ballot_path(@budget) %>
- <% end %>
-
+
<% if @ballot.valid_heading?(@heading) %>
<%= render 'budgets/ballot/progress_bar' %>
@@ -34,13 +33,16 @@
<% else %>
- <%= t("budget.investments.header.different_heading_assigned_html",
+ <%= t("budgets.investments.header.different_heading_assigned_html",
heading_link: link_to(
@assigned_heading.name,
budget_investments_path(@budget, heading: @assigned_heading))
) %>
<% end %>
+ <% else %>
+ <%= @budget.formatted_heading_price(@heading) %>
+ <% end %>
@@ -55,7 +57,7 @@
<%= t("shared.back") %>
<% end %>
- <%= t('budget.investments.index.title') %>
+ <%= t('budgets.investments.index.title') %>
diff --git a/app/views/budgets/investments/_investment.html.erb b/app/views/budgets/investments/_investment.html.erb
index e90801f17..c9c247784 100644
--- a/app/views/budgets/investments/_investment.html.erb
+++ b/app/views/budgets/investments/_investment.html.erb
@@ -6,7 +6,7 @@
<% cache [locale_and_user_status(investment), 'index', investment, investment.author] do %>
- <%= t("budget.investments.investment.title") %>
+ <%= t("budgets.investments.investment.title") %>
<%= link_to investment.title, namespaced_budget_investment_path(investment) %>
@@ -16,7 +16,7 @@
<% if investment.author.hidden? || investment.author.erased? %>
•
- <%= t("budget.investments.show.author_deleted") %>
+ <%= t("budgets.investments.show.author_deleted") %>
<% else %>
•
@@ -32,10 +32,10 @@
<% end %>
•
- <%= heading_name(investment.heading) %>
+ <%= investment.heading.name %>
- <%= link_to investment.description, namespaced_budget_investment_path(investment) %>
+ <%= investment.description %>
<%= render "shared/tags", taggable: investment, limit: 5 %>
diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb
index 7917889c4..8aae97c91 100644
--- a/app/views/budgets/investments/_investment_show.html.erb
+++ b/app/views/budgets/investments/_investment_show.html.erb
@@ -1,11 +1,5 @@
-
- - <%= link_to investment.budget.name, budget_path(investment.budget) %>
- - <%= investment.group.name %>
- - <%= investment.heading.name %>
-
-
<%= link_to :back, class: "back" do %>
@@ -21,17 +15,23 @@
•
<%= l investment.created_at.to_date %>
•
- <%= heading_name(investment.heading) %>
+ <%= investment.heading.name %>
- <%= t("budget.investments.show.code_html", code: investment.id) %>
+ <%= t("budgets.investments.show.code_html", code: investment.id) %>
<% if investment.location.present? %>
-
- <%= t("budget.investments.show.location_html", location: investment.location) %>
+
+ <%= t("budgets.investments.show.location_html", location: investment.location) %>
+
+ <% end %>
+
+ <% if investment.organization_name.present? %>
+
+ <%= t("budgets.investments.show.organization_name_html", name: investment.organization_name) %>
<% end %>
@@ -46,12 +46,12 @@
<% end %>
<% if investment.unfeasible? && investment.unfeasibility_explanation.present? %>
- <%= t('budget.investments.show.unfeasibility_explanation') %>
+ <%= t('budgets.investments.show.unfeasibility_explanation') %>
<%= investment.unfeasibility_explanation %>
<% end %>
<% if investment.feasible? && investment.price_explanation.present? %>
- <%= t('budget.investments.show.price_explanation') %>
+ <%= t('budgets.investments.show.price_explanation') %>
<%= investment.price_explanation %>
<% end %>
@@ -59,7 +59,7 @@
<% if investment.should_show_aside? %>
-
-
diff --git a/app/views/budgets/investments/_sidebar.html.erb b/app/views/budgets/investments/_sidebar.html.erb
index 639106934..202c8188d 100644
--- a/app/views/budgets/investments/_sidebar.html.erb
+++ b/app/views/budgets/investments/_sidebar.html.erb
@@ -1,41 +1,45 @@
-<% if @budget.accepting? %>
+<% if can?(:create, Budget::Investment.new(budget: @budget)) %>
<% if current_user && current_user.level_two_or_three_verified? %>
- <%= link_to t("budget.investments.index.sidebar.create"), new_budget_investment_path, class: "button budget expanded" %>
+ <%= link_to t("budgets.investments.index.sidebar.create"), new_budget_investment_path, class: "button budget expanded" %>
<% else %>
- <%= t("budget.investments.index.sidebar.verified_only",
- verify: link_to(t("budget.investments.index.sidebar.verify_account"), verification_path)).html_safe %>
+ <%= t("budgets.investments.index.sidebar.verified_only",
+ verify: link_to(t("budgets.investments.index.sidebar.verify_account"), verification_path)).html_safe %>
<% end %>
<%= render "shared/tag_cloud", taggable: 'budget/investment' %>
<%= render 'categories' %>
<% end %>
-
-
-<% if @heading && @ballot.investments.by_heading(@heading.id).count > 0 %>
-
-
- <%= t("budget.investments.index.sidebar.voted_html",
- count: @ballot.investments.by_heading(@heading.id).count,
- amount_spent: @ballot.formatted_amount_spent(@heading)) %>
-
-
-<% else %>
- <%= t("budget.investments.index.sidebar.zero") %>
-<% end %>
+<% if @heading && can?(:show, @ballot) %>
-
- <% if @heading %>
- <% @ballot.investments.by_heading(@heading.id).each do |investment| %>
- <%= render 'budgets/ballot/investment_for_sidebar',
- investment: investment,
- investment_ids: @investment_ids %>
- <% end %>
+
+
+
+ <% if @ballot.investments.by_heading(@heading.id).count > 0 %>
+
+
+ <%= t("budgets.investments.index.sidebar.voted_html",
+ count: @ballot.investments.by_heading(@heading.id).count,
+ amount_spent: @ballot.formatted_amount_spent(@heading)) %>
+
+
+ <% else %>
+ <%= t("budgets.investments.index.sidebar.zero") %>
<% end %>
-
- <%= t("budget.investments.index.sidebar.voted_info") %>
+
+ <% if @heading %>
+ <% @ballot.investments.by_heading(@heading.id).each do |investment| %>
+ <%= render 'budgets/ballot/investment_for_sidebar',
+ investment: investment,
+ investment_ids: @investment_ids %>
+ <% end %>
+ <% end %>
+
+
+ <%= t("budgets.investments.index.sidebar.voted_info") %>
+<% end %>
diff --git a/app/views/budgets/investments/_votes.html.erb b/app/views/budgets/investments/_votes.html.erb
index e1dd2860c..6d62b9a02 100644
--- a/app/views/budgets/investments/_votes.html.erb
+++ b/app/views/budgets/investments/_votes.html.erb
@@ -5,29 +5,29 @@
- <%= t("budget.investments.investment.supports", count: investment.total_votes) %>
+ <%= t("budgets.investments.investment.supports", count: investment.total_votes) %>
<% if user_voted_for %>
-
- <%= t("budget.investments.investment.already_supported") %>
+
+ <%= t("budgets.investments.investment.already_supported") %>
<% elsif investment.should_show_votes? %>
<%= link_to vote_url,
class: "button button-support small expanded",
- title: t('budget.investments.investment.support_title'),
+ title: t('budgets.investments.investment.support_title'),
method: "post",
remote: true,
"aria-hidden" => css_for_aria_hidden(reason) do %>
- <%= t("budget.investments.investment.give_support") %>
+ <%= t("budgets.investments.investment.give_support") %>
<% end %>
<% end %>
<% if reason.present? && !user_voted_for %>
-
+
<%= t("votes.budget_investments.#{reason}",
verify_account: link_to(t("votes.verify_account"), verification_path),
diff --git a/app/views/budgets/investments/index.html.erb b/app/views/budgets/investments/index.html.erb
index 3c91d27c1..b3bcf03fe 100644
--- a/app/views/budgets/investments/index.html.erb
+++ b/app/views/budgets/investments/index.html.erb
@@ -1,8 +1,8 @@
-<% provide :title do %><%= t('budget.investments.index.title') %><% end %>
+<% provide :title do %><%= t('budgets.investments.index.title') %><% end %>
<% content_for :header_addon do %>
<%= render "shared/search_form",
search_path: budget_investments_path(budget_id: @budget.id, page: 1),
- i18n_namespace: "budget.investments.index.search_form" %>
+ i18n_namespace: "budgets.investments.index.search_form" %>
<% end %>
@@ -17,23 +17,23 @@
<% if params[:unfeasible].present? %>
- <%= t("budget.investments.index.unfeasible") %>
+ <%= t("budgets.investments.index.unfeasible") %>
- <%= t("budget.investments.index.unfeasible_text",
- definitions: link_to(t("budget.investments.index.unfeasible_text_definitions"), "https://decide.madrid.es/participatory_budget_info#20")).html_safe %>
+ <%= t("budgets.investments.index.unfeasible_text",
+ definitions: link_to(t("budgets.investments.index.unfeasible_text_definitions"), "https://decide.madrid.es/participatory_budget_info#20")).html_safe %>
<% end %>
- <%= content_tag(:h2, t("budget.investments.index.by_heading", heading: @heading.name)) if @heading.present? %>
+ <%= content_tag(:h2, t("budgets.investments.index.by_heading", heading: @heading.name)) if @heading.present? %>
<% if params[:search].present? %>
<%= page_entries_info @investments %>
- <%= t("budget.investments.index.search_results", count: @investments.size, search_term: params[:search]) %>
+ <%= t("budgets.investments.index.search_results", count: @investments.size, search_term: params[:search]) %>
<% end %>
- <%= render('shared/order_links', i18n_namespace: "budget.investments.index") unless params[:unfeasible].present? %>
+ <%= render('shared/order_links', i18n_namespace: "budgets.investments.index") unless params[:unfeasible].present? %>
<% @investments.each do |investment| %>
<%= render partial: '/budgets/investments/investment', locals: {
diff --git a/app/views/budgets/show.html.erb b/app/views/budgets/show.html.erb
index 6798b329a..c43684363 100644
--- a/app/views/budgets/show.html.erb
+++ b/app/views/budgets/show.html.erb
@@ -12,26 +12,26 @@
- <%= t('budget.show.phase') %>
+ <%= t('budgets.show.phase') %>
- <%= t("budgets.phases.#{@budget.phase}") %>
+ <%= t("budgets.phase.#{@budget.phase}") %>
- <% if @budget.accepting? %>
+ <% if can?(:create, Budget::Investment.new(budget: @budget))%>
<% if current_user %>
<% if current_user.level_two_or_three_verified? %>
- <%= link_to t("budget.investments.index.sidebar.create"), new_budget_investment_path(@budget), class: "button margin-top expanded" %>
+ <%= link_to t("budgets.investments.index.sidebar.create"), new_budget_investment_path(@budget), class: "button margin-top expanded" %>
<% else %>
- <%= t("budget.investments.index.sidebar.verified_only",
- verify: link_to(t("budget.investments.index.sidebar.verify_account"), verification_path)).html_safe %>
+ <%= t("budgets.investments.index.sidebar.verified_only",
+ verify: link_to(t("budgets.investments.index.sidebar.verify_account"), verification_path)).html_safe %>
<% end %>
<% else %>
- <%= t("budget.investments.index.sidebar.not_logged_in",
- sign_in: link_to(t("budget.investments.index.sidebar.sign_in"), new_user_session_path),
- sign_up: link_to(t("budget.investments.index.sidebar.sign_up"), new_user_registration_path)).html_safe %>
+ <%= t("budgets.investments.index.sidebar.not_logged_in",
+ sign_in: link_to(t("budgets.investments.index.sidebar.sign_in"), new_user_session_path),
+ sign_up: link_to(t("budgets.investments.index.sidebar.sign_up"), new_user_registration_path)).html_safe %>
<% end %>
<% end %>
@@ -43,7 +43,7 @@
- | <%= t('budget.show.group') %> |
+ <%= t('budgets.show.group') %> |
<% @budget.groups.each do |group| %>
diff --git a/app/views/shared/_search_form.html.erb b/app/views/shared/_search_form.html.erb
index c14c41e7e..a15bc737a 100644
--- a/app/views/shared/_search_form.html.erb
+++ b/app/views/shared/_search_form.html.erb
@@ -3,7 +3,7 @@
<%= form_tag search_path, method: :get do %>
- " class="input-group-field" value="<%= params[:search] %>" id="search_text">
+
|