Skip to content

Instantly share code, notes, and snippets.

@capoferro
Created October 20, 2010 18:45
Show Gist options
  • Save capoferro/637041 to your computer and use it in GitHub Desktop.
Save capoferro/637041 to your computer and use it in GitHub Desktop.
module InstanceMethods
def can_moderate_community?
self.community_admin? or self.community_moderator?
end
end
<div class="module">
<div class="module_header">Posts [<%= @topic.posts.size %>]</div>
<div>
<table>
<% @topic.posts.each do |post| %>
<tr>
<td class="post_author" rowspan="2">
<span class="name"><%= post.user.username %></span>
<span class="avatar"><%= image_tag post.user.try(:community_avatar) %></span>
<span class="info smaller">
Posts <%= post.user.posts.size %><br />
Registered <%= post.user.created_at.to_s(:joined) %><br />
</span>
</td>
<td class="post_header">
<span class="left post_date smaller">Posted <%= post.created_at %></span>
<span class="right post_controls smaller">
<% if logged_in? %>
<%= link_to "Reply", new_topic_post_path(@topic) %>
<%= link_to "Quote", new_topic_post_path(@topic, :quote => post) %>
<% if current_user == post.user || current_user.can_moderate_community? %>
<%= link_to "Edit", edit_topic_post_path(@topic, post) %>
<%= link_to "Delete", topic_post_path(@topic, post), :confirm => "Are you sure?", :method => :delete %>
<% end %>
<% if current_user.can_moderate_community? %>
<%= link_to @topic.sticky ? "Unstick" : "Sticky", {:controller => 'community/topics', :action => 'update', :topic => {:sticky => @topic.sticky ? "false" : "true" }}, :method => :put %>
<%= link_to @topic.locked ? "Unlock" : "Lock", {:controller => 'community/topics', :action => 'update', :topic => {:locked => @topic.locked ? "false" : "true" }}, :method => :put %>
<% end %>
<% end %>
</span>
</td>
</tr>
<tr>
<td class="post_body">
<%=raw post.body %>
</td>
</tr>
<% end %>
</table>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment