个人主页留言消息推送
This commit is contained in:
parent
c8399cdf58
commit
6b6f6e0b0d
|
@ -116,7 +116,7 @@ class UsersController < ApplicationController
|
||||||
@user_forge_messages = @user.forge_messages.reverse
|
@user_forge_messages = @user.forge_messages.reverse
|
||||||
@user_memo_messages = @user.memo_messages.reverse
|
@user_memo_messages = @user.memo_messages.reverse
|
||||||
@user_course_messages_count = @user_course_messages.count
|
@user_course_messages_count = @user_course_messages.count
|
||||||
@user_forge_messages_count = @user_forum_messages.count
|
@user_forge_messages_count = @user_forge_messages.count
|
||||||
@user_memo_messages_count = @user_memo_messages.count
|
@user_memo_messages_count = @user_memo_messages.count
|
||||||
when 'homework'
|
when 'homework'
|
||||||
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc")
|
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc")
|
||||||
|
@ -147,8 +147,8 @@ class UsersController < ApplicationController
|
||||||
@user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc")
|
@user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc")
|
||||||
@user_forge_messages_count = @user_forge_messages.count
|
@user_forge_messages_count = @user_forge_messages.count
|
||||||
when 'forum'
|
when 'forum'
|
||||||
@user_forum_messages = Memo.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc")
|
@user_memo_messages = Memo.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc")
|
||||||
@user_forum_messages_count = @user_forum_messages.count
|
@user_memo_messages_count = @user_memo_messages.count
|
||||||
else
|
else
|
||||||
render_404
|
render_404
|
||||||
return
|
return
|
||||||
|
|
|
@ -207,19 +207,20 @@ class JournalsForMessage < ActiveRecord::Base
|
||||||
if self.user_id != self.jour_id # 过滤自己给自己的留言消息
|
if self.user_id != self.jour_id # 过滤自己给自己的留言消息
|
||||||
receivers << self.jour
|
receivers << self.jour
|
||||||
end
|
end
|
||||||
else # 回帖
|
else # 留言回复
|
||||||
# 添加吧主
|
# 添加留言回复人
|
||||||
if self.author_id != self.forum.creator_id
|
if self.user_id != self.parent.user_id # 如果回帖人不是用户自己
|
||||||
receivers << self.jour
|
receivers << User.find(self.reply_id)
|
||||||
end
|
end
|
||||||
# 添加发帖人
|
if self.user_id != self.parent.jour_id
|
||||||
if self.author_id != self.parent.author_id
|
receivers << self.parent.jour
|
||||||
receivers << self.parent.author
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if self.jour_type == 'Principal'
|
if self.jour_type == 'Principal'
|
||||||
if self.user_id != self.jour_id
|
if self.user_id != self.jour_id
|
||||||
self.user_feedback_messages << UserFeedbackMessage.new(:user_id => self.jour_id, :user_message_id => self.id, :user_message_type => "Forum", :viewed => false)
|
receivers.each do |r|
|
||||||
|
self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
class UserFeedbackMessage < ActiveRecord::Base
|
|
||||||
attr_accessible :user_id, :user_message_id, :user_message_type, :viewed
|
|
||||||
|
|
||||||
belongs_to :user
|
|
||||||
belongs_to :journals_for_message
|
|
||||||
|
|
||||||
validates :user_id,presence: true
|
|
||||||
validates :user_message_id,presence: true
|
|
||||||
validates :user_message_type, presence: true
|
|
||||||
end
|
|
|
@ -2,8 +2,8 @@ class CreateUserFeedbackMessages < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
create_table :user_feedback_messages do |t|
|
create_table :user_feedback_messages do |t|
|
||||||
t.integer :user_id
|
t.integer :user_id
|
||||||
t.integer :user_message_id
|
t.integer :journals_for_message_id
|
||||||
t.string :user_message_type
|
t.string :journals_for_message_type
|
||||||
t.integer :viewed
|
t.integer :viewed
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
20
db/schema.rb
20
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20150819090720) do
|
ActiveRecord::Schema.define(:version => 20150820004659) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -572,16 +572,6 @@ ActiveRecord::Schema.define(:version => 20150819090720) do
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "forum_messages", :force => true do |t|
|
|
||||||
t.integer "user_id"
|
|
||||||
t.integer "forum_id"
|
|
||||||
t.integer "memo_id"
|
|
||||||
t.string "memo_type"
|
|
||||||
t.integer "viewed"
|
|
||||||
t.datetime "created_at", :null => false
|
|
||||||
t.datetime "updated_at", :null => false
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "forums", :force => true do |t|
|
create_table "forums", :force => true do |t|
|
||||||
t.string "name", :null => false
|
t.string "name", :null => false
|
||||||
t.text "description"
|
t.text "description"
|
||||||
|
@ -1436,11 +1426,11 @@ ActiveRecord::Schema.define(:version => 20150819090720) do
|
||||||
|
|
||||||
create_table "user_feedback_messages", :force => true do |t|
|
create_table "user_feedback_messages", :force => true do |t|
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.integer "user_message_id"
|
t.integer "journals_for_message_id"
|
||||||
t.string "user_message_type"
|
t.string "journals_for_message_type"
|
||||||
t.integer "viewed"
|
t.integer "viewed"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "user_grades", :force => true do |t|
|
create_table "user_grades", :force => true do |t|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
FactoryGirl.define do
|
|
||||||
factory :user_feedback_message do
|
|
||||||
user_id 1
|
|
||||||
user_message_id 1
|
|
||||||
user_message_type "MyString"
|
|
||||||
viewed 1
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe UserFeedbackMessage, :type => :model do
|
|
||||||
pending "add some examples to (or delete) #{__FILE__}"
|
|
||||||
end
|
|
Loading…
Reference in New Issue