aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin_request_controller.rb8
-rw-r--r--app/models/comment.rb10
-rw-r--r--app/models/info_request.rb6
-rw-r--r--app/models/info_request_event.rb14
-rw-r--r--app/models/user.rb6
-rw-r--r--app/views/admin_request/edit_comment.rhtml5
-rw-r--r--app/views/admin_request/show.rhtml8
-rw-r--r--app/views/request/show.rhtml4
-rw-r--r--app/views/user/_user_listing_single.rhtml2
-rw-r--r--app/views/user/show.rhtml4
10 files changed, 54 insertions, 13 deletions
diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb
index 446b5263c..70db7cd8a 100644
--- a/app/controllers/admin_request_controller.rb
+++ b/app/controllers/admin_request_controller.rb
@@ -4,7 +4,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: admin_request_controller.rb,v 1.23 2008-09-24 19:43:21 francis Exp $
+# $Id: admin_request_controller.rb,v 1.24 2008-10-02 23:11:40 francis Exp $
class AdminRequestController < ApplicationController
layout "admin"
@@ -110,11 +110,15 @@ class AdminRequestController < ApplicationController
@comment = Comment.find(params[:id])
old_body = @comment.body
+ old_visible = @comment.visible
+ @comment.visible = params[:comment][:visible] == "true" ? true : false
if @comment.update_attributes(params[:comment])
@comment.info_request.log_event("edit_comment",
{ :comment_if => @comment.id, :editor => admin_http_auth_user(),
- :old_body => old_body, :body => @comment.body })
+ :old_body => old_body, :body => @comment.body,
+ :old_visible => old_visible, :visible => @comment.visible,
+ })
flash[:notice] = 'Comment successfully updated.'
redirect_to request_admin_url(@comment.info_request)
else
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 967108171..e4b995f32 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -19,7 +19,7 @@
# Copyright (c) 2008 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: comment.rb,v 1.6 2008-09-22 22:16:37 francis Exp $
+# $Id: comment.rb,v 1.7 2008-10-02 23:11:40 francis Exp $
class Comment < ActiveRecord::Base
belongs_to :user
@@ -43,6 +43,14 @@ class Comment < ActiveRecord::Base
read_attribute(:body)
end
+ # So when made invisble it vanishes
+ after_save :event_xapian_update
+ def event_xapian_update
+ for event in self.info_request_events
+ event.xapian_mark_needs_index
+ end
+ end
+
# Check have edited comment
def validate
if self.body.empty? || self.body =~ /^\s+$/
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index 43d566199..e9f76f445 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -23,7 +23,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: info_request.rb,v 1.143 2008-09-23 00:47:50 francis Exp $
+# $Id: info_request.rb,v 1.144 2008-10-02 23:11:40 francis Exp $
require 'digest/sha1'
require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian')
@@ -76,6 +76,10 @@ class InfoRequest < ActiveRecord::Base
end
end
+ def visible_comments
+ self.comments.find(:all, :conditions => 'visible')
+ end
+
# Central function to do all searches
# (Not really the right place to put it, but everything can get it here, and it
# does *mainly* find info requests, via their events, so hey)
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 7b32954d3..0b6e126a9 100644
--- a/app/models/info_request_event.rb
+++ b/app/models/info_request_event.rb
@@ -21,7 +21,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: info_request_event.rb,v 1.61 2008-09-23 21:00:14 francis Exp $
+# $Id: info_request_event.rb,v 1.62 2008-10-02 23:11:40 francis Exp $
class InfoRequestEvent < ActiveRecord::Base
belongs_to :info_request
@@ -149,7 +149,10 @@ class InfoRequestEvent < ActiveRecord::Base
end
def indexed_by_search
if ['sent', 'followup_sent', 'response', 'comment'].include?(self.event_type)
- if info_request.prominence == 'backpage'
+ if self.info_request.prominence == 'backpage'
+ return false
+ end
+ if self.event_type == 'comment' && !self.comment.visible
return false
end
return true
@@ -161,6 +164,13 @@ class InfoRequestEvent < ActiveRecord::Base
self.event_type
end
+ def visible
+ if self.event_type == 'comment'
+ return self.comment.visible
+ end
+ return true
+ end
+
# We store YAML version of parameters in the database
def params=(params)
# XXX should really set these explicitly, and stop storing them in
diff --git a/app/models/user.rb b/app/models/user.rb
index ba7e6f72b..072cca50a 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -22,7 +22,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: user.rb,v 1.72 2008-09-24 12:59:27 francis Exp $
+# $Id: user.rb,v 1.73 2008-10-02 23:11:40 francis Exp $
require 'digest/sha1'
@@ -68,6 +68,10 @@ class User < ActiveRecord::Base
end
end
+ def visible_comments
+ self.comments.find(:all, :conditions => 'visible')
+ end
+
def validate
errors.add(:email, "doesn't look like a valid address") unless MySociety::Validate.is_valid_email(self.email)
if MySociety::Validate.is_valid_email(self.name)
diff --git a/app/views/admin_request/edit_comment.rhtml b/app/views/admin_request/edit_comment.rhtml
index d8d7de276..ee43e849a 100644
--- a/app/views/admin_request/edit_comment.rhtml
+++ b/app/views/admin_request/edit_comment.rhtml
@@ -7,6 +7,11 @@
<p><label for="comment_body">Body of annotation</label><br/>
<%= text_area 'comment', 'body', :rows => 10, :cols => 60 %></p>
+ <p><label for="comment_visible">Visible</label>
+ <%= select('comment', "visible", [["Yes - show comment",true],["No - hide comment",false]]) %>
+ </p>
+
+
<p><%= submit_tag 'Save', :accesskey => 's' %></p>
<% end %>
diff --git a/app/views/admin_request/show.rhtml b/app/views/admin_request/show.rhtml
index 54b307cf9..7a5deb7d7 100644
--- a/app/views/admin_request/show.rhtml
+++ b/app/views/admin_request/show.rhtml
@@ -110,12 +110,16 @@
<th>Actions</th>
</tr>
-<% for comment in @info_request.comments.find(:all, :order => 'created_at') %>
+<% for comment in @info_request.comments %>
<tr class="<%= cycle('odd', 'even') %>">
<td><%=h comment.id %></td>
<td><%= user_both_links(comment.user) %></td>
<% for column in Comment.content_columns.map { |c| c.name } %>
- <td><%=h comment.send(column) %></td>
+ <% if column == 'body' && !comment.visible %>
+ <td><s><%=h comment.send(column) %></s></td>
+ <% else %>
+ <td><%=h comment.send(column) %></td>
+ <% end %>
<% end %>
<td>
<%= link_to "Edit", '../edit_comment/' + comment.id.to_s %>
diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml
index b77e3c464..a806434c4 100644
--- a/app/views/request/show.rhtml
+++ b/app/views/request/show.rhtml
@@ -98,7 +98,9 @@
</p>
<% for info_request_event in @info_request_events %>
- <%= render :partial => 'correspondence', :locals => { :info_request_event => info_request_event } %>
+ <% if info_request_event.visible %>
+ <%= render :partial => 'correspondence', :locals => { :info_request_event => info_request_event } %>
+ <% end %>
<% end %>
<% if @info_request.awaiting_description %>
diff --git a/app/views/user/_user_listing_single.rhtml b/app/views/user/_user_listing_single.rhtml
index 1362dc780..cd2328418 100644
--- a/app/views/user/_user_listing_single.rhtml
+++ b/app/views/user/_user_listing_single.rhtml
@@ -8,7 +8,7 @@ end %>
<span class="bottomline">
<%= pluralize(display_user.info_requests.size, "request") %> made.
- <%= pluralize(display_user.comments.size, "annotation") %> made.
+ <%= pluralize(display_user.visible_comments.size, "annotation") %> made.
Joined on <%= simple_date(display_user.created_at) %>.
</span>
diff --git a/app/views/user/show.rhtml b/app/views/user/show.rhtml
index d2966fcfe..7e85faabe 100644
--- a/app/views/user/show.rhtml
+++ b/app/views/user/show.rhtml
@@ -111,7 +111,7 @@
<% else %>
<h2>
<%= @is_you ? 'Your ' : "This person's " %>
- <%=pluralize(@display_user.comments.size, "annotation") %>
+ <%=pluralize(@display_user.visible_comments.size, "annotation") %>
<!-- matches_estimated <%=@xapian_comments.matches_estimated%> -->
<%= @page_desc %>
</h2>
@@ -120,7 +120,7 @@
<%= render :partial => 'request/request_listing_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %>
<% end %>
- <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.comments.size) %>
+ <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @display_user.visible_comments.size) %>
<% end %>
</div>