[#19] can reference all users and groups

This commit is contained in:
Alexander Machehin 2013-04-10 16:23:27 +06:00
parent 94d7865f14
commit 49feaf9d73
2 changed files with 8 additions and 4 deletions

View File

@ -51,6 +51,10 @@ class Group < Avatar
false
end
def fullname
return description.present? ? "#{uname} (#{description})" : uname
end
protected
def add_owner_to_members

View File

@ -100,7 +100,7 @@ module Modules
REFERENCE_PATTERN = %r{
(?<prefix>[\W\/])? # Prefix
( # Reference
@(?<user>[a-zA-Z][a-zA-Z0-9_\-\.]*) # User uname
@(?<user>[a-zA-Z][a-zA-Z0-9_\-\.]*) # User/Group uname
|(?<issue>(?:[a-zA-Z0-9\-_]*\/)?(?:[a-zA-Z0-9\-_]*)?\#[0-9]+) # Issue ID
|(?<commit>[\h]{6,40}) # Commit ID
)
@ -161,9 +161,9 @@ module Modules
end
def reference_user(identifier)
member = @project.all_members.select {|u| u.uname == identifier}
if member[0]
link_to("@#{identifier}", user_path(identifier), html_options.merge(title: member[0].fullname, class: "gfm gfm-team_member #{html_options[:class]}"))
member = User.where(uname: identifier).first || Group.where(uname: identifier).first
if member
link_to("@#{identifier}", "/#{identifier}", html_options.merge(title: member.fullname, class: "gfm gfm-member #{html_options[:class]}"))
end
end