Merge remote-tracking branch 'upstream/pull/1893'

This commit is contained in:
Tom Hughes 2018-06-06 14:33:36 +01:00
commit 4df0fe72e2
9 changed files with 49 additions and 61 deletions

View file

@ -26,7 +26,7 @@ class MessagesController < ApplicationController
if @message.save
flash[:notice] = t ".message_sent"
Notifier.message_notification(@message).deliver_now
redirect_to :action => "inbox", :display_name => current_user.display_name
redirect_to :action => :inbox
end
end
end
@ -56,14 +56,14 @@ class MessagesController < ApplicationController
redirect_to :controller => "user", :action => "login", :referer => request.fullpath
end
rescue ActiveRecord::RecordNotFound
@title = t "message.no_such_message.title"
@title = t "messages.no_such_message.title"
render :action => "no_such_message", :status => :not_found
end
# Show a message
def show
@title = t ".title"
@message = Message.find(params[:message_id])
@message = Message.find(params[:id])
if @message.recipient == current_user || @message.sender == current_user
@message.message_read = true if @message.recipient == current_user
@ -73,26 +73,18 @@ class MessagesController < ApplicationController
redirect_to :controller => "user", :action => "login", :referer => request.fullpath
end
rescue ActiveRecord::RecordNotFound
@title = t "message.no_such_message.title"
@title = t "messages.no_such_message.title"
render :action => "no_such_message", :status => :not_found
end
# Display the list of messages that have been sent to the user.
def inbox
@title = t ".title"
if current_user && params[:display_name] == current_user.display_name
else
redirect_to :action => "inbox", :display_name => current_user.display_name
end
end
# Display the list of messages that the user has sent to other users.
def outbox
@title = t ".title"
if current_user && params[:display_name] == current_user.display_name
else
redirect_to :action => "outbox", :display_name => current_user.display_name
end
end
# Set the message as being read or unread.
@ -108,10 +100,10 @@ class MessagesController < ApplicationController
@message.message_read = message_read
if @message.save && !request.xhr?
flash[:notice] = notice
redirect_to :action => "inbox", :display_name => current_user.display_name
redirect_to :action => :inbox
end
rescue ActiveRecord::RecordNotFound
@title = t "message.no_such_message.title"
@title = t "messages.no_such_message.title"
render :action => "no_such_message", :status => :not_found
end
@ -126,11 +118,11 @@ class MessagesController < ApplicationController
if params[:referer]
redirect_to params[:referer]
else
redirect_to :action => "inbox", :display_name => current_user.display_name
redirect_to :action => :inbox
end
end
rescue ActiveRecord::RecordNotFound
@title = t "message.no_such_message.title"
@title = t "messages.no_such_message.title"
render :action => "no_such_message", :status => :not_found
end

View file

@ -64,7 +64,7 @@
</a>
<ul class='dropdown-menu'>
<li>
<%= link_to inbox_path(:display_name => current_user.display_name) do %>
<%= link_to inbox_messages_path do %>
<span class='count-number'><%= number_with_delimiter(current_user.new_messages.size) %></span>
<%= t('user.view.my messages') %>
<% end %>

View file

@ -3,7 +3,7 @@
<% end %>
<% content_for :heading do %>
<h2><%= t '.my_inbox'%>/<%= link_to t('.outbox'), outbox_path(current_user.display_name) %></h2>
<h2><%= t '.my_inbox'%>/<%= link_to t('.outbox'), outbox_messages_path %></h2>
<% end %>
<h4><%= render :partial => "message_count" %></h4>

View file

@ -16,7 +16,7 @@
</div>
<div class='buttons'>
<%= submit_tag t('.send_button') %>
<%= link_to t('.back_to_inbox'), inbox_path(current_user), :class => 'deemphasize button' %>
<%= link_to t('.back_to_inbox'), inbox_messages_path, :class => 'deemphasize button' %>
</div>
</fieldset>
<% end %>

View file

@ -3,7 +3,7 @@
<% end %>
<% content_for :heading do %>
<h2><%= raw(t '.my_inbox', :inbox_link => link_to(t('.inbox'), inbox_path(current_user.display_name))) %>/<%= t'.outbox' %></h2>
<h2><%= raw(t '.my_inbox', :inbox_link => link_to(t('.inbox'), inbox_messages_path)) %>/<%= t'.outbox' %></h2>
<% end %>
<h4><%= t '.messages', :count => current_user.sent_messages.size %></h4>

View file

@ -36,5 +36,5 @@
<% end %>
<%= link_to t('.back'), outbox_path(current_user), :class => "button deemphasize" %>
<%= link_to t('.back'), outbox_messages_path, :class => "button deemphasize" %>
</div>