aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/info_request.rb15
-rw-r--r--app/models/info_request_event.rb8
-rw-r--r--app/models/user.rb3
3 files changed, 19 insertions, 7 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb
index aa9b49c83..dfa66102e 100644
--- a/app/models/info_request.rb
+++ b/app/models/info_request.rb
@@ -24,7 +24,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.197 2009-06-30 14:28:26 francis Exp $
+# $Id: info_request.rb,v 1.198 2009-07-03 11:43:37 francis Exp $
require 'digest/sha1'
require File.join(File.dirname(__FILE__),'../../vendor/plugins/acts_as_xapian/lib/acts_as_xapian')
@@ -68,7 +68,8 @@ class InfoRequest < ActiveRecord::Base
validates_inclusion_of :prominence, :in => [
'normal',
'backpage',
- 'hidden'
+ 'hidden',
+ 'requester_only'
]
validates_inclusion_of :law_used, :in => [
@@ -822,6 +823,16 @@ public
if self.prominence == 'hidden'
return User.view_hidden_requests?(user)
end
+ if self.prominence == 'requester_only'
+ return self.is_owning_user?(user)
+ end
+ return true
+ end
+
+ def indexed_by_search?
+ if self.prominence == 'backpage' || self.prominence == 'hidden' || self.prominence == 'requester_only'
+ return false
+ end
return true
end
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb
index 53f6d5f90..76f50c8d5 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.84 2009-06-26 14:28:38 francis Exp $
+# $Id: info_request_event.rb,v 1.85 2009-07-03 11:43:37 francis Exp $
class InfoRequestEvent < ActiveRecord::Base
belongs_to :info_request
@@ -84,7 +84,7 @@ class InfoRequestEvent < ActiveRecord::Base
[ :variety, 'V', "variety" ],
[ :filetype, 'T', "filetype" ]
],
- :if => :indexed_by_search,
+ :if => :indexed_by_search?,
:eager_load => [ :incoming_message, :outgoing_message, :comment, { :info_request => [ :user, :public_body, :censor_rules ] } ]
def requested_by
@@ -152,9 +152,9 @@ class InfoRequestEvent < ActiveRecord::Base
end
return ''
end
- def indexed_by_search
+ def indexed_by_search?
if ['sent', 'followup_sent', 'response', 'comment'].include?(self.event_type)
- if self.info_request.prominence == 'backpage' || self.info_request.prominence == 'hidden'
+ if !self.info_request.indexed_by_search?
return false
end
if self.event_type == 'comment' && !self.comment.visible
diff --git a/app/models/user.rb b/app/models/user.rb
index 03a076c24..4853d633c 100644
--- a/app/models/user.rb
+++ b/app/models/user.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: user.rb,v 1.96 2009-06-30 14:28:26 francis Exp $
+# $Id: user.rb,v 1.97 2009-07-03 11:43:37 francis Exp $
require 'digest/sha1'
@@ -220,6 +220,7 @@ class User < ActiveRecord::Base
!user.nil? && user.owns_every_request?
end
+ # Can the user see every request, even hidden ones?
def self.view_hidden_requests?(user)
!user.nil? && user.admin_level == 'super'
end