check_boundaries(@min_lon, @min_lat, @max_lon, @max_lat, :false)
- @bugs = MapBug.find_by_area_no_quadtile(@min_lat, @min_lon, @max_lat, @max_lon, :include => :map_bug_comment, :order => "last_changed DESC", :limit => limit, :conditions => conditions)
+ @bugs = MapBug.find_by_area_no_quadtile(@min_lat, @min_lon, @max_lat, @max_lon, :include => :comments, :order => "last_changed DESC", :limit => limit, :conditions => conditions)
respond_to do |format|
format.html {render :template => 'map_bugs/get_bugs.js', :content_type => "text/javascript"}
format.rss {render :template => 'map_bugs/get_bugs.rss'}
format.js
format.xml {render :template => 'map_bugs/get_bugs.xml'}
- format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :map_bug_comment => { :only => [:commenter_name, :date_created, :comment]}}) }
+ format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :comments => { :only => [:commenter_name, :date_created, :comment]}}) }
format.gpx {render :template => 'map_bugs/get_bugs.gpx'}
end
end
respond_to do |format|
format.rss
format.xml
- format.json { render :json => @bug.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :map_bug_comment => { :only => [:commenter_name, :date_created, :comment]}}) }
+ format.json { render :json => @bug.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :comments => { :only => [:commenter_name, :date_created, :comment]}}) }
format.gpx
end
end
#TODO: There should be a better way to do this. CloseConditions are ignored at the moment
- bugs2 = MapBug.find(:all, :limit => limit, :order => "last_changed DESC", :joins => :map_bug_comment, :include => :map_bug_comment,
+ bugs2 = MapBug.find(:all, :limit => limit, :order => "last_changed DESC", :joins => :comments, :include => :comments,
:conditions => conditions)
@bugs = bugs2.uniq
respond_to do |format|
format.rss {render :template => 'map_bugs/get_bugs.rss'}
format.js
format.xml {render :template => 'map_bugs/get_bugs.xml'}
- format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :map_bug_comment => { :only => [:commenter_name, :date_created, :comment]}}) }
+ format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :comments => { :only => [:commenter_name, :date_created, :comment]}}) }
format.gpx {render :template => 'map_bugs/get_bugs.gpx'}
end
end
@page_size = 10
@bugs = MapBug.find(:all,
- :include => [:map_bug_comment, {:map_bug_comment => :user}],
- :joins => :map_bug_comment,
+ :include => [:comments, {:comments => :user}],
+ :joins => :comments,
:order => "last_changed DESC",
:conditions => conditions,
:offset => (@page - 1) * @page_size,
def add_comment(bug, comment, name,event)
t = Time.now.getutc
- bug_comment = bug.map_bug_comment.create(:date_created => t, :visible => true, :event => event)
+ bug_comment = bug.comments.create(:date_created => t, :visible => true, :event => event)
bug_comment.comment = comment unless comment == :nil
if @user
bug_comment.commenter_id = @user.id
bug.save
sent_to = Set.new
- bug.map_bug_comment.each do | cmt |
+ bug.comments.each do | cmt |
if cmt.user
unless sent_to.include?(cmt.user)
Notifier.deliver_bug_comment_notification(bug_comment, cmt.user) unless cmt.user == @user
class MapBug < ActiveRecord::Base
include GeoRecord
- has_many :map_bug_comment, :foreign_key => :bug_id, :order => :date_created, :conditions => "visible = true and comment is not null"
+ has_many :comments, :class_name => "MapBugComment",
+ :foreign_key => :bug_id,
+ :order => :date_created,
+ :conditions => "visible = true and comment is not null"
validates_presence_of :id, :on => :update
validates_uniqueness_of :id
def flatten_comment(separator_char, upto_timestamp = :nil)
resp = ""
comment_no = 1
- self.map_bug_comment.each do |comment|
+ self.comments.each do |comment|
next if upto_timestamp != :nil and comment.date_created > upto_timestamp
resp += (comment_no == 1 ? "" : separator_char)
resp += comment.comment if comment.comment
def bug_comment_notification(bug_comment, recipient)
common_headers recipient
- commenter_name = bug_comment.user.display_name if bug_comment.user
- commenter_name = bug_comment.commenter_name unless bug_comment.user
- owner = (recipient == bug_comment.map_bug.map_bug_comment[0].user);
- subject I18n.t('notifier.map_bug_plain.subject_own', :commenter => commenter_name) if owner
- subject I18n.t('notifier.map_bug_plain.subject_other', :commenter => commenter_name) unless owner
+ owner = (recipient == bug_comment.map_bug.comments.first.user);
+ subject I18n.t('notifier.map_bug_plain.subject_own', :commenter => bug_comment.commenter_name) if owner
+ subject I18n.t('notifier.map_bug_plain.subject_other', :commenter => bug_comment.commenter_name) unless owner
body :bugurl => url_for(:host => SERVER_URL,
:controller => "browse",
:place => bug_comment.map_bug.nearby_place,
:comment => bug_comment.comment,
:owner => owner,
- :commenter => commenter_name
+ :commenter => bug_comment.commenter_name
end
private
<tr>
<td width="100%">
<h2>
- <% if @bug.status == "closed" %>
- <%= image_tag("closed_bug_marker.png", :alt => 'closed') %>
- <%= t'browse.bug.closed_title', :bug_name => @bug.id %>
- <% else %>
- <%= image_tag("open_bug_marker.png", :alt => 'open') %>
- <%= t'browse.bug.open_title', :bug_name => @bug.id %>
- <% end %>
- </h2>
+ <% if @bug.status == "closed" %>
+ <%= image_tag("closed_bug_marker.png", :alt => 'closed') %>
+ <%= t 'browse.bug.closed_title', :bug_name => @bug.id %>
+ <% else %>
+ <%= image_tag("open_bug_marker.png", :alt => 'open') %>
+ <%= t 'browse.bug.open_title', :bug_name => @bug.id %>
+ <% end %>
+ </h2>
</td>
<td>
<%= render :partial => "navigation" %>
</tr>
<tr valign="top">
<td>
- <table>
- <tr>
- <th><%= t 'browse.bug.created_at' %></th>
- <td><%= l @bug.date_created %></td>
- </tr>
-
- <tr>
- <th><%= t 'browse.bug.edited_at' %></th>
- <td><%= l @bug.last_changed %></td>
- </tr>
- <% if @bug.status == "closed" %>
- <tr>
- <th><%= t 'browse.bug.closed_at' %></th>
- <td><%= l @bug.date_closed %></td>
- </tr>
- <% end %>
- <tr>
- <th><%= t 'browse.bug.opened_by' %></th>
- <% if @bug.map_bug_comment[0].user.nil? %>
- <td> <%= @bug.map_bug_comment[0].commenter_name %> </td>
- <% else %>
- <td><%= link_to h(@bug.map_bug_comment[0].user.display_name), :controller => "user", :action => "view", :display_name => @bug.map_bug_comment[0].user.display_name %></td>
- <% end %>
- </tr>
- <tr>
- <th><%= t 'browse.bug.description' %></th>
- <td><%= h(@bug.map_bug_comment[0].comment) %></td>
- </tr>
+ <table>
+ <tr>
+ <th><%= t 'browse.bug.created_at' %></th>
+ <td><%= l @bug.date_created %></td>
+ </tr>
+ <tr>
+ <th><%= t 'browse.bug.edited_at' %></th>
+ <td><%= l @bug.last_changed %></td>
+ </tr>
+ <% if @bug.status == "closed" %>
+ <tr>
+ <th><%= t 'browse.bug.closed_at' %></th>
+ <td><%= l @bug.date_closed %></td>
+ </tr>
+ <% end %>
+ <tr>
+ <th><%= t 'browse.bug.opened_by' %></th>
+ <% if @bug.comments.first.user.nil? %>
+ <td> <%= @bug.comments.first.commenter_name %> </td>
+ <% else %>
+ <td><%= link_to h(@bug.comments.first.user.display_name), :controller => "user", :action => "view", :display_name => @bug.comments.first.user.display_name %></td>
+ <% end %>
+ </tr>
+ <tr>
+ <th><%= t 'browse.bug.description' %></th>
+ <td><%= h(@bug.comments.first.comment) %></td>
+ </tr>
+ <tr>
+ <th><%= t 'browse.node_details.coordinates' %></th>
+ <td><div class="geo"><%= link_to ("<span class='latitude'>#{number_with_delimiter(@bug.lat)}</span>, <span class='longitude'>#{number_with_delimiter(@bug.lon)}</span>"), {:controller => 'site', :action => 'index', :lat => h(@bug.lat), :lon => h(@bug.lon), :zoom => "18"} %></div></td>
+ </tr>
+ </table>
- <tr>
- <th><%= t 'browse.node_details.coordinates' %></th>
- <td><div class="geo"><%= link_to ("<span class='latitude'>#{number_with_delimiter(@bug.lat)}</span>, <span class='longitude'>#{number_with_delimiter(@bug.lon)}</span>"), {:controller => 'site', :action => 'index', :lat => h(@bug.lat), :lon => h(@bug.lon), :zoom => "18"} %></div></td>
- </tr>
+ <br />
- </table>
-
- <br>
-
- <%if @bug.map_bug_comment.length > 1 %>
-
- <table>
- <tr>
- <th width="20%"> <%= t 'browse.bug.comment_by' %></th> <th width="60%"> <%= t 'browse.bug.comment' %></th> <th width="20%"> <%= t 'browse.bug.date' %></th>
- </tr>
- <% @bug.map_bug_comment[1..-1].each do |bug_comment| %>
- <tr>
-
- <td>
- <% if bug_comment.user.nil? %>
- <%= bug_comment.commenter_name %>
- <% else %>
- <%= link_to h(bug_comment.user.display_name), :controller => "user", :action => "view", :display_name => bug_comment.user.display_name %>
- <% end %>
- </td>
- <td> <%= h(bug_comment.comment) %> </td>
- <td> <%= l bug_comment.date_created %> </td>
- </tr>
- <% end %>
- </table>
-
- <% end %>
+ <% if @bug.comments.length > 1 %>
+ <table>
+ <tr>
+ <th width="20%"> <%= t 'browse.bug.comment_by' %></th>
+ <th width="60%"> <%= t 'browse.bug.comment' %></th>
+ <th width="20%"> <%= t 'browse.bug.date' %></th>
+ </tr>
+ <% @bug.comments[1..-1].each do |bug_comment| %>
+ <tr>
+ <td>
+ <% if bug_comment.user.nil? %>
+ <%= bug_comment.commenter_name %>
+ <% else %>
+ <%= link_to h(bug_comment.user.display_name), :controller => "user", :action => "view", :display_name => bug_comment.user.display_name %>
+ <% end %>
+ </td>
+ <td> <%= h(bug_comment.comment) %> </td>
+ <td> <%= l bug_comment.date_created %> </td>
+ </tr>
+ <% end %>
+ </table>
+ <% end %>
- <hr />
-
+ <hr />
</td>
+
<%= render :partial => "map", :object => @bug %>
</tr>
-</table>
\ No newline at end of file
+</table>
xml.item do
if bug.status == "closed"
xml.title t('bugs.rss.closed', :place => bug.nearby_place)
- elsif bug.map_bug_comment.length > 1
+ elsif bug.comments.length > 1
xml.title t('bugs.rss.comment', :place => bug.nearby_place)
else
xml.title t('bugs.rss.new', :place => bug.nearby_place)
xml.guid url_for(:controller => "map_bugs", :action => "read", :id => bug.id, :only_path => false)
xml.description htmlize(bug.flatten_comment("<br><br>"))
- unless bug.map_bug_comment.empty?
- xml.author bug.map_bug_comment[-1].commenter_name
+ unless bug.comments.empty?
+ xml.author bug.comments[-1].commenter_name
end
xml.pubDate bug.last_changed.to_s(:rfc822)
end
xml.comments do
- bug.map_bug_comment.each do |comment|
+ bug.comments.each do |comment|
xml.comment do
xml.date comment.date_created
xml.uid comment.commenter_id unless comment.commenter_id.nil?
<%= render :partial => 'bugs_paging_nav' %>
<table id="bug_list" cellpadding="3">
- <tr>
- <th></th>
- <th><%= t'bugs.user.id' %></th>
- <th><%= t'changeset.changesets.user' %></th>
- <th><%= t'changeset.changesets.comment' %></th>
- <th><%= t'changeset.changesets.saved_at' %></th>
- <th><%= t'bugs.user.last_changed' %></th>
-
-
- </tr>
+ <tr>
+ <th></th>
+ <th><%= t'bugs.user.id' %></th>
+ <th><%= t'changeset.changesets.user' %></th>
+ <th><%= t'changeset.changesets.comment' %></th>
+ <th><%= t'changeset.changesets.saved_at' %></th>
+ <th><%= t'bugs.user.last_changed' %></th>
+ </tr>
<% @bugs.each do |bug| %>
-<% if bug.map_bug_comment[0].user == @user2 %>
- <tr>
-<% else %>
- <tr bgcolor=#EEEEEE>
-<% end %>
- <td>
- <% if bug.status == "closed" %>
- <%= image_tag("closed_bug_marker.png", :alt => 'closed') %>
- <% else %>
- <%= image_tag("open_bug_marker.png", :alt => 'open') %>
- <% end %>
- </td>
- <td><%= link_to bug.id.to_s, :controller => "browse", :action => "bug", :id => bug.id %></td>
-
- <% if bug.map_bug_comment[0].user.nil? %>
- <td> <%= bug.map_bug_comment[0].commenter_name %> </td>
- <% else %>
- <td><%= link_to h(bug.map_bug_comment[0].user.display_name), :controller => "user", :action => "view", :display_name => bug.map_bug_comment[0].user.display_name %></td>
- <% end %>
- <td> <%= htmlize bug.map_bug_comment[0].comment %> </td>
- <td><%= l bug.date_created %></td>
- <td><%= l bug.last_changed %></td>
- </tr>
+ <tr<% if bug.comments[0].user != @user2 %> bgcolor="#EEEEEE"<% end %>>
+ <td>
+ <% if bug.status == "closed" %>
+ <%= image_tag("closed_bug_marker.png", :alt => 'closed') %>
+ <% else %>
+ <%= image_tag("open_bug_marker.png", :alt => 'open') %>
+ <% end %>
+ </td>
+ <td><%= link_to bug.id.to_s, :controller => "browse", :action => "bug", :id => bug.id %></td>
+ <% if bug.comments[0].user.nil? %>
+ <td> <%= bug.comments[0].commenter_name %> </td>
+ <% else %>
+ <td><%= link_to h(bug.comments[0].user.display_name), :controller => "user", :action => "view", :display_name => bug.comments[0].user.display_name %></td>
+ <% end %>
+ <td> <%= htmlize bug.comments[0].comment %> </td>
+ <td><%= l bug.date_created %></td>
+ <td><%= l bug.last_changed %></td>
+ </tr>
<% end %>
</table>
-
<%= render :partial => 'bugs_paging_nav' %>