Merge branch 'master' into legislation-module-stable

This commit is contained in:
Amaia Castro
2017-03-29 14:28:22 +02:00
11 changed files with 96 additions and 14 deletions

View File

@@ -129,16 +129,16 @@ module CommentableActions
when '4'
1.year.ago
else
Date.parse(params[:advanced_search][:date_min]) rescue nil
Date.parse(params[:advanced_search][:date_min]) rescue 100.years.ago
end
end
def search_finish_date
params[:advanced_search][:date_max].try(:to_date) || Date.today
(params[:advanced_search][:date_max].to_date rescue Date.today) || Date.today
end
def search_date_range
search_start_date.beginning_of_day..search_finish_date.end_of_day
[100.years.ago, search_start_date].max.beginning_of_day..[search_finish_date, Date.today].min.end_of_day
end
def set_search_order

View File

@@ -25,6 +25,7 @@ class Budget
validates :description, presence: true
validates :heading_id, presence: true
validates_presence_of :unfeasibility_explanation, if: :unfeasibility_explanation_required?
validates_presence_of :price, if: :price_required?
validates :title, length: { in: 4..Budget::Investment.title_max_length }
validates :description, length: { maximum: Budget::Investment.description_max_length }
@@ -136,6 +137,10 @@ class Budget
unfeasible? && valuation_finished?
end
def price_required?
feasible? && valuation_finished?
end
def unfeasible_email_pending?
unfeasible_email_sent_at.blank? && unfeasible? && valuation_finished?
end
@@ -225,7 +230,7 @@ class Budget
def should_show_aside?
(budget.selecting? && !unfeasible?) ||
(budget.balloting? && feasible?) ||
(budget.valuating? && feasible?)
(budget.valuating? && !unfeasible?)
end
def should_show_votes?

View File

@@ -103,7 +103,7 @@
<div class="social-share-full">
<%= social_share_button_tag("#{investment.title} #{setting['twitter_hashtag']}") %>
<% if browser.device.mobile? %>
<a href="whatsapp://send?text=<%= investment.title %> <%= budget_investment_url(budget_id: investment.budget_id, id: investment.id) %>" data-action="share/whatsapp/share">
<a href="whatsapp://send?text=<%= investment.title.gsub(/\s/, '&nbsp;') %>&nbsp;<%= budget_investment_url(budget_id: investment.budget_id, id: investment.id) %>" data-action="share/whatsapp/share">
<span class="icon-whatsapp whatsapp"></span>
<span class="sr-only"><%= t("social.whatsapp") %></span>
</a>

View File

@@ -53,7 +53,7 @@
<div class="social-share-full">
<%= social_share_button_tag("#{@debate.title} #{setting['twitter_hashtag']}") %>
<% if browser.device.mobile? %>
<a href="whatsapp://send?text=<%= @debate.title %> <%= debate_url(@debate) %>" data-action="share/whatsapp/share">
<a href="whatsapp://send?text=<%= @debate.title.gsub(/\s/, '&nbsp;') %>&nbsp;<%= debate_url(@debate) %>" data-action="share/whatsapp/share">
<span class="icon-whatsapp whatsapp"></span>
<span class="sr-only"><%= t("social.whatsapp") %></span>
</a>

View File

@@ -126,7 +126,7 @@
<div class="social-share-full">
<%= social_share_button_tag("#{@proposal.title} #{setting['twitter_hashtag']}") %>
<% if browser.device.mobile? %>
<a href="whatsapp://send?text=<%= @proposal.title %> <%= proposal_url(@proposal) %>" data-action="share/whatsapp/share">
<a href="whatsapp://send?text=<%= @proposal.title.gsub(/\s/, '&nbsp;') %>&nbsp;<%= proposal_url(@proposal) %>" data-action="share/whatsapp/share">
<span class="icon-whatsapp whatsapp"></span>
<span class="sr-only"><%= t("social.whatsapp") %></span>
</a>

View File

@@ -36,7 +36,6 @@
</label>
<%= text_field_tag 'advanced_search[date_min]',
params[:advanced_search].try(:[], :date_min),
type: "date",
class: 'js-calendar' %>
</div>
<div class='small-12 large-6 column'>
@@ -45,7 +44,6 @@
</label>
<%= text_field_tag 'advanced_search[date_max]',
params[:advanced_search].try(:[], :date_max),
type: "date",
class: 'js-calendar' %>
</div>
</div>

View File

@@ -45,7 +45,7 @@
<div class="social-share-full">
<%= social_share_button_tag("#{@spending_proposal.title} #{setting['twitter_hashtag']}") %>
<% if browser.device.mobile? %>
<a href="whatsapp://send?text=<%= @spending_proposal.title %> <%= spending_proposal_url(@spending_proposal) %>" data-action="share/whatsapp/share">
<a href="whatsapp://send?text=<%= @spending_proposal.title.gsub(/\s/, '&nbsp;') %>&nbsp;<%= spending_proposal_url(@spending_proposal) %>" data-action="share/whatsapp/share">
<span class="icon-whatsapp whatsapp"></span>
<span class="sr-only"><%= t("social.whatsapp") %></span>
</a>