diff --git a/app/helpers/flags_helper.rb b/app/helpers/flags_helper.rb
new file mode 100644
index 000000000..3a8bfbc75
--- /dev/null
+++ b/app/helpers/flags_helper.rb
@@ -0,0 +1,23 @@
+module FlagsHelper
+ def show_flag_action?(flaggable)
+ current_user && !own_flaggable?(flaggable) && !flagged?(flaggable)
+ end
+
+ def show_unflag_action?(flaggable)
+ current_user && !own_flaggable?(flaggable) && flagged?(flaggable)
+ end
+
+ private
+
+ def flagged?(flaggable)
+ Flag.flagged?(current_user, flaggable)
+ end
+
+ def own_flaggable?(flaggable)
+ if flaggable.is_a? Comment
+ flaggable.user_id == current_user.id
+ else
+ flaggable.author_id == current_user.id
+ end
+ end
+end
diff --git a/app/views/comments/_flag_actions.html.erb b/app/views/comments/_flag_actions.html.erb
index f1557668c..c056204e7 100644
--- a/app/views/comments/_flag_actions.html.erb
+++ b/app/views/comments/_flag_actions.html.erb
@@ -1,4 +1,4 @@
-<% if can? :flag, comment %>
+<% if show_flag_action? comment %>
|
@@ -10,7 +10,7 @@
<% end %>
-<% if can? :unflag, comment %>
+<% if show_unflag_action? comment %>
|
diff --git a/app/views/debates/_flag_actions.html.erb b/app/views/debates/_flag_actions.html.erb
index 07fff9329..20f147df9 100644
--- a/app/views/debates/_flag_actions.html.erb
+++ b/app/views/debates/_flag_actions.html.erb
@@ -1,4 +1,4 @@
-<% if can? :flag, debate %>
+<% if show_flag_action? debate %>
@@ -9,7 +9,7 @@
<% end %>
-<% if can? :unflag, debate %>
+<% if show_unflag_action? debate %>