Skip to content

Commit

Permalink
added delete link to message posts in admin bar
Browse files Browse the repository at this point in the history
  • Loading branch information
jlapier committed Apr 13, 2012
1 parent 1434437 commit 3d7f681
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def require_forum_read_access

def require_forum_write_access
if require_user
unless current_user.has_write_access_to?(@forum)
unless current_user.is_admin? or current_user.has_write_access_to?(@forum)
flash[:notice] = "You do not have post or edit in that forum."
redirect_to forums_url
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/message_posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def destroy
@message_post.destroy

respond_to do |format|
flash[:notice] = "Post '#{@message_post.subject}' deleted."
format.html { redirect_to(@forum) }
format.xml { head :ok }
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/message_post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class MessagePost < ActiveRecord::Base
belongs_to :user
belongs_to :thread, :class_name => 'MessagePost', :foreign_key => 'thread_id', :include => :user

has_many :child_posts, :class_name => 'MessagePost', :foreign_key => 'thread_id', :include => :user
has_many :child_posts, :class_name => 'MessagePost', :foreign_key => 'thread_id', :include => :user, :dependent => :destroy

validates_presence_of :subject, :body, :user_id

Expand Down
10 changes: 4 additions & 6 deletions app/views/forums/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<% if is_admin? %>
<div style="float:right" class="small_text">
<%= link_to 'edit details of this forum', edit_forum_path(@forum) %> |
<%= link_to 'delete this forum', @forum, :method => :delete,
<% content_for :admin_bar do %>
<%= link_to 'edit details of this forum', edit_forum_path(@forum) %> |
<%= link_to 'delete this forum', @forum, :method => :delete,
:confirm => 'Are you sure you want to delete this forum and all the messages in it?' %>
</div>
<% end %>

<h1><%= link_to "Forums", forums_path %>: <%= @forum.title %></h1>
Expand Down Expand Up @@ -47,5 +45,5 @@
<% end -%>

<p class="small_text">
Go to <a href="http://en.gravatar.com/">gravatar.com</a> to upload picture for your signetwork account. By doing so your photo will appear next to your discussion posts.
Go to <a href="http://en.gravatar.com/">gravatar.com</a> to upload picture for your account. By doing so your photo will appear next to your discussion posts.
</p>
9 changes: 8 additions & 1 deletion app/views/message_posts/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@


<p class="small_text">
Go to <a href="http://en.gravatar.com/">gravatar.com</a> to upload picture for your signetwork account. By doing so your photo will appear next to your discussion posts.
Go to <a href="http://en.gravatar.com/">gravatar.com</a> to upload picture for your account. By doing so your photo will appear next to your discussion posts.
</p>



<% content_for :admin_bar do %>
<%= link_to 'delete this message thread', forum_message_post_path(@forum, @message_post), :method => :delete,
:confirm => 'Are you sure you want to delete this thread and all the messages in it?' %>
<% end %>

0 comments on commit 3d7f681

Please sign in to comment.