ability to delete messages
This commit is contained in:
parent
4b3c207a81
commit
ee6165bf9b
4 changed files with 16 additions and 0 deletions
|
@ -20,6 +20,18 @@ class MessageController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
|
||||||
|
if !@message.message_read
|
||||||
|
flash[:notice] = 'Message not read and so not deleted'
|
||||||
|
redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
|
||||||
|
else
|
||||||
|
flash[:notice] = "Message '#{@message.title}' deleted"
|
||||||
|
@message.destroy
|
||||||
|
redirect_to :controller => 'message', :action => 'inbox', :display_name => @user.display_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def reply
|
def reply
|
||||||
message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
|
message = Message.find(params[:message_id], :conditions => ["to_user_id = ? or from_user_id = ?", @user.id, @user.id ])
|
||||||
title = message.title.sub(/^Re:\s*/, "Re: ")
|
title = message.title.sub(/^Re:\s*/, "Re: ")
|
||||||
|
|
|
@ -10,4 +10,6 @@
|
||||||
<td><%= button_to 'Mark as read', :controller => 'message', :action => 'mark', :message_id => message_summary.id, :mark => 'read' %></td>
|
<td><%= button_to 'Mark as read', :controller => 'message', :action => 'mark', :message_id => message_summary.id, :mark => 'read' %></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<td><%= button_to 'Reply', :controller => 'message', :action => 'reply', :message_id => message_summary.id %></td>
|
<td><%= button_to 'Reply', :controller => 'message', :action => 'reply', :message_id => message_summary.id %></td>
|
||||||
|
<td><%= button_to 'Delete', :controller => 'message', :action => 'destroy', :message_id => message_summary.id %></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= button_to 'Reply', :controller => 'message', :action => 'reply', :message_id => @message.id %></td>
|
<td><%= button_to 'Reply', :controller => 'message', :action => 'reply', :message_id => @message.id %></td>
|
||||||
<td><%= button_to 'Mark as unread', :controller => 'message', :action => 'mark', :message_id => @message.id, :mark => 'unread' %></td>
|
<td><%= button_to 'Mark as unread', :controller => 'message', :action => 'mark', :message_id => @message.id, :mark => 'unread' %></td>
|
||||||
|
<td><%= button_to 'Delete', :controller => 'message', :action => 'destroy', :message_id => @message.id %></td>
|
||||||
<td><%= link_to 'Back to inbox', :controller => 'message', :action => 'inbox', :display_name => @user.display_name %></td>
|
<td><%= link_to 'Back to inbox', :controller => 'message', :action => 'inbox', :display_name => @user.display_name %></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -143,6 +143,7 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
map.connect '/message/read/:message_id', :controller => 'message', :action => 'read'
|
map.connect '/message/read/:message_id', :controller => 'message', :action => 'read'
|
||||||
map.connect '/message/mark/:message_id', :controller => 'message', :action => 'mark'
|
map.connect '/message/mark/:message_id', :controller => 'message', :action => 'mark'
|
||||||
map.connect '/message/reply/:message_id', :controller => 'message', :action => 'reply'
|
map.connect '/message/reply/:message_id', :controller => 'message', :action => 'reply'
|
||||||
|
map.connect '/message/delete/:message_id', :controller => 'message', :action => 'destroy'
|
||||||
|
|
||||||
# fall through
|
# fall through
|
||||||
map.connect ':controller/:id/:action'
|
map.connect ':controller/:id/:action'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue