aboutsummaryrefslogtreecommitdiffstats
path: root/lib/message_prominence.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-09-17 17:39:51 +0100
committerLouise Crow <louise.crow@gmail.com>2013-09-17 17:39:51 +0100
commit6fbcb461025dc315d688038d9f0a8e138d00ba33 (patch)
tree628ad3d7bf9cb2310bc2bed2e94b8670532a0dd4 /lib/message_prominence.rb
parentabde5e4a1139c41c6db23ce041fba090674f65ac (diff)
parentf41ec6d1cb167058a808b7820da5345c6da962fd (diff)
Merge branch 'feature/hide-individual-responses' into rails-3-develop
Conflicts: Gemfile app/views/admin_request/edit_outgoing.html.erb config/packages doc/CHANGES.md doc/INSTALL.md spec/models/info_request_spec.rb spec/models/public_body_spec.rb
Diffstat (limited to 'lib/message_prominence.rb')
-rw-r--r--lib/message_prominence.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/message_prominence.rb b/lib/message_prominence.rb
new file mode 100644
index 000000000..8f54fcc95
--- /dev/null
+++ b/lib/message_prominence.rb
@@ -0,0 +1,26 @@
+module MessageProminence
+
+ def has_prominence
+ send :include, InstanceMethods
+ cattr_accessor :prominence_states
+ self.prominence_states = ['normal', 'hidden','requester_only']
+ validates_inclusion_of :prominence, :in => self.prominence_states
+ end
+
+ module InstanceMethods
+
+ def user_can_view?(user)
+ Ability.can_view_with_prominence?(self.prominence, self.info_request, user)
+ end
+
+ def indexed_by_search?
+ self.prominence == 'normal'
+ end
+
+ def all_can_view?
+ self.prominence == 'normal'
+ end
+
+ end
+end
+