add mark all dmail as read option

This commit is contained in:
albert
2013-02-20 22:52:42 -05:00
parent 13ebfeacb6
commit 65b45e46c2
4 changed files with 9 additions and 0 deletions

View File

@@ -41,6 +41,12 @@ class DmailsController < ApplicationController
redirect_to dmails_path, :notice => "Message destroyed"
end
def mark_all_as_read
Dmail.visible.unread.each do |x|
x.update_column(:is_read, true)
end
end
private
def check_privilege(dmail)
if !dmail.visible_to?(CurrentUser.user)

View File

@@ -4,5 +4,6 @@
<li><%= link_to "Sent", dmails_path(:search => {:owner_id => CurrentUser.id, :from_id => CurrentUser.id}, :folder => "sent") %></li>
<li><%= link_to "New", new_dmail_path %></li>
<li><%= link_to "Search", search_dmails_path %></li>
<li><%= link_to "Mark all as read", {:controller => "dmails", :action => "mark_all_as_read"}, :method => :post, :remote => true %></li>
</menu>
<% end %>

View File

@@ -0,0 +1 @@
location.reload();

View File

@@ -72,6 +72,7 @@ Danbooru::Application.routes.draw do
resources :dmails do
collection do
get :search
post :mark_all_as_read
end
end
resource :dtext_preview, :only => [:create]