debian-mirror-gitlab/app/helpers/award_emoji_helper.rb

17 lines
669 B
Ruby
Raw Normal View History

2016-09-29 09:46:39 +05:30
module AwardEmojiHelper
def toggle_award_url(awardable)
2017-08-17 22:00:37 +05:30
return url_for([:toggle_award_emoji, awardable]) unless @project || awardable.is_a?(Note)
2016-11-03 12:29:30 +05:30
if awardable.is_a?(Note)
2017-08-17 22:00:37 +05:30
# We render a list of notes very frequently and calling the specific method is a lot faster than the generic one (4.5x)
if awardable.for_personal_snippet?
toggle_award_emoji_snippet_note_path(awardable.noteable, awardable)
else
toggle_award_emoji_namespace_project_note_path(@project.namespace, @project, awardable.id)
end
2016-09-29 09:46:39 +05:30
else
2016-11-03 12:29:30 +05:30
url_for([:toggle_award_emoji, @project.namespace.becomes(Namespace), @project, awardable])
2016-09-29 09:46:39 +05:30
end
end
end