个人主页添加个人留言动态
This commit is contained in:
parent
3ebbcedf1b
commit
8abc97ae84
|
@ -883,6 +883,7 @@ class UsersController < ApplicationController
|
|||
user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
|
||||
course_types = "('Message','News','HomeworkCommon','Poll')"
|
||||
project_types = "('Message','Issue')"
|
||||
principal_types = "JournalsForMessage"
|
||||
if params[:type].present?
|
||||
case params[:type]
|
||||
when "course_homework"
|
||||
|
@ -897,13 +898,15 @@ class UsersController < ApplicationController
|
|||
@user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Issue'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "project_message"
|
||||
@user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "user_journals"
|
||||
@user_activities = UserActivity.where("container_type = 'Principal' and act_type= 'JournalsForMessage' and container_id = #{@user.id}").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
when "current_user"
|
||||
@user_activities = UserActivity.where("user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
else
|
||||
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
end
|
||||
else
|
||||
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
end
|
||||
# @user_activities = paginateHelper @user_activities,500
|
||||
@type = params[:type]
|
||||
|
|
|
@ -76,7 +76,8 @@ class WordsController < ApplicationController
|
|||
# render 'test/index'
|
||||
# }
|
||||
format.js {
|
||||
@user_activity_id = params[:user_activity_id] if
|
||||
@reply_type = params[:reply_type]
|
||||
@user_activity_id = params[:user_activity_id]
|
||||
@activity = JournalsForMessage.find(parent_id)
|
||||
}
|
||||
end
|
||||
|
|
|
@ -64,7 +64,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :dependent => :destroy
|
||||
|
||||
validates :notes, presence: true, if: :is_homework_jour?
|
||||
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message
|
||||
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message, :act_as_principal_activity
|
||||
after_create :reset_counters!
|
||||
after_destroy :reset_counters!
|
||||
after_save :be_user_score
|
||||
|
@ -136,7 +136,11 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
|
||||
#用户动态公共表记录
|
||||
def act_as_principal_activity
|
||||
self.principal_acts << PrincipalActivity.new(:user_id => self.id,:principal_id => self.id)
|
||||
if self.jour_type == 'Principal'
|
||||
unless self.user_id == self.jour.id && self.user_id != self.reply_id && self.reply_id != 0
|
||||
self.principal_acts << PrincipalActivity.new(:user_id => self.user_id, :principal_id => self.jour_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def reset_counters!
|
||||
|
|
|
@ -28,7 +28,7 @@ class PrincipalActivity < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def destroy_user_activity
|
||||
user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'")
|
||||
user_activity = UserActivity.where("act_type = '#{self.principal_act_type.to_s}' and act_id = '#{self.principal_act_id}'")
|
||||
user_activity.destroy_all
|
||||
end
|
||||
end
|
||||
|
|
|
@ -212,7 +212,7 @@ class User < Principal
|
|||
before_save :update_hashed_password
|
||||
before_destroy :remove_references_before_destroy
|
||||
# added by fq
|
||||
after_create :act_as_activity, :add_onclick_time
|
||||
after_create :act_as_activity, :add_onclick_time, :act_as_principal_activity
|
||||
# end
|
||||
# 更新邮箱用户或用户名的同事,同步更新邀请信息
|
||||
after_update :update_invite_list
|
||||
|
|
|
@ -83,6 +83,13 @@
|
|||
<%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:first_user_activity =>first_user_activity,:page => page} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% when 'Principal' %>
|
||||
<% if act %>
|
||||
<% case user_activity.act_type.to_s %>
|
||||
<% when 'JournalsForMessage' %>
|
||||
<%= render :partial => 'user_journalsformessage', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -5,23 +5,17 @@
|
|||
</div>
|
||||
<div class="homepagePostDes">
|
||||
<div class="homepagePostTo break_word">
|
||||
<% if activity.try(:user).try(:realname) == ' ' %>
|
||||
<%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %>
|
||||
<% else %>
|
||||
<%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %>
|
||||
<% end %> TO
|
||||
<% if @user.try(:realname) == ' '%>
|
||||
<% name = @user.login.to_s %>
|
||||
<% else %>
|
||||
<% name = @user.try(:realname).to_s %>
|
||||
<%= link_to activity.user.show_name, user_path(activity.user_id), :class => "newsBlue mr15" %>
|
||||
TO
|
||||
<% if activity.jour %>
|
||||
<%= link_to activity.jour.show_name+"("+(activity.jour.login ? activity.jour.login : activity.jour.show_name ).to_s+")的留言", feedback_path(activity.jour, :host=> Setting.host_user), :class => "newsBlue ml15" %>
|
||||
<% end %>
|
||||
<%= link_to name+"("+@user.login.to_s+")的留言", feedback_path(@user, :host=> Setting.host_user), :class => "newsBlue ml15" %>
|
||||
</div>
|
||||
<div class="homepagePostTitle break_word list_style upload_img">
|
||||
<% if activity.parent %>
|
||||
<%= link_to activity.parent.notes.html_safe, feedback_path(@user, :host=> Setting.host_user), :class => "postGrey" %>
|
||||
<%= link_to activity.parent.notes.html_safe, feedback_path(activity.jour, :host=> Setting.host_user), :class => "postGrey" %>
|
||||
<% else %>
|
||||
<%= link_to activity.notes.html_safe, feedback_path(@user, :host=> Setting.host_user), :class => "postGrey" %>
|
||||
<%= link_to activity.notes.html_safe, feedback_path(activity.jour, :host=> Setting.host_user), :class => "postGrey" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="homepagePostDate">
|
||||
|
@ -67,7 +61,8 @@
|
|||
<%= format_time(comment.created_on) %>
|
||||
</div>
|
||||
<div class="homepagePostReplyContent break_word list_style upload_img" id="reply_content_<%= user_activity_id %>">
|
||||
<%= comment.notes.html_safe %></div>
|
||||
<%= comment.notes.html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
|
@ -86,6 +81,7 @@
|
|||
<%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %>
|
||||
<%= hidden_field_tag 'show_name',params[:show_name],:value =>true %>
|
||||
<%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
|
||||
<%= hidden_field_tag 'reply_type',params[:reply_type],:value =>'user' %>
|
||||
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="user_notes"></textarea>
|
||||
<div nhname='toolbar_container_<%= user_activity_id%>' style="float:left;padding-top:3px; margin-left: 5px;"></div>
|
||||
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<li>
|
||||
<ul class="homepagePostTypeProject fl">
|
||||
<li class="f14">更多</li>
|
||||
<li class="mt-4"><%= link_to "留言动态", {:controller => "users", :action => "show", :type => "user_journals"}, :class =>"homepagePostTypeMessage postTypeGrey"%>
|
||||
<li class="mt-4"><%= link_to "我的动态", {:controller => "users", :action => "show", :type => "current_user"}, :class =>"homepagePostTypeMine postTypeGrey"%>
|
||||
<li class="mt-4"><%= link_to "全部动态", {:controller => "users", :action => "show", :type => nil}, :class =>"homepagePostTypeAll postTypeGrey"%>
|
||||
</ul>
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
<% if @save_succ %>
|
||||
<% if @user_activity_id %>
|
||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>");
|
||||
<% if @reply_type == 'user' %>
|
||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>");
|
||||
<% else %>
|
||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_journalsformessage', :locals => {:activity => @activity,:user_activity_id =>@user_activity_id}) %>");
|
||||
<% end %>
|
||||
init_activity_KindEditor_data('<%= @user_activity_id%>', "", "87%");
|
||||
<% else %>
|
||||
<% if !@jfm.nil? && @jfm.jour_type == 'Principal' %>
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
class UpdatePrincipalActivity < ActiveRecord::Migration
|
||||
def up
|
||||
User.all.each do |user|
|
||||
transaction do
|
||||
user.principal_acts << PrincipalActivity.new(:user_id => user.id,:principal_id => user.id)
|
||||
user.journals_for_messages.each do |jour|
|
||||
jour.principal_acts << PrincipalActivity.new(:user_id => jour.user_id,:principal_id => user.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,43 @@
|
|||
class UpdatePrincipalActivityTime < ActiveRecord::Migration
|
||||
def up
|
||||
count = PrincipalActivity.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... count do i
|
||||
PrincipalActivity.page(i).per(30).each do |activity|
|
||||
if activity.principal_act
|
||||
if activity.principal_act.respond_to?("created_on")
|
||||
activity.created_at = activity.principal_act.created_on
|
||||
activity.updated_at = activity.principal_act.created_on
|
||||
elsif activity.principal_act.respond_to?("created_at")
|
||||
activity.created_at = activity.principal_act.created_at
|
||||
activity.updated_at = activity.principal_act.created_at
|
||||
end
|
||||
activity.save
|
||||
|
||||
user_activity = UserActivity.where("act_type = '#{activity.principal_act_type.to_s}' and act_id = '#{activity.principal_act_id}'").first
|
||||
user_activity.created_at = activity.created_at
|
||||
user_activity.updated_at = activity.created_at
|
||||
if user_activity.act_type == 'JournalsForMessage'
|
||||
if user_activity.act
|
||||
unless user_activity.act.m_parent_id.nil?
|
||||
parent_act = UserActivity.where("act_id = #{user_activity.act.m_parent_id} and act_type='JournalsForMessage' and container_type='Principal'").first
|
||||
if parent_act
|
||||
parent_act.created_at = user_activity.act.parent.children.maximum("created_on")
|
||||
parent_act.save
|
||||
user_activity.destroy
|
||||
end
|
||||
end
|
||||
else
|
||||
user_activity.destroy
|
||||
end
|
||||
end
|
||||
user_activity.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
class UpdateUserActivityUpdatedAt < ActiveRecord::Migration
|
||||
def up
|
||||
count = UserActivity.all.count / 30 + 2
|
||||
transaction do
|
||||
for i in 1 ... count do i
|
||||
UserActivity.page(i).per(30).each do |activity|
|
||||
activity.updated_at = activity.created_at
|
||||
activity.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20151013081912) do
|
||||
ActiveRecord::Schema.define(:version => 20151014013243) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
|
|
@ -624,6 +624,7 @@ a.homepagePostTypeQuiz {background:url(../images/homepage_icon.png) -90px -124px
|
|||
a.homepagePostTypeQuestion {background:url(../images/homepage_icon.png) -10px -273px no-repeat; padding-left:23px;}
|
||||
a.homepagePostTypeMine {background:url(../images/homepage_icon.png) -187px -277px no-repeat; padding-left:23px;}
|
||||
a.homepagePostTypeAll {background:url(../images/homepage_icon.png) -185px -308px no-repeat; padding-left:23px;}
|
||||
a.homepagePostTypeMessage {background:url(images/homepage_icon.png) -3px -518px no-repeat; padding-left:23px;}
|
||||
.homepagePostTypeMore {width:180px; border-top:1px dashed #dddddd; margin-top:5px;}
|
||||
.w100 {width:100px;}
|
||||
a.homepageTypeUnread {background:url(../images/homepage_icon.png) -6px -579px no-repeat; padding-left:23px;}
|
||||
|
|
Loading…
Reference in New Issue