if a user has had a story moderated in the past 5 days, show guidelines
This commit is contained in:
parent
7f2c98860d
commit
af24e4e388
19
app/helpers/stories_helper.rb
Normal file
19
app/helpers/stories_helper.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
module StoriesHelper
|
||||
def show_guidelines?
|
||||
if !@user
|
||||
return true
|
||||
end
|
||||
|
||||
if @user.stories_submitted_count <= 5
|
||||
return true
|
||||
end
|
||||
|
||||
if Moderation.joins(:story).
|
||||
where("stories.user_id = ? AND moderations.created_at > ?", @user.id,
|
||||
5.days.ago).count > 0
|
||||
return true
|
||||
end
|
||||
|
||||
false
|
||||
end
|
||||
end
|
|
@ -68,15 +68,15 @@
|
|||
<a href="#" id="story_guidelines_toggler">
|
||||
Story submission guidelines
|
||||
</a>
|
||||
<div id="story_guidelines" style="<%= @user &&
|
||||
@user.stories_submitted_count > 5 ? "display: none;" : "" %>">
|
||||
<div style="float: right;">
|
||||
<a href="javascript:window.location=%22<%= root_url %>stories/new?url=%22+encodeURIComponent(document.location)+%22&title=%22+encodeURIComponent(document.title)"
|
||||
style="border: 1px solid #ddd; padding: 0.5em; background-color:
|
||||
#f8f8f8; line-height: 1.5em; margin-left: 1em;">Submit to
|
||||
<%= Rails.application.name %></a>
|
||||
</div>
|
||||
<ul>
|
||||
<div id="story_guidelines" style="<%= show_guidelines?? "" :
|
||||
"display: none;" %>">
|
||||
<div style="float: right;">
|
||||
<a href="javascript:window.location=%22<%= root_url %>stories/new?url=%22+encodeURIComponent(document.location)+%22&title=%22+encodeURIComponent(document.title)"
|
||||
style="border: 1px solid #ddd; padding: 0.5em; background-color:
|
||||
#f8f8f8; line-height: 1.5em; margin-left: 1em;">Submit to
|
||||
<%= Rails.application.name %></a>
|
||||
</div>
|
||||
<ul>
|
||||
|
||||
<li><p>
|
||||
To be able to easily submit a page you're viewing in your browser
|
||||
|
|
Loading…
Reference in a new issue