aboutsummaryrefslogtreecommitdiffstats
path: root/lib/message_prominence.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-09-24 09:23:44 +0100
committerLouise Crow <louise.crow@gmail.com>2013-09-24 09:23:44 +0100
commit7d9b66d1ff31afa8d73ea1a81f4e612e41f89cb0 (patch)
tree5206d9fbaf8d6af58bdaa35cefdfeb34a88c84ff /lib/message_prominence.rb
parent40a28fa2fe21d752a15c11938791d620dd31d17f (diff)
parent8e7432be764254e6a50e6a06e77bb93bb5bba9fe (diff)
Merge branch 'release/0.14' into wdtk
Conflicts: app/views/request/show.html.erb
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
+