pull request中如果登录名在Trustie中不存在则有匿名改成登录名;匿名用户改成邮箱显示

This commit is contained in:
huang 2016-12-15 14:36:08 +08:00
parent 53ecbdf8f0
commit 5b93bf2b4d
6 changed files with 19 additions and 13 deletions

View File

@ -77,10 +77,16 @@ module ApplicationHelper
user.nil? ? User.find(2) : user
end
# 通过邮件查找用户,能查到返回用户,否则返回邮件地址
def user_by_mail mail
user = User.find_by_mail(mail)
user.nil? ? mail : user.try(:show_name)
# 通过登录名查找用户,能查到返回用户姓名,否则返回登录名
def link_to_user_login login, css_class
user = User.find_by_login(login)
user = user.nil? ? login : user
if user.is_a?(User)
name = user.show_name
link_to name, {:controller=> 'users', :action => 'show', id: user.id}, :class => css_class, :target => "_blank"
else
"<a class='#{css_class}'>#{h(user.to_s)}</a>".html_safe
end
end
def link_to_user_mail(mail, css_class)
@ -90,7 +96,7 @@ module ApplicationHelper
name = user.show_name
link_to name, {:controller=> 'users', :action => 'show', id: user.id}, :class => css_class, :target => "_blank"
else
"<a class='#{css_class}'>#{h(user.to_s)}</a>".html_safe
"<a class='#{css_class}' title='#{user.to_s}'>#{h(user.to_s)}</a>".html_safe
end
end

View File

@ -12,7 +12,7 @@
<%= link_to image_tag(url_to_avatar(get_user_by_login_and(comment.author.try(:username))), :width => "43", :height => "43", :class => "pullreques_reply_user_img fl mr15"), user_path(get_user_by_login_and(comment.author.try(:username))), :alt => "用户头像", :target => "_blank", :class => "fl" %>
<div class="sy_teachers_txt fl ">
<p class="clear mb5">
<%= link_to comment.author.try(:username), user_path(get_user_by_login_and(comment.author.try(:username))), :class => "pullreques_reply_name fl", :target => "_blank" %>
<%= link_to_user_login(comment.author.try(:username), "pullreques_reply_name fl") %>
<span class="fl ml15 c_grey"><%= time_tag(comment.created_at) %>前</span>
</p>
<p class="pullreques_reply_txt"><%= comment.note %></p>

View File

@ -8,7 +8,7 @@
<% commits.each do |commit| %>
<li class="clear">
<span class="fl c_grey ml15 "><%= time_tag(commit.created_at) %>前</span>
<%= link_to get_user_by_mail(commit.author_email).show_name, user_path(get_user_by_mail(commit.author_email)), :target => "_blank", :class => "pullreques_pull_name fl ml10" %>
<%= link_to_user_mail(commit.author_email, "pullreques_pull_name fl ml10") %>
<p class="pullreques_pull_txt ml10 fl"><%= commit.title %></p>
<%= link_to truncate(commit.short_id, :length => 20), {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank", :class => "fr mr15 c_grey" %>
</li>

View File

@ -12,7 +12,7 @@
<%= link_to "", project_pull_request_path(request.id, :project_id => @project.id), :class => "issues_icons_mes fr mr5 ml5" %>
</div>
<div class="c_grey clear mt5">
<p class="fl">由 <%= link_to get_user_by_login_and(request.author.try(:username)).try(:show_name), user_path(get_user_by_login_and(request.author.try(:username))), :class => "linkBlue2" %> 创建于<%= time_tag(request.created_at) %>前</p>
<p class="fl">由 <%= link_to_user_login(request.author.try(:username), "linkBlue2") %> 创建于<%= time_tag(request.created_at) %>前</p>
<span class="fl ml10"><%= time_tag(request.updated_at) %>前更新</span>
<p class="fr"><%#= find_gitlab_project(request.source_project_id)+"/"+request.source_branch %><span class="c_grey02 ml10 mr10">合并到</span><%#= find_gitlab_project(request.target_project_id)+"/"+request.target_branch %></p>
</div>

View File

@ -19,7 +19,7 @@
<p><%= @request.description %></p>
</div>
<div class="c_grey clear mt5">
<p class="fl">由 <%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "linkBlue2" %>于 <%= format_time(@request.created_at) %> 创建</p>
<p class="fl">由 <%= link_to_user_login(@request.author.try(:username), "linkBlue2") %>于 <%= format_time(@request.created_at) %> 创建</p>
<span class="fl ml10">最近更新:<%= format_time(@request.updated_at) %></span>
<p class="fr">
<%= find_gitlab_project(@request.source_project_id)+"/"+@request.source_branch %><span class="c_grey02 ml10 mr10">合并到</span><%= find_gitlab_project(@request.target_project_id)+"/"+@request.target_branch %>

View File

@ -6,10 +6,10 @@
<div class="alert alert-orange mb15 ">
项目分支 <%= @request.source_branch %> 和 <%= @request.target_branch %> 似乎没有差异,请将新改动提交至源分支或者切换到其它目标分支
</div>
<% elsif !@request.merge_when_build_succeeds %>
<div class="alert alert-orange mb15 ">
Pull Request中存在冲突请先解决冲突或者手动进行合并。
</div>
<%# elsif !@request.merge_when_build_succeeds %>
<!--<div class="alert alert-orange mb15 ">-->
<!--Pull Request中存在冲突请先解决冲突或者手动进行合并。-->
<!--</div>-->
<% else %>
<% if is_project_manager?(User.current.id, @project.id) %>
<div class="alert alert-orange mb15 ">