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
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
def init_advanced_menu

View File

@@ -1,7 +1,7 @@
module AdminHelper
def side_menu
if namespace == 'moderation/budgets'
if namespace == "moderation/budgets"
render "/moderation/menu"
else
render "/#{namespace}/menu"
@@ -13,7 +13,7 @@ module AdminHelper
end
def namespaced_header_title
if namespace == 'moderation/budgets'
if namespace == "moderation/budgets"
t("moderation.header.title")
else
t("#{namespace}.header.title")
@@ -71,13 +71,13 @@ module AdminHelper
def official_level_options
options = [["", 0]]
(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
options
end
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
def admin_submit_action(resource)

View File

@@ -4,10 +4,10 @@ module ApplicationHelper
return false if user_signed_in?
# Using path because fullpath yields false negatives since it contains
# parameters too
request.path == '/'
request.path == "/"
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)
def current_path_with_query_params(query_parameters)
url_for(request.query_parameters.merge(query_parameters))

View File

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

View File

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

View File

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

View File

@@ -5,7 +5,7 @@ module DocumentsHelper
end
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
def bytes_to_mega(bytes)
@@ -18,7 +18,7 @@ module DocumentsHelper
def render_destroy_document_link(builder, document)
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[resource_id]": document.documentable_id,
"direct_upload[resource_relation]": "documents",
@@ -27,7 +27,7 @@ module DocumentsHelper
remote: true,
class: "delete remove-cached-attachment"
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
@@ -40,7 +40,7 @@ module DocumentsHelper
html += builder.file_field :attachment,
label: false,
accept: accepted_content_types_extensions(document.documentable_type.constantize),
class: 'js-document-attachment',
class: "js-document-attachment",
data: {
url: document_direct_upload_url(document),
nested_document: true

View File

@@ -5,7 +5,7 @@ module EmbedVideosHelper
def embedded_video_code
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.*/
server = "Vimeo"
elsif link =~ /youtu*.*/
@@ -27,7 +27,7 @@ module EmbedVideosHelper
if match && match[2]
'<iframe src="' + src + match[2] + '" style="border:0;" allowfullscreen title="' + title + '"></iframe>'
else
''
""
end
end

View File

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

View File

@@ -2,12 +2,12 @@ module FollowsHelper
def follow_text(followable)
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
def unfollow_text(followable)
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

View File

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

View File

@@ -19,7 +19,7 @@ module ImagesHelper
end
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
def image_bytes_to_megabytes(bytes)
@@ -32,7 +32,7 @@ module ImagesHelper
def render_destroy_image_link(builder, image)
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[resource_id]": image.imageable_id,
"direct_upload[resource_relation]": "image",
@@ -41,7 +41,7 @@ module ImagesHelper
remote: true,
class: "delete remove-cached-attachment"
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
@@ -54,7 +54,7 @@ module ImagesHelper
html += builder.file_field :attachment,
label: false,
accept: imageable_accepted_content_types_extensions,
class: 'js-image-attachment',
class: "js-image-attachment",
data: {
url: image_direct_upload_url(imageable),
nested_image: true

View File

@@ -2,7 +2,7 @@ module LayoutsHelper
def layout_menu_link_to(text, path, is_active, options)
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"))
else
link_to(text, path, options)

View File

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

View File

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

View File

@@ -42,7 +42,7 @@ module PollsHelper
end
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
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_3"), 3],
[t("shared.advanced_search.date_4"), 4],
[t("shared.advanced_search.date_5"), 'custom']],
[t("shared.advanced_search.date_5"), "custom"]],
selected_date_range)
end
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
def custom_date_range?

View File

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

View File

@@ -1,28 +1,28 @@
module StatsHelper
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][:graph] = admin_api_stats_path(events: events)
content_tag :div, "", opt
end
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][:graph] = admin_api_stats_path(visits: true)
content_tag :div, "", opt
end
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][:graph] = admin_api_stats_path(spending_proposals: true)
content_tag :div, "", opt
end
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][:graph] = admin_api_stats_path(budget_investments: true)
content_tag :div, "", opt

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
module ValuatorsHelper
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

View File

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

View File

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

View File

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