From a337ee850ef0bb3361d86ea05365d14c4a39b5c4 Mon Sep 17 00:00:00 2001 From: joshua stein Date: Sat, 17 Oct 2015 10:38:48 -0500 Subject: [PATCH] take suggestions on moderator stories, just not those with privileged tags also allow moderators to make tag suggestions, we're people too --- app/models/story.rb | 18 +++++++++++------- app/views/stories/_listdetail.html.erb | 3 ++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/models/story.rb b/app/models/story.rb index 65b93d0..d23e4c8 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -209,15 +209,19 @@ class Story < ActiveRecord::Base end def can_have_suggestions_from_user?(user) - if user - if self.user.is_moderator? - return false - end - - return true - else + if !user return false end + + if user.id == self.user_id + return false + end + + if self.tags.select{|t| t.privileged? }.any? + return false + end + + return true end # this has to happen just before save rather than in tags_a= because we need diff --git a/app/views/stories/_listdetail.html.erb b/app/views/stories/_listdetail.html.erb index d5ca639..36cba6b 100644 --- a/app/views/stories/_listdetail.html.erb +++ b/app/views/stories/_listdetail.html.erb @@ -127,7 +127,8 @@ class="story <%= story.vote && story.vote[:vote] == 1 ? "upvoted" : "" %> :confirm => "Are you sure you want to delete this story?" } %> <% end %> <% end %> - <% elsif story.can_have_suggestions_from_user?(@user) %> + <% end %> + <% if story.can_have_suggestions_from_user?(@user) %> | <%= link_to "suggest", story_suggest_path(story.short_id), :class => "suggester" %> <% end %>