Use double quotes in app/helpers

This commit is contained in:
Julian Herrero
2019-03-15 09:26:49 +01:00
parent d9eaea4ea0
commit b460c024f3
27 changed files with 66 additions and 66 deletions

View File

@@ -1,7 +1,7 @@
module AdminBudgetInvestmentsHelper module AdminBudgetInvestmentsHelper
def advanced_menu_visibility def advanced_menu_visibility
(params[:advanced_filters].empty? && params["min_total_supports"].blank?) ? 'hide' : '' (params[:advanced_filters].empty? && params["min_total_supports"].blank?) ? "hide" : ""
end end
def init_advanced_menu def init_advanced_menu

View File

@@ -1,7 +1,7 @@
module AdminHelper module AdminHelper
def side_menu def side_menu
if namespace == 'moderation/budgets' if namespace == "moderation/budgets"
render "/moderation/menu" render "/moderation/menu"
else else
render "/#{namespace}/menu" render "/#{namespace}/menu"
@@ -13,7 +13,7 @@ module AdminHelper
end end
def namespaced_header_title def namespaced_header_title
if namespace == 'moderation/budgets' if namespace == "moderation/budgets"
t("moderation.header.title") t("moderation.header.title")
else else
t("#{namespace}.header.title") t("#{namespace}.header.title")
@@ -71,13 +71,13 @@ module AdminHelper
def official_level_options def official_level_options
options = [["", 0]] options = [["", 0]]
(1..5).each do |i| (1..5).each do |i|
options << [[t("admin.officials.level_#{i}"), setting["official_level_#{i}_name"]].compact.join(': '), i] options << [[t("admin.officials.level_#{i}"), setting["official_level_#{i}_name"]].compact.join(": "), i]
end end
options options
end end
def admin_select_options def admin_select_options
Administrator.all.order('users.username asc').includes(:user).collect { |v| [ v.name, v.id ] } Administrator.all.order("users.username asc").includes(:user).collect { |v| [ v.name, v.id ] }
end end
def admin_submit_action(resource) def admin_submit_action(resource)

View File

@@ -4,10 +4,10 @@ module ApplicationHelper
return false if user_signed_in? return false if user_signed_in?
# Using path because fullpath yields false negatives since it contains # Using path because fullpath yields false negatives since it contains
# parameters too # parameters too
request.path == '/' request.path == "/"
end end
# if current path is /debates current_path_with_query_params(foo: 'bar') returns /debates?foo=bar # if current path is /debates current_path_with_query_params(foo: "bar") returns /debates?foo=bar
# notice: if query_params have a param which also exist in current path, it "overrides" (query_params is merged last) # notice: if query_params have a param which also exist in current path, it "overrides" (query_params is merged last)
def current_path_with_query_params(query_parameters) def current_path_with_query_params(query_parameters)
url_for(request.query_parameters.merge(query_parameters)) url_for(request.query_parameters.merge(query_parameters))

View File

@@ -1,12 +1,12 @@
module BudgetsHelper module BudgetsHelper
def show_links_to_budget_investments(budget) def show_links_to_budget_investments(budget)
['balloting', 'reviewing_ballots', 'finished'].include? budget.phase ["balloting", "reviewing_ballots", "finished"].include? budget.phase
end end
def heading_name_and_price_html(heading, budget) def heading_name_and_price_html(heading, budget)
content_tag :div do content_tag :div do
concat(heading.name + ' ') concat(heading.name + " ")
concat(content_tag(:span, budget.formatted_heading_price(heading))) concat(content_tag(:span, budget.formatted_heading_price(heading)))
end end
end end

View File

@@ -6,9 +6,9 @@ module DebatesHelper
def empty_recommended_debates_message_text(user) def empty_recommended_debates_message_text(user)
if user.interests.any? if user.interests.any?
t('debates.index.recommendations.without_results') t("debates.index.recommendations.without_results")
else else
t('debates.index.recommendations.without_interests') t("debates.index.recommendations.without_interests")
end end
end end

View File

@@ -1,7 +1,7 @@
module DocumentablesHelper module DocumentablesHelper
def documentable_class(documentable) def documentable_class(documentable)
documentable.class.name.parameterize('_') documentable.class.name.parameterize("_")
end end
def max_documents_allowed(documentable) def max_documents_allowed(documentable)

View File

@@ -5,7 +5,7 @@ module DocumentsHelper
end end
def document_errors_on_attachment(document) def document_errors_on_attachment(document)
document.errors[:attachment].join(', ') if document.errors.key?(:attachment) document.errors[:attachment].join(", ") if document.errors.key?(:attachment)
end end
def bytes_to_mega(bytes) def bytes_to_mega(bytes)
@@ -18,7 +18,7 @@ module DocumentsHelper
def render_destroy_document_link(builder, document) def render_destroy_document_link(builder, document)
if !document.persisted? && document.cached_attachment.present? if !document.persisted? && document.cached_attachment.present?
link_to t('documents.form.delete_button'), link_to t("documents.form.delete_button"),
direct_upload_destroy_url("direct_upload[resource_type]": document.documentable_type, direct_upload_destroy_url("direct_upload[resource_type]": document.documentable_type,
"direct_upload[resource_id]": document.documentable_id, "direct_upload[resource_id]": document.documentable_id,
"direct_upload[resource_relation]": "documents", "direct_upload[resource_relation]": "documents",
@@ -27,7 +27,7 @@ module DocumentsHelper
remote: true, remote: true,
class: "delete remove-cached-attachment" class: "delete remove-cached-attachment"
else else
link_to_remove_association document.new_record? ? t('documents.form.cancel_button') : t('documents.form.delete_button') , builder, class: "delete remove-document" link_to_remove_association document.new_record? ? t("documents.form.cancel_button") : t("documents.form.delete_button") , builder, class: "delete remove-document"
end end
end end
@@ -40,7 +40,7 @@ module DocumentsHelper
html += builder.file_field :attachment, html += builder.file_field :attachment,
label: false, label: false,
accept: accepted_content_types_extensions(document.documentable_type.constantize), accept: accepted_content_types_extensions(document.documentable_type.constantize),
class: 'js-document-attachment', class: "js-document-attachment",
data: { data: {
url: document_direct_upload_url(document), url: document_direct_upload_url(document),
nested_document: true nested_document: true

View File

@@ -5,7 +5,7 @@ module EmbedVideosHelper
def embedded_video_code def embedded_video_code
link = @proposal.video_url link = @proposal.video_url
title = t('proposals.show.embed_video_title', proposal: @proposal.title) title = t("proposals.show.embed_video_title", proposal: @proposal.title)
if link =~ /vimeo.*/ if link =~ /vimeo.*/
server = "Vimeo" server = "Vimeo"
elsif link =~ /youtu*.*/ elsif link =~ /youtu*.*/
@@ -27,7 +27,7 @@ module EmbedVideosHelper
if match && match[2] if match && match[2]
'<iframe src="' + src + match[2] + '" style="border:0;" allowfullscreen title="' + title + '"></iframe>' '<iframe src="' + src + match[2] + '" style="border:0;" allowfullscreen title="' + title + '"></iframe>'
else else
'' ""
end end
end end

View File

@@ -6,8 +6,8 @@ module FollowablesHelper
def followable_icon(followable) def followable_icon(followable)
{ {
proposals: 'Proposal', proposals: "Proposal",
budget: 'Budget::Investment' budget: "Budget::Investment"
}.invert[followable] }.invert[followable]
end end

View File

@@ -2,12 +2,12 @@ module FollowsHelper
def follow_text(followable) def follow_text(followable)
entity = followable.class.name.underscore entity = followable.class.name.underscore
t('shared.follow_entity', entity: t("activerecord.models.#{entity}.one").downcase) t("shared.follow_entity", entity: t("activerecord.models.#{entity}.one").downcase)
end end
def unfollow_text(followable) def unfollow_text(followable)
entity = followable.class.name.underscore entity = followable.class.name.underscore
t('shared.unfollow_entity', entity: t("activerecord.models.#{entity}.one").downcase) t("shared.unfollow_entity", entity: t("activerecord.models.#{entity}.one").downcase)
end end
end end

View File

@@ -5,7 +5,7 @@ module ImageablesHelper
end end
def imageable_class(imageable) def imageable_class(imageable)
imageable.class.name.parameterize('_') imageable.class.name.parameterize("_")
end end
def imageable_max_file_size def imageable_max_file_size

View File

@@ -19,7 +19,7 @@ module ImagesHelper
end end
def image_errors_on_attachment(image) def image_errors_on_attachment(image)
image.errors[:attachment].join(', ') if image.errors.key?(:attachment) image.errors[:attachment].join(", ") if image.errors.key?(:attachment)
end end
def image_bytes_to_megabytes(bytes) def image_bytes_to_megabytes(bytes)
@@ -32,7 +32,7 @@ module ImagesHelper
def render_destroy_image_link(builder, image) def render_destroy_image_link(builder, image)
if !image.persisted? && image.cached_attachment.present? if !image.persisted? && image.cached_attachment.present?
link_to t('images.form.delete_button'), link_to t("images.form.delete_button"),
direct_upload_destroy_url("direct_upload[resource_type]": image.imageable_type, direct_upload_destroy_url("direct_upload[resource_type]": image.imageable_type,
"direct_upload[resource_id]": image.imageable_id, "direct_upload[resource_id]": image.imageable_id,
"direct_upload[resource_relation]": "image", "direct_upload[resource_relation]": "image",
@@ -41,7 +41,7 @@ module ImagesHelper
remote: true, remote: true,
class: "delete remove-cached-attachment" class: "delete remove-cached-attachment"
else else
link_to_remove_association t('images.form.delete_button'), builder, class: "delete remove-image" link_to_remove_association t("images.form.delete_button"), builder, class: "delete remove-image"
end end
end end
@@ -54,7 +54,7 @@ module ImagesHelper
html += builder.file_field :attachment, html += builder.file_field :attachment,
label: false, label: false,
accept: imageable_accepted_content_types_extensions, accept: imageable_accepted_content_types_extensions,
class: 'js-image-attachment', class: "js-image-attachment",
data: { data: {
url: image_direct_upload_url(imageable), url: image_direct_upload_url(imageable),
nested_image: true nested_image: true

View File

@@ -2,7 +2,7 @@ module LayoutsHelper
def layout_menu_link_to(text, path, is_active, options) def layout_menu_link_to(text, path, is_active, options)
if is_active if is_active
content_tag(:span, t('shared.you_are_in'), class: 'show-for-sr') + ' ' + content_tag(:span, t("shared.you_are_in"), class: "show-for-sr") + " " +
link_to(text, path, options.merge(class: "is-active")) link_to(text, path, options.merge(class: "is-active"))
else else
link_to(text, path, options) link_to(text, path, options)

View File

@@ -14,10 +14,10 @@ module LegislationHelper
def link_to_toggle_legislation_proposal_selection(proposal) def link_to_toggle_legislation_proposal_selection(proposal)
if proposal.selected? if proposal.selected?
button_text = t("admin.legislation.proposals.index.selected") button_text = t("admin.legislation.proposals.index.selected")
html_class = 'button expanded' html_class = "button expanded"
else else
button_text = t("admin.legislation.proposals.index.select") button_text = t("admin.legislation.proposals.index.select")
html_class = 'button hollow expanded' html_class = "button hollow expanded"
end end
link_to button_text, link_to button_text,

View File

@@ -1,7 +1,7 @@
module OfficersHelper module OfficersHelper
def officer_label(officer) def officer_label(officer)
truncate([officer.name, officer.email].compact.join(' - '), length: 100) truncate([officer.name, officer.email].compact.join(" - "), length: 100)
end end
def vote_collection_shift? def vote_collection_shift?

View File

@@ -42,7 +42,7 @@ module PollsHelper
end end
def poll_voter_token(poll, user) def poll_voter_token(poll, user)
Poll::Voter.where(poll: poll, user: user, origin: "web").first&.token || '' Poll::Voter.where(poll: poll, user: user, origin: "web").first&.token || ""
end end
def voted_before_sign_in(question) def voted_before_sign_in(question)

View File

@@ -11,12 +11,12 @@ module SearchHelper
[t("shared.advanced_search.date_2"), 2], [t("shared.advanced_search.date_2"), 2],
[t("shared.advanced_search.date_3"), 3], [t("shared.advanced_search.date_3"), 3],
[t("shared.advanced_search.date_4"), 4], [t("shared.advanced_search.date_4"), 4],
[t("shared.advanced_search.date_5"), 'custom']], [t("shared.advanced_search.date_5"), "custom"]],
selected_date_range) selected_date_range)
end end
def selected_date_range def selected_date_range
custom_date_range? ? 'custom' : params[:advanced_search].try(:[], :date_min) custom_date_range? ? "custom" : params[:advanced_search].try(:[], :date_min)
end end
def custom_date_range? def custom_date_range?

View File

@@ -1,7 +1,7 @@
module SettingsHelper module SettingsHelper
def setting_for_widget(widget) def setting_for_widget(widget)
Setting.where(key: 'feature.user.recommendations').first Setting.where(key: "feature.user.recommendations").first
end end
end end

View File

@@ -1,28 +1,28 @@
module StatsHelper module StatsHelper
def events_chart_tag(events, opt = {}) def events_chart_tag(events, opt = {})
events = events.join(',') if events.is_a? Array events = events.join(",") if events.is_a? Array
opt[:data] ||= {} opt[:data] ||= {}
opt[:data][:graph] = admin_api_stats_path(events: events) opt[:data][:graph] = admin_api_stats_path(events: events)
content_tag :div, "", opt content_tag :div, "", opt
end end
def visits_chart_tag(opt = {}) def visits_chart_tag(opt = {})
events = events.join(',') if events.is_a? Array events = events.join(",") if events.is_a? Array
opt[:data] ||= {} opt[:data] ||= {}
opt[:data][:graph] = admin_api_stats_path(visits: true) opt[:data][:graph] = admin_api_stats_path(visits: true)
content_tag :div, "", opt content_tag :div, "", opt
end end
def spending_proposals_chart_tag(opt = {}) def spending_proposals_chart_tag(opt = {})
events = events.join(',') if events.is_a? Array events = events.join(",") if events.is_a? Array
opt[:data] ||= {} opt[:data] ||= {}
opt[:data][:graph] = admin_api_stats_path(spending_proposals: true) opt[:data][:graph] = admin_api_stats_path(spending_proposals: true)
content_tag :div, "", opt content_tag :div, "", opt
end end
def budget_investments_chart_tag(opt = {}) def budget_investments_chart_tag(opt = {})
events = events.join(',') if events.is_a? Array events = events.join(",") if events.is_a? Array
opt[:data] ||= {} opt[:data] ||= {}
opt[:data][:graph] = admin_api_stats_path(budget_investments: true) opt[:data][:graph] = admin_api_stats_path(budget_investments: true)
content_tag :div, "", opt content_tag :div, "", opt

View File

@@ -2,32 +2,32 @@ module TagsHelper
def taggables_path(taggable_type, tag_name) def taggables_path(taggable_type, tag_name)
case taggable_type case taggable_type
when 'debate' when "debate"
debates_path(search: tag_name) debates_path(search: tag_name)
when 'proposal' when "proposal"
proposals_path(search: tag_name) proposals_path(search: tag_name)
when 'budget/investment' when "budget/investment"
budget_investments_path(@budget, search: tag_name) budget_investments_path(@budget, search: tag_name)
when 'legislation/proposal' when "legislation/proposal"
legislation_process_proposals_path(@process, search: tag_name) legislation_process_proposals_path(@process, search: tag_name)
else else
'#' "#"
end end
end end
def taggable_path(taggable) def taggable_path(taggable)
taggable_type = taggable.class.name.underscore taggable_type = taggable.class.name.underscore
case taggable_type case taggable_type
when 'debate' when "debate"
debate_path(taggable) debate_path(taggable)
when 'proposal' when "proposal"
proposal_path(taggable) proposal_path(taggable)
when 'budget/investment' when "budget/investment"
budget_investment_path(taggable.budget_id, taggable) budget_investment_path(taggable.budget_id, taggable)
when 'legislation/proposal' when "legislation/proposal"
legislation_process_proposal_path(@process, taggable) legislation_process_proposal_path(@process, taggable)
else else
'#' "#"
end end
end end

View File

@@ -4,11 +4,11 @@ module TracksHelper
track_data = "" track_data = ""
prefix = " data-track-event-" prefix = " data-track-event-"
data.each do |key, value| data.each do |key, value|
track_data = track_data + prefix + key.to_s + '=' + value + " " track_data = track_data + prefix + key.to_s + "=" + value + " "
end end
content_for :track_event do content_for :track_event do
track_data track_data
end end
end end
end end

View File

@@ -16,8 +16,8 @@ module UsersHelper
if commentable.nil? if commentable.nil?
deleted_commentable_text(comment) deleted_commentable_text(comment)
elsif commentable.hidden? elsif commentable.hidden?
content_tag(:del, commentable.title) + ' ' + content_tag(:del, commentable.title) + " " +
content_tag(:span, '(' + deleted_commentable_text(comment) + ')', class: 'small') content_tag(:span, "(" + deleted_commentable_text(comment) + ")", class: "small")
else else
link_to(commentable.title, comment) link_to(commentable.title, comment)
end end
@@ -58,9 +58,9 @@ module UsersHelper
def interests_title_text(user) def interests_title_text(user)
if current_user == user if current_user == user
t('account.show.public_interests_my_title_list') t("account.show.public_interests_my_title_list")
else else
t('account.show.public_interests_user_title_list') t("account.show.public_interests_user_title_list")
end end
end end

View File

@@ -22,8 +22,8 @@ module ValuationHelper
valuators.first.name + valuators.first.name +
"</span>".html_safe "</span>".html_safe
else else
"<span title=\"".html_safe + valuators.map(&:name).join(', ') + "\">".html_safe + "<span title=\"".html_safe + valuators.map(&:name).join(", ") + "\">".html_safe +
t('valuation.budget_investments.index.valuators_assigned', count: valuators.size) + t("valuation.budget_investments.index.valuators_assigned", count: valuators.size) +
"</span>".html_safe "</span>".html_safe
end end
end end

View File

@@ -1,7 +1,7 @@
module ValuatorsHelper module ValuatorsHelper
def valuator_label(valuator) def valuator_label(valuator)
truncate([valuator.name, valuator.email, valuator.description].compact.join(' - '), length: 100) truncate([valuator.name, valuator.email, valuator.description].compact.join(" - "), length: 100)
end end
end end

View File

@@ -1,9 +1,9 @@
module VerificationHelper module VerificationHelper
def document_types def document_types
[[t('verification.residence.new.document_type.spanish_id'), 1], [[t("verification.residence.new.document_type.spanish_id"), 1],
[t('verification.residence.new.document_type.passport'), 2], [t("verification.residence.new.document_type.passport"), 2],
[t('verification.residence.new.document_type.residence_card'), 3]] [t("verification.residence.new.document_type.residence_card"), 3]]
end end
def mask_phone(number) def mask_phone(number)

View File

@@ -6,9 +6,9 @@ module VotesHelper
def votes_percentage(vote, debate) def votes_percentage(vote, debate)
return "0%" if debate.total_votes == 0 return "0%" if debate.total_votes == 0
if vote == 'likes' if vote == "likes"
debate_percentage_of_likes(debate).to_s + "%" debate_percentage_of_likes(debate).to_s + "%"
elsif vote == 'dislikes' elsif vote == "dislikes"
(100 - debate_percentage_of_likes(debate)).to_s + "%" (100 - debate_percentage_of_likes(debate)).to_s + "%"
end end
end end

View File

@@ -15,7 +15,7 @@ module WelcomeHelper
when "Proposal" when "Proposal"
proposal_path(recommended) proposal_path(recommended)
else else
'#' "#"
end end
end end