diff --git a/app/assets/images/more_info/budgets_en.png b/app/assets/images/help/budgets_en.png
similarity index 100%
rename from app/assets/images/more_info/budgets_en.png
rename to app/assets/images/help/budgets_en.png
diff --git a/app/assets/images/more_info/budgets_es.png b/app/assets/images/help/budgets_es.png
similarity index 100%
rename from app/assets/images/more_info/budgets_es.png
rename to app/assets/images/help/budgets_es.png
diff --git a/app/assets/images/more_info/budgets_fr.png b/app/assets/images/help/budgets_fr.png
similarity index 100%
rename from app/assets/images/more_info/budgets_fr.png
rename to app/assets/images/help/budgets_fr.png
diff --git a/app/assets/images/more_info/budgets_nl.png b/app/assets/images/help/budgets_nl.png
similarity index 100%
rename from app/assets/images/more_info/budgets_nl.png
rename to app/assets/images/help/budgets_nl.png
diff --git a/app/assets/images/more_info/budgets_pt-BR.png b/app/assets/images/help/budgets_pt-BR.png
similarity index 100%
rename from app/assets/images/more_info/budgets_pt-BR.png
rename to app/assets/images/help/budgets_pt-BR.png
diff --git a/app/assets/images/more_info/debates.png b/app/assets/images/help/debates.png
similarity index 100%
rename from app/assets/images/more_info/debates.png
rename to app/assets/images/help/debates.png
diff --git a/app/assets/images/more_info/proposals_en.png b/app/assets/images/help/proposals_en.png
similarity index 100%
rename from app/assets/images/more_info/proposals_en.png
rename to app/assets/images/help/proposals_en.png
diff --git a/app/assets/images/more_info/proposals_es.png b/app/assets/images/help/proposals_es.png
similarity index 100%
rename from app/assets/images/more_info/proposals_es.png
rename to app/assets/images/help/proposals_es.png
diff --git a/app/assets/images/more_info/proposals_fr.png b/app/assets/images/help/proposals_fr.png
similarity index 100%
rename from app/assets/images/more_info/proposals_fr.png
rename to app/assets/images/help/proposals_fr.png
diff --git a/app/assets/images/more_info/proposals_nl.png b/app/assets/images/help/proposals_nl.png
similarity index 100%
rename from app/assets/images/more_info/proposals_nl.png
rename to app/assets/images/help/proposals_nl.png
diff --git a/app/assets/images/more_info/proposals_pt-BR.png b/app/assets/images/help/proposals_pt-BR.png
similarity index 100%
rename from app/assets/images/more_info/proposals_pt-BR.png
rename to app/assets/images/help/proposals_pt-BR.png
diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss
index 09902f649..cebd8c8eb 100644
--- a/app/assets/stylesheets/layout.scss
+++ b/app/assets/stylesheets/layout.scss
@@ -1641,7 +1641,7 @@ table {
// 13. Pages
// ---------
-.more-information {
+.help {
li {
border-bottom: 1px solid $border;
diff --git a/app/controllers/admin/budget_investments_controller.rb b/app/controllers/admin/budget_investments_controller.rb
index 9bf4d4610..c81ccfcc3 100644
--- a/app/controllers/admin/budget_investments_controller.rb
+++ b/app/controllers/admin/budget_investments_controller.rb
@@ -61,12 +61,13 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
end
def load_investments
- if params[:project_title].present?
- @investments = Budget::Investment.where("title ILIKE ?", "%#{params[:project_title].strip}%")
- else
- @investments = Budget::Investment.scoped_filter(params, @current_filter)
+ @investments = if params[:project_title].present?
+ Budget::Investment.where("title ILIKE ?",
+ "%#{params[:project_title].strip}%")
+ else
+ Budget::Investment.scoped_filter(params, @current_filter)
.order(sort_by(params[:sort_by]))
- end
+ end
@investments = @investments.page(params[:page]) unless request.format.csv?
end
diff --git a/app/controllers/budgets_controller.rb b/app/controllers/budgets_controller.rb
index 385734121..298425174 100644
--- a/app/controllers/budgets_controller.rb
+++ b/app/controllers/budgets_controller.rb
@@ -14,8 +14,7 @@ class BudgetsController < ApplicationController
end
def index
- @budgets = @budgets.order(created_at: :desc)
- @budget = current_budget
+ @finished_budgets = @budgets.finished.order(created_at: :desc)
@budgets_coordinates = current_budget_map_locations
end
diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb
index 98357e96e..0f5cb680b 100644
--- a/app/controllers/comments_controller.rb
+++ b/app/controllers/comments_controller.rb
@@ -45,12 +45,13 @@ class CommentsController < ApplicationController
def comment_params
params.require(:comment).permit(:commentable_type, :commentable_id, :parent_id,
- :body, :as_moderator, :as_administrator)
+ :body, :as_moderator, :as_administrator, :valuation)
end
def build_comment
@comment = Comment.build(@commentable, current_user, comment_params[:body],
- comment_params[:parent_id].presence)
+ comment_params[:parent_id].presence,
+ comment_params[:valuation])
check_for_special_comments
end
diff --git a/app/controllers/valuation/budget_investments_controller.rb b/app/controllers/valuation/budget_investments_controller.rb
index 18f7e2599..a9064a301 100644
--- a/app/controllers/valuation/budget_investments_controller.rb
+++ b/app/controllers/valuation/budget_investments_controller.rb
@@ -1,11 +1,14 @@
class Valuation::BudgetInvestmentsController < Valuation::BaseController
include FeatureFlags
+ include CommentableActions
+
feature_flag :budgets
before_action :restrict_access_to_assigned_items, only: [:show, :edit, :valuate]
before_action :load_budget
before_action :load_investment, only: [:show, :edit, :valuate]
+ has_orders %w{oldest}, only: [:show, :edit]
has_filters %w{valuating valuation_finished}, only: :index
load_and_authorize_resource :investment, class: "Budget::Investment"
@@ -36,8 +39,30 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
end
end
+ def show
+ load_comments
+ end
+
+ def edit
+ load_comments
+ end
+
private
+ def load_comments
+ @commentable = @investment
+ @comment_tree = CommentTree.new(@commentable, params[:page], @current_order, valuations: true)
+ set_comment_flags(@comment_tree.comments)
+ end
+
+ def resource_model
+ Budget::Investment
+ end
+
+ def resource_name
+ resource_model.parameterize('_')
+ end
+
def load_budget
@budget = Budget.find(params[:budget_id])
end
diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb
index 53b49dfb4..7af50446a 100644
--- a/app/models/abilities/administrator.rb
+++ b/app/models/abilities/administrator.rb
@@ -55,7 +55,7 @@ module Abilities
can [:read, :create, :update, :destroy], Budget::Group
can [:read, :create, :update, :destroy], Budget::Heading
can [:hide, :update, :toggle_selection], Budget::Investment
- can :valuate, Budget::Investment
+ can [:valuate, :comment_valuation], Budget::Investment
can :create, Budget::ValuatorAssignment
can [:search, :edit, :update, :create, :index, :destroy], Banner
diff --git a/app/models/abilities/valuator.rb b/app/models/abilities/valuator.rb
index 614869665..449a42410 100644
--- a/app/models/abilities/valuator.rb
+++ b/app/models/abilities/valuator.rb
@@ -5,8 +5,8 @@ module Abilities
def initialize(user)
valuator = user.valuator
can [:read, :update, :valuate], SpendingProposal
- can [:read, :update, :valuate], Budget::Investment, id: valuator.investment_ids
- cannot [:update, :valuate], Budget::Investment, budget: { phase: 'finished' }
+ can [:read, :update, :valuate, :comment_valuation], Budget::Investment, id: valuator.investment_ids
+ cannot [:update, :valuate, :comment_valuation], Budget::Investment, budget: { phase: 'finished' }
end
end
end
diff --git a/app/models/budget/group.rb b/app/models/budget/group.rb
index 93d7bba63..a2b3179a3 100644
--- a/app/models/budget/group.rb
+++ b/app/models/budget/group.rb
@@ -10,5 +10,8 @@ class Budget
validates :name, presence: true, uniqueness: { scope: :budget }
validates :slug, presence: true, format: /\A[a-z0-9\-_]+\z/
+ def single_heading_group?
+ headings.count == 1
+ end
end
end
diff --git a/app/models/budget/heading.rb b/app/models/budget/heading.rb
index c9719a709..8816d1abf 100644
--- a/app/models/budget/heading.rb
+++ b/app/models/budget/heading.rb
@@ -17,7 +17,7 @@ class Budget
scope :order_by_group_name, -> { includes(:group).order('budget_groups.name', 'budget_headings.name') }
def name_scoped_by_group
- "#{group.name}: #{name}"
+ group.single_heading_group? ? name : "#{group.name}: #{name}"
end
def name_exists_in_budget_headings
diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb
index 58674be9b..f909a9746 100644
--- a/app/models/budget/investment.rb
+++ b/app/models/budget/investment.rb
@@ -34,7 +34,10 @@ class Budget
has_many :valuator_assignments, dependent: :destroy
has_many :valuators, through: :valuator_assignments
- has_many :comments, as: :commentable
+
+ has_many :comments, -> {where(valuation: false)}, as: :commentable, class_name: 'Comment'
+ has_many :valuations, -> {where(valuation: true)}, as: :commentable, class_name: 'Comment'
+
has_many :milestones
validates :title, presence: true
@@ -86,6 +89,10 @@ class Budget
before_validation :set_responsible_name
before_validation :set_denormalized_ids
+ def comments_count
+ comments.count
+ end
+
def url
budget_investment_path(budget, self)
end
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 50f6cef66..d9329d3c0 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -20,6 +20,7 @@ class Comment < ActiveRecord::Base
validates :commentable_type, inclusion: { in: COMMENTABLE_TYPES }
validate :validate_body_length
+ validate :comment_valuation, if: -> { valuation }
belongs_to :commentable, -> { with_hidden }, polymorphic: true, counter_cache: true
belongs_to :user, -> { with_hidden }
@@ -33,7 +34,8 @@ class Comment < ActiveRecord::Base
end
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
scope :public_for_api, -> do
- where(%{(comments.commentable_type = 'Debate' and comments.commentable_id in (?)) or
+ not_valuations
+ .where(%{(comments.commentable_type = 'Debate' and comments.commentable_id in (?)) or
(comments.commentable_type = 'Proposal' and comments.commentable_id in (?)) or
(comments.commentable_type = 'Poll' and comments.commentable_id in (?))},
Debate.public_for_api.pluck(:id),
@@ -50,13 +52,16 @@ class Comment < ActiveRecord::Base
scope :sort_by_oldest, -> { order(created_at: :asc) }
scope :sort_descendants_by_oldest, -> { order(created_at: :asc) }
+ scope :not_valuations, -> { where(valuation: false) }
+
after_create :call_after_commented
- def self.build(commentable, user, body, p_id = nil)
- new commentable: commentable,
+ def self.build(commentable, user, body, p_id = nil, valuation = false)
+ new(commentable: commentable,
user_id: user.id,
body: body,
- parent_id: p_id
+ parent_id: p_id,
+ valuation: valuation)
end
def self.find_commentable(c_type, c_id)
@@ -129,4 +134,9 @@ class Comment < ActiveRecord::Base
validator.validate(self)
end
+ def comment_valuation
+ unless author.can?(:comment_valuation, commentable)
+ errors.add(:valuation, :cannot_comment_valuation)
+ end
+ end
end
diff --git a/app/views/admin/budget_investments/index.html.erb b/app/views/admin/budget_investments/index.html.erb
index 19acdebd3..73a06a402 100644
--- a/app/views/admin/budget_investments/index.html.erb
+++ b/app/views/admin/budget_investments/index.html.erb
@@ -27,15 +27,14 @@
class: "js-submit-on-change" } %>
-
- <%= select_tag :tag_name,
- options_for_select(investment_tags_select_options(@budget), params[:tag_name]),
- { prompt: t("admin.budget_investments.index.tags_filter_all"),
- label: false,
- class: "js-submit-on-change" } %>
-
- <% end %>
-
+
+ <%= select_tag :tag_name,
+ options_for_select(investment_tags_select_options(@budget), params[:tag_name]),
+ { prompt: t("admin.budget_investments.index.tags_filter_all"),
+ label: false,
+ class: "js-submit-on-change" } %>
+
+<% end %>
<%= render "advanced_filters", i18n_namespace: "admin.budget_investments.index" %>
diff --git a/app/views/admin/budgets/_group.html.erb b/app/views/admin/budgets/_group.html.erb
index 8f3fbe2cc..c3ce314aa 100644
--- a/app/views/admin/budgets/_group.html.erb
+++ b/app/views/admin/budgets/_group.html.erb
@@ -20,8 +20,8 @@
<% else %>
| <%= t("admin.budgets.form.table_heading") %> |
- <%= t("admin.budgets.form.table_amount") %> |
- <%= t("admin.budgets.form.table_population") %> |
+ <%= t("admin.budgets.form.table_amount") %> |
+ <%= t("admin.budgets.form.table_population") %> |
<%= t("admin.actions.actions") %> |
diff --git a/app/views/admin/budgets/_heading.html.erb b/app/views/admin/budgets/_heading.html.erb
index bc9d59c5f..da3139a1b 100644
--- a/app/views/admin/budgets/_heading.html.erb
+++ b/app/views/admin/budgets/_heading.html.erb
@@ -2,10 +2,10 @@
<%= heading.name %>
|
-
- <%= heading.price %>
+ |
+ <%= heading.budget.formatted_heading_price(heading) %>
|
-
+ |
<%= heading.population %>
|
diff --git a/app/views/budgets/_phases.html.erb b/app/views/budgets/_phases.html.erb
index 1d0968c46..2d11ef01f 100644
--- a/app/views/budgets/_phases.html.erb
+++ b/app/views/budgets/_phases.html.erb
@@ -1,6 +1,6 @@
- <% @budget.published_phases.each do |phase| %>
- -
+ <% current_budget.published_phases.each do |phase| %>
+
-
<%= t("budgets.phase.#{phase.kind}") %>
<%= l(phase.starts_at.to_date, format: :long) if phase.starts_at.present? %>
diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb
index 99571e70a..810c505ae 100644
--- a/app/views/budgets/index.html.erb
+++ b/app/views/budgets/index.html.erb
@@ -7,9 +7,9 @@
- <%= @budget.name %>
+ <%= current_budget.name %>
- <%= safe_html_with_links(@budget.description) %>
+ <%= safe_html_with_links(current_budget.description) %>
<%= link_to t("budgets.index.section_header.help"), "#section_help" %>
@@ -19,11 +19,11 @@
<%= t('budgets.show.phase') %>
- <%= t("budgets.phase.#{@budget.phase}") %>
+ <%= t("budgets.phase.#{current_budget.phase}") %>
<%= link_to t("budgets.index.section_header.all_phases"), "#all_phases" %>
- <% if @budget.accepting? %>
+ <% if current_budget.accepting? %>
<% if current_user %>
<% if current_user.level_two_or_three_verified? %>
<%= link_to t("budgets.investments.index.sidebar.create"),
@@ -48,9 +48,9 @@
<% end %>
- <% if @budget.finished? || (@budget.balloting? && can?(:read_results, @budget)) %>
+ <% if current_budget.finished? || (current_budget.balloting? && can?(:read_results, current_budget)) %>
<%= link_to t("budgets.show.see_results"),
- budget_results_path(@budget, heading_id: @budget.headings.first),
+ budget_results_path(current_budget, heading_id: current_budget.headings.first),
class: "button margin-top expanded" %>
<% end %>
@@ -62,18 +62,18 @@
- <% @budget.groups.each do |group| %>
+ <% current_budget.groups.each do |group| %>
<%= group.name %>
- <% unless @budget.informing? %>
+ <% unless current_budget.informing? %>
<%= t("budgets.index.map") %>
<%= render_map(nil, "budgets", false, nil, @budgets_coordinates) %>
- <%= link_to budget_investments_path(@budget.id) do %>
+ <%= link_to budget_investments_path(current_budget.id) do %>
<%= t("budgets.index.investment_proyects") %>
<% end %>
- <%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unfeasible') do %>
+ <%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unfeasible') do %>
<%= t("budgets.index.unfeasible_investment_proyects") %>
<% end %>
- <%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unselected') do %>
+ <%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unselected') do %>
<%= t("budgets.index.not_selected_investment_proyects") %>
<% end %>
@@ -103,26 +103,26 @@
<%= t("budgets.index.all_phases") %>
- <%= render "phases" %>
+ <%= render "phases", budget: current_budget %>
-
-
-
+ <% if @finished_budgets.present? %>
+
+
+
-
- <% @budgets.each do |budget| %>
- <% if budget_published?(budget) %>
+
+ <% @finished_budgets.each do |budget| %>
-
+ <% end %>
diff --git a/app/views/budgets/show.html.erb b/app/views/budgets/show.html.erb
index 54d87498f..1719624aa 100644
--- a/app/views/budgets/show.html.erb
+++ b/app/views/budgets/show.html.erb
@@ -60,7 +60,7 @@
<% @budget.groups.each do |group| %>
|
- <% if group.headings.count == 1 %>
+ <% if group.single_heading_group? %>
<%= link_to group.name,
budget_investments_path(@budget,
heading_id: group.headings.first.id,
diff --git a/app/views/comments/_actions.html.erb b/app/views/comments/_actions.html.erb
index 80302a70a..2852fa09d 100644
--- a/app/views/comments/_actions.html.erb
+++ b/app/views/comments/_actions.html.erb
@@ -1,6 +1,8 @@
-
+<% if local_assigns.fetch(:allow_flagging, true) %>
+
+<% end %>
<% if can? :hide, comment %>
diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb
index 8d45b5469..f57876030 100644
--- a/app/views/comments/_comment.html.erb
+++ b/app/views/comments/_comment.html.erb
@@ -1,4 +1,7 @@
<% comment_flags ||= @comment_flags %>
+<% valuation = local_assigns.fetch(:valuation, false) %>
+<% allow_votes = local_assigns.fetch(:allow_votes, true) %>
+<% allow_flagging = local_assigns.fetch(:allow_flagging, true) %>
<% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (comment_flags[comment.id] if comment_flags)] do %>
| |