diff --git a/CUSTOMIZE_ES.md b/CUSTOMIZE_ES.md
index 09fdfe62c..33c91b268 100644
--- a/CUSTOMIZE_ES.md
+++ b/CUSTOMIZE_ES.md
@@ -17,6 +17,7 @@ Para adaptarlo puedes hacerlo a través de los directorios que están en custom
Aparte de estos directorios también cuentas con ciertos ficheros para:
* `app/assets/stylesheets/custom.css`
+* `app/assets/stylesheets/_custom_settings.css`
* `app/assets/javascripts/custom.js`
* `Gemfile_custom`
* `config/application.custom.rb`
@@ -67,6 +68,11 @@ Si quieres cambiar algun selector CSS (de las hojas de estilo) puedes hacerlo en
background: red;
}
```
+Si quieres cambiar alguna variable de foundation puedes hacerlo en el fichero `app/assets/stylesheets/_custom_settings.scss`. Por ejemplo para cambiar el color general de la aplicación puedes hacerlo agregando:
+
+```css
+$brand: #446336;
+```
Usamos un preprocesador de CSS, [SASS, con la sintaxis SCSS](http://sass-lang.com/guide).
diff --git a/app/assets/stylesheets/_custom_settings.scss b/app/assets/stylesheets/_custom_settings.scss
new file mode 100644
index 000000000..92a304e6f
--- /dev/null
+++ b/app/assets/stylesheets/_custom_settings.scss
@@ -0,0 +1,5 @@
+// Overrides and adds customized foundation settings in this file
+// Read more on documentation:
+// * English: https://github.com/consul/consul/blob/master/CUSTOMIZE_EN.md#css
+// * Spanish: https://github.com/consul/consul/blob/master/CUSTOMIZE_ES.md#css
+//
diff --git a/app/assets/stylesheets/foundation_and_overrides.scss b/app/assets/stylesheets/foundation_and_overrides.scss
index cd33ac92d..992b0cc81 100644
--- a/app/assets/stylesheets/foundation_and_overrides.scss
+++ b/app/assets/stylesheets/foundation_and_overrides.scss
@@ -1,6 +1,7 @@
@charset 'utf-8';
@import 'settings';
+@import 'custom_settings';
@import 'foundation';
@include foundation-global-styles;
diff --git a/app/controllers/budgets/ballot/lines_controller.rb b/app/controllers/budgets/ballot/lines_controller.rb
index 0f8209e5a..2feb83e5e 100644
--- a/app/controllers/budgets/ballot/lines_controller.rb
+++ b/app/controllers/budgets/ballot/lines_controller.rb
@@ -5,6 +5,8 @@ module Budgets
#before_action :ensure_final_voting_allowed
before_action :load_budget
before_action :load_ballot
+ before_action :load_tag_cloud
+ before_action :load_categories
before_action :load_investments
@@ -63,6 +65,14 @@ module Budgets
@heading = @investment.heading
end
+ def load_tag_cloud
+ @tag_cloud = TagCloud.new(Budget::Investment, params[:search])
+ end
+
+ def load_categories
+ @categories = ActsAsTaggableOn::Tag.where("kind = 'category'").order(:name)
+ end
+
end
end
end
diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb
index 235163f2e..ebf14d94b 100644
--- a/app/controllers/budgets/investments_controller.rb
+++ b/app/controllers/budgets/investments_controller.rb
@@ -46,6 +46,7 @@ module Budgets
@investment.author = current_user
if @investment.save
+ Mailer.budget_investment_created(@investment).deliver_later
redirect_to budget_investment_path(@budget, @investment),
notice: t('flash.actions.create.budget_investment')
else
@@ -61,6 +62,10 @@ module Budgets
def vote
@investment.register_selection(current_user)
load_investment_votes(@investment)
+ respond_to do |format|
+ format.html { redirect_to budget_investments_path(heading_id: @investment.heading.id) }
+ format.js
+ end
end
private
diff --git a/app/controllers/management/budgets/investments_controller.rb b/app/controllers/management/budgets/investments_controller.rb
index e790312d6..025b6301d 100644
--- a/app/controllers/management/budgets/investments_controller.rb
+++ b/app/controllers/management/budgets/investments_controller.rb
@@ -34,6 +34,10 @@ class Management::Budgets::InvestmentsController < Management::BaseController
def vote
@investment.register_selection(managed_user)
load_investment_votes(@investment)
+ respond_to do |format|
+ format.html { redirect_to management_budget_investments_path(heading_id: @investment.heading.id) }
+ format.js
+ end
end
def print
diff --git a/app/controllers/valuation/budget_investments_controller.rb b/app/controllers/valuation/budget_investments_controller.rb
index 03facadb3..666fac74a 100644
--- a/app/controllers/valuation/budget_investments_controller.rb
+++ b/app/controllers/valuation/budget_investments_controller.rb
@@ -21,6 +21,11 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
def valuate
if valid_price_params? && @investment.update(valuation_params)
+
+ if @investment.unfeasible_email_pending?
+ @investment.send_unfeasible_email
+ end
+
redirect_to valuation_budget_budget_investment_path(@budget, @investment), notice: t('valuation.budget_investments.notice.valuate')
else
render action: :edit
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index 3d30ce101..ebde2a954 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -1,13 +1,8 @@
module SearchHelper
def official_level_search_options
- options_for_select([
- [t("shared.advanced_search.author_type_1"), 1],
- [t("shared.advanced_search.author_type_2"), 2],
- [t("shared.advanced_search.author_type_3"), 3],
- [t("shared.advanced_search.author_type_4"), 4],
- [t("shared.advanced_search.author_type_5"), 5]],
- params[:advanced_search].try(:[], :official_level))
+ options_for_select((1..5).map{ |i| [setting["official_level_#{i}_name"], i] },
+ params[:advanced_search].try(:[], :official_level))
end
def date_range_options
@@ -28,4 +23,4 @@ module SearchHelper
params[:advanced_search].try(:[], :date_max).present?
end
-end
\ No newline at end of file
+end
diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb
index 25c019857..188de029b 100644
--- a/app/mailers/mailer.rb
+++ b/app/mailers/mailer.rb
@@ -74,6 +74,23 @@ class Mailer < ApplicationMailer
end
end
+ def budget_investment_created(investment)
+ @investment = investment
+
+ with_user(@investment.author) do
+ mail(to: @investment.author.email, subject: t('mailers.budget_investment_created.subject'))
+ end
+ end
+
+ def budget_investment_unfeasible(investment)
+ @investment = investment
+ @author = investment.author
+
+ with_user(@author) do
+ mail(to: @author.email, subject: t('mailers.budget_investment_unfeasible.subject', code: @investment.code))
+ end
+ end
+
private
def with_user(user, &block)
diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb
index 5389825e5..100433707 100644
--- a/app/models/budget/investment.rb
+++ b/app/models/budget/investment.rb
@@ -136,16 +136,26 @@ class Budget
unfeasible? && valuation_finished?
end
+ def unfeasible_email_pending?
+ unfeasible_email_sent_at.blank? && unfeasible? && valuation_finished?
+ end
+
def total_votes
cached_votes_up + physical_votes
end
def code
- "B#{budget.id}I#{id}"
+ "#{created_at.strftime('%Y')}-#{id}" + (administrator.present? ? "-A#{administrator.id}" : "")
+ end
+
+ def send_unfeasible_email
+ Mailer.budget_investment_unfeasible(self).deliver_later
+ update(unfeasible_email_sent_at: Time.current)
end
def reason_for_not_being_selectable_by(user)
return permission_problem(user) if permission_problem?(user)
+ return :different_heading_assigned unless valid_heading?(user)
return :no_selecting_allowed unless budget.selecting?
end
@@ -173,6 +183,24 @@ class Budget
reason_for_not_being_selectable_by(user).blank?
end
+ def valid_heading?(user)
+ !different_heading_assigned?(user)
+ end
+
+ def different_heading_assigned?(user)
+ other_heading_ids = group.heading_ids - [heading.id]
+ voted_in?(other_heading_ids, user)
+ end
+
+ def voted_in?(heading_ids, user)
+ heading_ids.include? heading_voted_by_user?(user)
+ end
+
+ def heading_voted_by_user?(user)
+ user.votes.for_budget_investments(budget.investments.where(group: group)).
+ votables.map(&:heading_id).first
+ end
+
def ballotable_by?(user)
reason_for_not_being_ballotable_by(user).blank?
end
@@ -195,11 +223,17 @@ class Budget
end
def should_show_aside?
- (budget.selecting? && !unfeasible?) || (budget.balloting? && feasible?) || budget.on_hold?
+ (budget.selecting? && !unfeasible?) ||
+ (budget.balloting? && feasible?) ||
+ (budget.valuating? && feasible?)
end
def should_show_votes?
- budget.selecting? || budget.on_hold?
+ budget.selecting?
+ end
+
+ def should_show_vote_count?
+ budget.valuating?
end
def should_show_ballots?
diff --git a/app/models/user.rb b/app/models/user.rb
index 82324da7e..a570b1477 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -104,6 +104,10 @@ class User < ActiveRecord::Base
comment_flags.each_with_object({}){ |f, h| h[f.flaggable_id] = true }
end
+ def voted_in_group?(group)
+ votes.for_budget_investments(Budget::Investment.where(group: group)).exists?
+ end
+
def administrator?
administrator.present?
end
diff --git a/app/views/budgets/investments/_feasibility_link.html.erb b/app/views/budgets/investments/_feasibility_link.html.erb
new file mode 100644
index 000000000..118a02e7f
--- /dev/null
+++ b/app/views/budgets/investments/_feasibility_link.html.erb
@@ -0,0 +1,11 @@
+
+
+
+
+<% if params[:unfeasible].present? %>
+ <%= link_to t("budgets.investments.index.sidebar.feasible"),
+ budget_investments_path(@budget, heading_id: @heading, unfeasible: nil) %>
+<% else %>
+ <%= link_to t("budgets.investments.index.sidebar.unfeasible"),
+ budget_investments_path(@budget, heading_id: @heading, unfeasible: 1) %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/budgets/investments/_investment.html.erb b/app/views/budgets/investments/_investment.html.erb
index c9c247784..c9391cbe5 100644
--- a/app/views/budgets/investments/_investment.html.erb
+++ b/app/views/budgets/investments/_investment.html.erb
@@ -46,7 +46,6 @@
<% unless investment.unfeasible? %>
<% if investment.should_show_votes? %>
-
<%= render partial: '/budgets/investments/votes', locals: {
@@ -55,9 +54,17 @@
vote_url: namespaced_budget_investment_vote_path(investment, value: 'yes')
} %>
-
+ <% elsif investment.should_show_vote_count? %>
+
+
+
+ <%= t("budgets.investments.investment.supports",
+ count: investment.total_votes) %>
+
+
+
<% elsif investment.should_show_ballots? %>
-
<%= render partial: '/budgets/investments/ballot', locals: {
@@ -66,7 +73,6 @@
ballot: ballot
} %>
-
<% end %>
<% end %>
diff --git a/app/views/budgets/investments/_investment_show.html.erb b/app/views/budgets/investments/_investment_show.html.erb
index 12f23fe87..fad11d0f0 100644
--- a/app/views/budgets/investments/_investment_show.html.erb
+++ b/app/views/budgets/investments/_investment_show.html.erb
@@ -55,11 +55,10 @@
<% if investment.should_show_aside? %>