2015-12-15 14:51:16 +00:00
|
|
|
module Banzai
|
|
|
|
module Filter
|
2015-04-14 22:34:01 +00:00
|
|
|
# HTML filter that replaces issue references with links. References to
|
|
|
|
# issues that do not exist are ignored.
|
2015-04-03 00:46:43 +00:00
|
|
|
#
|
|
|
|
# This filter supports cross-project references.
|
2015-11-16 20:56:28 +00:00
|
|
|
class IssueReferenceFilter < AbstractReferenceFilter
|
|
|
|
def self.object_class
|
|
|
|
Issue
|
2015-04-03 00:46:43 +00:00
|
|
|
end
|
|
|
|
|
2016-03-17 20:39:50 +00:00
|
|
|
def self.user_can_see_reference?(user, node, context)
|
2016-05-04 23:16:16 +00:00
|
|
|
# It is not possible to check access rights for external issue trackers
|
|
|
|
return true if context[:project].try(:external_issue_tracker)
|
|
|
|
|
2016-03-17 20:39:50 +00:00
|
|
|
issue = Issue.find(node.attr('data-issue')) rescue nil
|
|
|
|
Ability.abilities.allowed?(user, :read_issue, issue)
|
|
|
|
end
|
|
|
|
|
2015-11-16 20:56:28 +00:00
|
|
|
def find_object(project, id)
|
|
|
|
project.get_issue(id)
|
2015-04-03 00:46:43 +00:00
|
|
|
end
|
|
|
|
|
2015-11-16 20:56:28 +00:00
|
|
|
def url_for_object(issue, project)
|
|
|
|
IssuesHelper.url_for_issue(issue.iid, project, only_path: context[:only_path])
|
2015-04-03 00:46:43 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|