Add methods to get a bug's author details from the first comment
This commit is contained in:
parent
882700c5c8
commit
f77a3c75be
6 changed files with 32 additions and 16 deletions
|
@ -226,7 +226,7 @@ class MapBugsController < ApplicationController
|
||||||
@page_size = 10
|
@page_size = 10
|
||||||
|
|
||||||
@bugs = MapBug.find(:all,
|
@bugs = MapBug.find(:all,
|
||||||
:include => [:comments, {:comments => :user}],
|
:include => [:comments, {:comments => :author}],
|
||||||
:joins => :comments,
|
:joins => :comments,
|
||||||
:order => "updated_at DESC",
|
:order => "updated_at DESC",
|
||||||
:conditions => conditions,
|
:conditions => conditions,
|
||||||
|
@ -302,10 +302,10 @@ private
|
||||||
|
|
||||||
sent_to = Set.new
|
sent_to = Set.new
|
||||||
bug.comments.each do | cmt |
|
bug.comments.each do | cmt |
|
||||||
if cmt.user
|
if cmt.author
|
||||||
unless sent_to.include?(cmt.user)
|
unless sent_to.include?(cmt.author)
|
||||||
Notifier.deliver_bug_comment_notification(bug_comment, cmt.user) unless cmt.user == @user
|
Notifier.deliver_bug_comment_notification(bug_comment, cmt.author) unless cmt.author == @user
|
||||||
sent_to.add(cmt.user)
|
sent_to.add(cmt.author)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,4 +46,20 @@ class MapBug < ActiveRecord::Base
|
||||||
def visible
|
def visible
|
||||||
return status != "hidden"
|
return status != "hidden"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def author
|
||||||
|
self.comments.first.author
|
||||||
|
end
|
||||||
|
|
||||||
|
def author_ip
|
||||||
|
self.comments.first.author_ip
|
||||||
|
end
|
||||||
|
|
||||||
|
def author_id
|
||||||
|
self.comments.first.author_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def author_name
|
||||||
|
self.comments.first.author_name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
class MapBugComment < ActiveRecord::Base
|
class MapBugComment < ActiveRecord::Base
|
||||||
set_table_name 'map_bug_comment'
|
set_table_name 'map_bug_comment'
|
||||||
|
|
||||||
belongs_to :map_bug, :foreign_key => 'bug_id'
|
belongs_to :map_bug, :foreign_key => :bug_id
|
||||||
belongs_to :user, :foreign_key => 'author_id'
|
belongs_to :author, :class_name => "User", :foreign_key => :author_id
|
||||||
|
|
||||||
validates_inclusion_of :event, :in => [ "opened", "closed", "reopened", "commented", "hidden" ]
|
validates_inclusion_of :event, :in => [ "opened", "closed", "reopened", "commented", "hidden" ]
|
||||||
validates_presence_of :id, :on => :update
|
validates_presence_of :id, :on => :update
|
||||||
|
@ -13,7 +13,7 @@ class MapBugComment < ActiveRecord::Base
|
||||||
if self.author_id.nil?
|
if self.author_id.nil?
|
||||||
self.read_attribute(:author_name)
|
self.read_attribute(:author_name)
|
||||||
else
|
else
|
||||||
self.user.display_name
|
self.author.display_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -97,7 +97,7 @@ class Notifier < ActionMailer::Base
|
||||||
|
|
||||||
def bug_comment_notification(bug_comment, recipient)
|
def bug_comment_notification(bug_comment, recipient)
|
||||||
common_headers recipient
|
common_headers recipient
|
||||||
owner = (recipient == bug_comment.map_bug.comments.first.user);
|
owner = (recipient == bug_comment.map_bug.author);
|
||||||
subject I18n.t('notifier.map_bug_plain.subject_own', :commenter => bug_comment.author_name) if owner
|
subject I18n.t('notifier.map_bug_plain.subject_own', :commenter => bug_comment.author_name) if owner
|
||||||
subject I18n.t('notifier.map_bug_plain.subject_other', :commenter => bug_comment.author_name) unless owner
|
subject I18n.t('notifier.map_bug_plain.subject_other', :commenter => bug_comment.author_name) unless owner
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,10 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<tr>
|
<tr>
|
||||||
<th><%= t 'browse.bug.opened_by' %></th>
|
<th><%= t 'browse.bug.opened_by' %></th>
|
||||||
<% if @bug.comments.first.user.nil? %>
|
<% if @bug.author.nil? %>
|
||||||
<td> <%= @bug.comments.first.author_name %> </td>
|
<td> <%= @bug.author_name %> </td>
|
||||||
<% else %>
|
<% else %>
|
||||||
<td><%= link_to h(@bug.comments.first.user.display_name), :controller => "user", :action => "view", :display_name => @bug.comments.first.user.display_name %></td>
|
<td><%= link_to h(@bug.author_name), :controller => "user", :action => "view", :display_name => @bug.author_name %></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<th><%= t'bugs.user.last_changed' %></th>
|
<th><%= t'bugs.user.last_changed' %></th>
|
||||||
</tr>
|
</tr>
|
||||||
<% @bugs.each do |bug| %>
|
<% @bugs.each do |bug| %>
|
||||||
<tr<% if bug.comments.first.user != @user2 %> bgcolor="#EEEEEE"<% end %>>
|
<tr<% if bug.author != @user2 %> bgcolor="#EEEEEE"<% end %>>
|
||||||
<td>
|
<td>
|
||||||
<% if bug.status == "closed" %>
|
<% if bug.status == "closed" %>
|
||||||
<%= image_tag("closed_bug_marker.png", :alt => 'closed') %>
|
<%= image_tag("closed_bug_marker.png", :alt => 'closed') %>
|
||||||
|
@ -22,10 +22,10 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= link_to bug.id.to_s, :controller => "browse", :action => "bug", :id => bug.id %></td>
|
<td><%= link_to bug.id.to_s, :controller => "browse", :action => "bug", :id => bug.id %></td>
|
||||||
<% if bug.comments.first.user.nil? %>
|
<% if bug.author.nil? %>
|
||||||
<td> <%= bug.comments.first.author_name %> </td>
|
<td> <%= bug.author_name %> </td>
|
||||||
<% else %>
|
<% else %>
|
||||||
<td><%= link_to h(bug.comments.first.user.display_name), :controller => "user", :action => "view", :display_name => bug.comments.first.user.display_name %></td>
|
<td><%= link_to h(bug.author_name), :controller => "user", :action => "view", :display_name => bug.author_name %></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td> <%= htmlize bug.comments.first.body %> </td>
|
<td> <%= htmlize bug.comments.first.body %> </td>
|
||||||
<td><%= l bug.created_at %></td>
|
<td><%= l bug.created_at %></td>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue