We were very inconsistent regarding these rules. Personally I prefer no empty lines around blocks, clases, etc... as recommended by the Ruby style guide [1], and they're the default values in rubocop, so those are the settings I'm applying. The exception is the `private` access modifier, since we were leaving empty lines around it most of the time. That's the default rubocop rule as well. Personally I don't have a strong preference about this one. [1] https://rubystyle.guide/#empty-lines-around-bodies
75 lines
1.8 KiB
Ruby
75 lines
1.8 KiB
Ruby
module UsersHelper
|
|
def humanize_document_type(document_type)
|
|
case document_type
|
|
when "1"
|
|
t "verification.residence.new.document_type.spanish_id"
|
|
when "2"
|
|
t "verification.residence.new.document_type.passport"
|
|
when "3"
|
|
t "verification.residence.new.document_type.residence_card"
|
|
end
|
|
end
|
|
|
|
def comment_commentable_title(comment)
|
|
commentable = comment.commentable
|
|
if commentable.nil?
|
|
deleted_commentable_text(comment)
|
|
elsif commentable.hidden?
|
|
content_tag(:del, commentable.title) + " " +
|
|
content_tag(:span, "(" + deleted_commentable_text(comment) + ")", class: "small")
|
|
else
|
|
link_to(commentable.title, comment)
|
|
end
|
|
end
|
|
|
|
def deleted_commentable_text(comment)
|
|
case comment.commentable_type
|
|
when "Proposal"
|
|
t("users.show.deleted_proposal")
|
|
when "Debate"
|
|
t("users.show.deleted_debate")
|
|
when "Budget::Investment"
|
|
t("users.show.deleted_budget_investment")
|
|
else
|
|
t("users.show.deleted")
|
|
end
|
|
end
|
|
|
|
def current_administrator?
|
|
current_user&.administrator?
|
|
end
|
|
|
|
def current_moderator?
|
|
current_user&.moderator?
|
|
end
|
|
|
|
def current_valuator?
|
|
current_user&.valuator?
|
|
end
|
|
|
|
def current_manager?
|
|
current_user&.manager?
|
|
end
|
|
|
|
def current_poll_officer?
|
|
current_user&.poll_officer?
|
|
end
|
|
|
|
def current_tracker?
|
|
current_user&.tracker?
|
|
end
|
|
|
|
def show_admin_menu?(user = nil)
|
|
current_administrator? || current_moderator? || current_valuator? || current_manager? ||
|
|
current_tracker? || (user&.administrator?) || current_poll_officer?
|
|
end
|
|
|
|
def interests_title_text(user)
|
|
if current_user == user
|
|
t("account.show.public_interests_my_title_list")
|
|
else
|
|
t("account.show.public_interests_user_title_list")
|
|
end
|
|
end
|
|
end
|