From c90f1d5c8bed09aeb51a11d223025b423b048143 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Sun, 5 Feb 2012 12:58:02 +0200 Subject: [PATCH] fixed issue, mr crash if assignee/author removed from team --- app/helpers/issues_helper.rb | 22 +++++++++++++++++++ app/helpers/merge_requests_helper.rb | 21 ++++++++++++++++++ app/views/issues/_show.html.haml | 4 +--- app/views/issues/show.html.haml | 6 ++--- .../merge_requests/_merge_request.html.haml | 4 +--- app/views/merge_requests/show.html.haml | 6 ++--- 6 files changed, 49 insertions(+), 14 deletions(-) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index d09fad5f..d902be0e 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -9,4 +9,26 @@ module IssuesHelper params[:f] ||= cookies['issue_filter'] project_issues_path project, params end + + def link_to_issue_assignee(issue) + project = issue.project + + tm = project.team_member_by_id(issue.assignee_id) + if tm + link_to issue.assignee_name, project_team_member_path(project, tm), :class => "author_link" + else + issue.assignee_name + end + end + + def link_to_issue_author(issue) + project = issue.project + + tm = project.team_member_by_id(issue.author_id) + if tm + link_to issue.author_name, project_team_member_path(project, tm), :class => "author_link" + else + issue.author_name + end + end end diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index fac9870f..afdf65bd 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -1,2 +1,23 @@ module MergeRequestsHelper + def link_to_merge_request_assignee(merge_request) + project = merge_request.project + + tm = project.team_member_by_id(merge_request.assignee_id) + if tm + link_to merge_request.assignee_name, project_team_member_path(project, tm), :class => "author_link" + else + merge_request.assignee_name + end + end + + def link_to_merge_request_author(merge_request) + project = merge_request.project + + tm = project.team_member_by_id(merge_request.author_id) + if tm + link_to merge_request.author_name, project_team_member_path(project, tm), :class => "author_link" + else + merge_request.author_name + end + end end diff --git a/app/views/issues/_show.html.haml b/app/views/issues/_show.html.haml index cc154d8c..91bbb1aa 100644 --- a/app/views/issues/_show.html.haml +++ b/app/views/issues/_show.html.haml @@ -2,9 +2,7 @@ = image_tag gravatar_icon(issue.assignee_email), :class => "avatar" %span.update-author assigned to - %strong - = link_to project_team_member_path(@project, @project.team_member_by_id(issue.author_id)), :class => "author_link" do - = issue.assignee_name + %strong= link_to_issue_assignee(issue) - if issue.critical %span.label.important critical - if issue.today? diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 2ef59a2f..abf5fc11 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -25,13 +25,11 @@ %div %cite.cgray Created by = image_tag gravatar_icon(@issue.author_email), :width => 16, :class => "lil_av" - = link_to project_team_member_path(@project, @project.team_member_by_id(@issue.author.id)) do - %strong.author= @issue.author_name + %strong.author= link_to_issue_author(@issue) %cite.cgray and currently assigned to = image_tag gravatar_icon(@issue.assignee_email), :width => 16, :class => "lil_av" - = link_to project_team_member_path(@project, @project.team_member_by_id(@issue.assignee.id)) do - %strong.author= @issue.assignee_name + %strong.author= link_to_issue_assignee(@issue) %hr diff --git a/app/views/merge_requests/_merge_request.html.haml b/app/views/merge_requests/_merge_request.html.haml index 33dd7e5d..5852c18c 100644 --- a/app/views/merge_requests/_merge_request.html.haml +++ b/app/views/merge_requests/_merge_request.html.haml @@ -1,9 +1,7 @@ %li.wll = image_tag gravatar_icon(merge_request.author_email), :class => "avatar" %span.update-author - %strong - = link_to project_team_member_path(@project, @project.team_member_by_id(merge_request.author_id)), :class => "author_link" do - = merge_request.author_name + %strong= link_to_merge_request_author(merge_request) authored = time_ago_in_words(merge_request.created_at) ago diff --git a/app/views/merge_requests/show.html.haml b/app/views/merge_requests/show.html.haml index 6293d2d8..9840ea4a 100644 --- a/app/views/merge_requests/show.html.haml +++ b/app/views/merge_requests/show.html.haml @@ -30,13 +30,11 @@ %div %cite.cgray Created by = image_tag gravatar_icon(@merge_request.author_email), :width => 16, :class => "lil_av" - = link_to project_team_member_path(@project, @project.team_member_by_id(@merge_request.author.id)) do - %strong.author= @merge_request.author_name + %strong.author= link_to_merge_request_author(@merge_request) %cite.cgray and currently assigned to = image_tag gravatar_icon(@merge_request.assignee_email), :width => 16, :class => "lil_av" - = link_to project_team_member_path(@project, @project.team_member_by_id(@merge_request.assignee.id)) do - %strong.author= @merge_request.assignee_name + %strong.author= link_to_merge_request_assignee(@merge_request) %hr