Added 'read' check; message name is only bold if unread
This commit is contained in:
@@ -16,7 +16,7 @@ class MessagerepliesController < ApplicationController
|
||||
@reply.user_author = current_user
|
||||
@reply.message = message
|
||||
if @reply.save
|
||||
@reply.message.update_attributes(user_hidden: nil)
|
||||
@reply.message.update_attributes(user_hidden: nil, read: false)
|
||||
if false
|
||||
@reply.send_new_message_reply_mail
|
||||
end
|
||||
|
||||
@@ -17,6 +17,7 @@ class MessagesController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
Message.find(@message.id).update_attributes(read: true) if !@message.read && @message.user_target.is?(current_user)
|
||||
@replies = @message.replies.page(params[:page])
|
||||
end
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<%= render partial: "users/username", locals: { user: user } %>
|
||||
<span style="font-size:16px">
|
||||
|
||||
<b><%= link_to message.subject, message %></b>
|
||||
<span class="<%= "bold" unless message.user_sender.is?(current_user) || message.read%>"><%= link_to message.subject, message %></span>
|
||||
|
|
||||
</span>
|
||||
<%= ago message.created_at %>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<%= link_to "edit profile", edit_user_path(@user), :class => "btn blue" %>
|
||||
<% end %>
|
||||
<% if @user.is?(current_user) %>
|
||||
<%= link_to "Private Messages (#{Message.where("user_sender_id = ? OR user_target_id = ?", current_user.id, current_user.id).count})", messages_path, :class => "btn blue" %>
|
||||
<%= link_to "Private Messages (#{Message.where(read: false).count})", messages_path, :class => "btn blue" %>
|
||||
<% elsif current_user %>
|
||||
<%= link_to "Send this user a message", new_message_path(user_target: @user.ign), :class => "btn blue" %>
|
||||
<% end %>
|
||||
|
||||
@@ -6,7 +6,9 @@ class CreateMessages < ActiveRecord::Migration
|
||||
t.references :user_target
|
||||
t.references :user_editor
|
||||
t.references :user_hidden
|
||||
t.datetime :created_at
|
||||
t.boolean :read, default: false
|
||||
|
||||
t.timestamps null: true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class AddUserEditorToMessages < ActiveRecord::Migration
|
||||
def change
|
||||
add_reference :messages, :user_editor
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170613144233) do
|
||||
ActiveRecord::Schema.define(version: 20170613021450) do
|
||||
|
||||
create_table "blogposts", force: :cascade do |t|
|
||||
t.string "title", limit: 191
|
||||
@@ -89,11 +89,12 @@ ActiveRecord::Schema.define(version: 20170613144233) do
|
||||
t.text "text", limit: 65535
|
||||
t.integer "user_sender_id", limit: 4
|
||||
t.integer "user_target_id", limit: 4
|
||||
t.integer "user_editor_id", limit: 4
|
||||
t.integer "user_hidden_id", limit: 4
|
||||
t.boolean "read", default: false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "subject", limit: 191
|
||||
t.integer "user_editor_id", limit: 4
|
||||
end
|
||||
|
||||
create_table "register_tokens", force: :cascade do |t|
|
||||
|
||||
Reference in New Issue
Block a user