个人主页->动态
This commit is contained in:
parent
00c50d8114
commit
87ab758ec5
|
@ -483,8 +483,96 @@ class UsersController < ApplicationController
|
|||
render :layout=>nil
|
||||
end
|
||||
|
||||
# def user_course_activities
|
||||
# @list = []
|
||||
# lastid = nil
|
||||
# if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
# lastid = params[:lastid];
|
||||
# end
|
||||
#
|
||||
# user_ids = []
|
||||
# if @user == User.current
|
||||
# watcher = User.watched_by(@user)
|
||||
# watcher.push(User.current)
|
||||
# user_ids = watcher.map{|x| x.id}
|
||||
# else
|
||||
# user_ids << @user.id
|
||||
# end
|
||||
#
|
||||
# query_rec_count = 8
|
||||
# query_times = 10 #query_times次没查到query_rec_count条记录就不查了
|
||||
# query_i = 0;
|
||||
# while( true )
|
||||
# query_i = query_i+1
|
||||
# if(query_i>query_times)
|
||||
# break
|
||||
# end
|
||||
# query = Activity.where(user_id: user_ids)
|
||||
# if(lastid != nil)
|
||||
# query = query.where("id < ?",lastid)
|
||||
# end
|
||||
# lastid,item_list = query_activities(query,'course');
|
||||
# for item in item_list
|
||||
# @list << item
|
||||
# if @list.count() >= query_rec_count
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
# if @list.count() >= query_rec_count
|
||||
# break
|
||||
# end
|
||||
# if lastid == nil
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
# render :layout=>nil
|
||||
# end
|
||||
#
|
||||
# def user_project_activities
|
||||
# @list = []
|
||||
# lastid = nil
|
||||
# if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
# lastid = params[:lastid];
|
||||
# end
|
||||
#
|
||||
# user_ids = []
|
||||
# if @user == User.current
|
||||
# watcher = User.watched_by(@user)
|
||||
# watcher.push(User.current)
|
||||
# user_ids = watcher.map{|x| x.id}
|
||||
# else
|
||||
# user_ids << @user.id
|
||||
# end
|
||||
#
|
||||
# query_rec_count = 8
|
||||
# query_times = 10 #query_times次没查到query_rec_count条记录就不查了
|
||||
# query_i = 0;
|
||||
# while( true )
|
||||
# query_i = query_i+1
|
||||
# if(query_i>query_times)
|
||||
# break
|
||||
# end
|
||||
# query = Activity.where(user_id: user_ids)
|
||||
# if(lastid != nil)
|
||||
# query = query.where("id < ?",lastid)
|
||||
# end
|
||||
# lastid,item_list = query_activities(query,'project');
|
||||
# for item in item_list
|
||||
# @list << item
|
||||
# if @list.count() >= query_rec_count
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
# if @list.count() >= query_rec_count
|
||||
# break
|
||||
# end
|
||||
# if lastid == nil
|
||||
# break
|
||||
# end
|
||||
# end
|
||||
# render :action=>'user_course_activities',:layout=>nil
|
||||
# end
|
||||
def user_course_activities
|
||||
@list = []
|
||||
lastid = nil
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
lastid = params[:lastid];
|
||||
|
@ -499,37 +587,16 @@ class UsersController < ApplicationController
|
|||
user_ids << @user.id
|
||||
end
|
||||
|
||||
query_rec_count = 8
|
||||
query_times = 10 #query_times次没查到query_rec_count条记录就不查了
|
||||
query_i = 0;
|
||||
while( true )
|
||||
query_i = query_i+1
|
||||
if(query_i>query_times)
|
||||
break
|
||||
end
|
||||
query = Activity.where(user_id: user_ids)
|
||||
if(lastid != nil)
|
||||
query = query.where("id < ?",lastid)
|
||||
end
|
||||
lastid,item_list = query_activities(query,'course');
|
||||
for item in item_list
|
||||
@list << item
|
||||
if @list.count() >= query_rec_count
|
||||
break
|
||||
end
|
||||
end
|
||||
if @list.count() >= query_rec_count
|
||||
break
|
||||
end
|
||||
if lastid == nil
|
||||
break
|
||||
end
|
||||
query = Activity.where(user_id: user_ids)
|
||||
if(lastid != nil)
|
||||
query = query.where("id < ?",lastid)
|
||||
end
|
||||
@list = query_activities(query,'Course');
|
||||
|
||||
render :layout=>nil
|
||||
end
|
||||
|
||||
def user_project_activities
|
||||
@list = []
|
||||
lastid = nil
|
||||
if params[:lastid]!=nil && !params[:lastid].empty?
|
||||
lastid = params[:lastid];
|
||||
|
@ -544,32 +611,12 @@ class UsersController < ApplicationController
|
|||
user_ids << @user.id
|
||||
end
|
||||
|
||||
query_rec_count = 8
|
||||
query_times = 10 #query_times次没查到query_rec_count条记录就不查了
|
||||
query_i = 0;
|
||||
while( true )
|
||||
query_i = query_i+1
|
||||
if(query_i>query_times)
|
||||
break
|
||||
end
|
||||
query = Activity.where(user_id: user_ids)
|
||||
if(lastid != nil)
|
||||
query = query.where("id < ?",lastid)
|
||||
end
|
||||
lastid,item_list = query_activities(query,'project');
|
||||
for item in item_list
|
||||
@list << item
|
||||
if @list.count() >= query_rec_count
|
||||
break
|
||||
end
|
||||
end
|
||||
if @list.count() >= query_rec_count
|
||||
break
|
||||
end
|
||||
if lastid == nil
|
||||
break
|
||||
end
|
||||
query = Activity.where(user_id: user_ids)
|
||||
if(lastid != nil)
|
||||
query = query.where("id < ?",lastid)
|
||||
end
|
||||
@list = query_activities(query,'Project');
|
||||
|
||||
render :action=>'user_course_activities',:layout=>nil
|
||||
end
|
||||
|
||||
|
|
|
@ -42,4 +42,30 @@ module ActivitiesHelper
|
|||
end
|
||||
sorted_events
|
||||
end
|
||||
|
||||
def get_container_type(activity)
|
||||
#问卷
|
||||
if activity.act_type == 'Poll'
|
||||
return 'Course'
|
||||
end
|
||||
#注册
|
||||
if activity.act_type == 'Principal'
|
||||
return 'Principal'
|
||||
end
|
||||
#留言
|
||||
if activity.act_type == 'JournalsForMessage'
|
||||
return activity.act.jour.class.to_s
|
||||
end
|
||||
|
||||
# HomeworkCommon Issue Journal Message News
|
||||
if activity.act.respond_to?('course') && activity.act.course
|
||||
return 'Course'
|
||||
end
|
||||
if activity.act.respond_to?('project') && activity.act.project
|
||||
return 'Project'
|
||||
end
|
||||
|
||||
# Contest Contestnotification
|
||||
return 'Unknow'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -360,60 +360,77 @@ module UsersHelper
|
|||
end
|
||||
|
||||
|
||||
# def query_activities(query,type)
|
||||
# query_rec_count = 8
|
||||
# # query = query.where("act_type='JournalsForMessage'")
|
||||
# #query = query.where("act_type not in (?)", ['JournalsForMessage','Message','HomeworkCommon','News','Issue','Journal','Poll'])
|
||||
# list = query.order("id desc").limit(query_rec_count).all
|
||||
#
|
||||
# result = [];
|
||||
# for item in list
|
||||
# container = get_activity_container(item,type)
|
||||
# if( activity_is_show(item,container) )
|
||||
# result << { :item=>item,:e=>container }
|
||||
# end
|
||||
# end
|
||||
# return [lastid,result]
|
||||
# end
|
||||
# def get_activity_container activity,type
|
||||
# e = nil;
|
||||
# if type == 'Project'
|
||||
# if activity.act_type == 'Poll'
|
||||
# # 项目没有问卷
|
||||
# # e = Project.find_by_id(activity.act.polls_group_id)
|
||||
# else
|
||||
# e = activity.act.project if activity.act.respond_to?('project')
|
||||
# end
|
||||
# end
|
||||
# if type == 'Course'
|
||||
# if activity.act_type == 'Poll'
|
||||
# e = Course.find_by_id(activity.act.polls_group_id)
|
||||
# else
|
||||
# e = activity.act.course if activity.act.respond_to?('course')
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# return e;
|
||||
# end
|
||||
def query_activities(query,type)
|
||||
query_rec_count = 50
|
||||
query = query.where("act_type not in ('Contest','Contestnotifications','Principal')")
|
||||
# query = query.where("act_type='JournalsForMessage'")
|
||||
#query = query.where("act_type not in (?)", ['JournalsForMessage','Message','HomeworkCommon','News','Issue','Journal','Poll'])
|
||||
list = query.order("id desc").limit(query_rec_count).all
|
||||
if( list == nil || list.count() < query_rec_count )
|
||||
lastid = nil
|
||||
else
|
||||
lastid = list.last.id
|
||||
end
|
||||
|
||||
query = query.where("activity_container_type = ?",type)
|
||||
list = query.order("id desc").limit(8).all
|
||||
result = [];
|
||||
for item in list
|
||||
container = get_activity_container(item,type)
|
||||
if( activity_is_show(item,container) )
|
||||
result << { :item=>item,:e=>container }
|
||||
end
|
||||
result << { :item=>item,:e=>container }
|
||||
end
|
||||
return [lastid,result]
|
||||
return result
|
||||
end
|
||||
def get_activity_container activity,type
|
||||
e = nil;
|
||||
if type == 'project'
|
||||
if type == 'Project'
|
||||
return activity.act.project if activity.act.respond_to?('project')
|
||||
end
|
||||
if type == 'Course'
|
||||
if activity.act_type == 'Poll'
|
||||
# 项目没有问卷
|
||||
# e = Project.find_by_id(activity.act.polls_group_id)
|
||||
else
|
||||
e = activity.act.project if activity.act.respond_to?('project')
|
||||
return Course.find_by_id(activity.act.polls_group_id)
|
||||
end
|
||||
return activity.act.course if activity.act.respond_to?('course')
|
||||
end
|
||||
if type == 'course'
|
||||
if activity.act_type == 'Poll'
|
||||
e = Course.find_by_id(activity.act.polls_group_id)
|
||||
else
|
||||
e = activity.act.course if activity.act.respond_to?('course')
|
||||
end
|
||||
end
|
||||
|
||||
return e;
|
||||
return nil;
|
||||
end
|
||||
def activity_is_show(activity,e)
|
||||
if(!e)
|
||||
return false
|
||||
end
|
||||
|
||||
if activity.user_id == User.current.id
|
||||
return true
|
||||
end
|
||||
if( e.visible? )
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
# def activity_is_show(activity,e)
|
||||
# if(!e)
|
||||
# return false
|
||||
# end
|
||||
#
|
||||
# if activity.user_id == User.current.id
|
||||
# return true
|
||||
# end
|
||||
# if( e.visible? )
|
||||
# return true
|
||||
# end
|
||||
# return false
|
||||
# end
|
||||
def get_activity_act_showname(activity)
|
||||
case activity.act_type
|
||||
when "HomeworkCommon"
|
||||
|
@ -450,7 +467,21 @@ module UsersHelper
|
|||
return activity.act.created_on
|
||||
end
|
||||
end
|
||||
def get_activity_container_url e
|
||||
if !e.visible?
|
||||
return "javascript:;"
|
||||
end
|
||||
|
||||
if e.class.to_s == 'Course'
|
||||
return url_for(:controller => 'courses', :action=>"show", :id=>e.id, :host=>Setting.host_course)
|
||||
end
|
||||
return url_for(:controller => 'projects', :action=>"show", :id=>e.id, :host=>Setting.host_name)
|
||||
end
|
||||
def get_activity_url(activity,e)
|
||||
if !e.visible?
|
||||
return "javascript:;"
|
||||
end
|
||||
|
||||
case activity.act_type
|
||||
# when "Contest"
|
||||
# when "Contestnotification"
|
||||
|
|
|
@ -7,4 +7,12 @@ class Activity < ActiveRecord::Base
|
|||
validates :user_id, presence: true
|
||||
|
||||
include Trustie::Cache::ClearCourseEvent
|
||||
|
||||
before_create :set_container_type_val
|
||||
|
||||
#helper :activities
|
||||
include ActivitiesHelper
|
||||
def set_container_type_val
|
||||
self.activity_container_type = get_container_type(self)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
<% for rec in @list %>
|
||||
<div class="users_courses_list" nhname="rec" data-id="<%= rec[:item].id %>">
|
||||
<a href="<%= rec[:e].class.to_s == 'Course' ? course_path(rec[:e]) : project_path(rec[:e]) %>" class=" fl users_coursename ml5" title="<%= rec[:e].name %>"><%= rec[:e].name %></a>
|
||||
<a href="<%= get_activity_container_url(rec[:e]) %>" class=" fl users_coursename ml5" title="<%= rec[:e].name %>">
|
||||
<li style="max-width:140px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" class="fl"><%= rec[:e].name %></li>
|
||||
<% if( rec[:e].is_public == false || rec[:e].is_public == 0 ) %>
|
||||
<span class="img_private">私有</span>
|
||||
<% end %>
|
||||
</a>
|
||||
<a href="<%= user_path(rec[:item].user.id) %>" class="c_orange course_name fl mr5" title="<%= rec[:item].user.show_name %>"><%= rec[:item].user.show_name %></a>
|
||||
<span class="fl mr5 c_grey"><%= get_activity_opt(rec[:item],rec[:e]) %></span>
|
||||
<a href="<%= get_activity_url(rec[:item],rec[:e]) %>"
|
||||
class="c_blue02 fl users_courses_txt hidepic" title="<%= get_activity_act_showname(rec[:item]) %>">
|
||||
<%= get_activity_act_showname(rec[:item]).html_safe %>
|
||||
</a>
|
||||
<span class="fr c_grey mr10"><%= time_tag(get_activity_act_createtime(rec[:item])).html_safe %>前</span>
|
||||
<span class="fr c_grey mr10"><%= time_tag(get_activity_act_createtime(rec[:item])).html_safe %></span>
|
||||
</div>
|
||||
<% end %>
|
|
@ -16,7 +16,7 @@
|
|||
<% if User.current.admin? || item.user.id == User.current.id %>
|
||||
<a href="<%= url_for(:controller => 'words', :action=>"destroy", :object_id=>item.id,:user_id=>item.user.id) %>" data-confirm="您确定要删除吗?" data-remote="true" data-method="delete" class="fl mt5 c_purple ml5">删除</a>
|
||||
<% end %>
|
||||
<span class="massage_time fr"><%= time_tag(item.created_on).html_safe %>前</span>
|
||||
<span class="massage_time fr"><%= time_tag(item.created_on).html_safe %></span>
|
||||
<div class="cl"></div>
|
||||
<div nhname='div_form' class="mt10 ml80" style="display:none;">
|
||||
<form action="<%= url_for(:controller => 'words', :action => 'create_reply') %>" data-remote="true" method="post">
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class AddActivityContainerTypeToActivities < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :activities, :activity_container_type, :string, default: ''
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :activities, :activity_container_type
|
||||
end
|
||||
end
|
|
@ -0,0 +1,13 @@
|
|||
class ChangeActivitiesContainerType < ActiveRecord::Migration
|
||||
def up
|
||||
activities = Activity.where("activity_container_type = ''")
|
||||
activities.each do |activity|
|
||||
activity.set_container_type_val
|
||||
activity.save
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
Activity.where("activity_container_type <> ''").update_all(activity_container_type: '')
|
||||
end
|
||||
end
|
|
@ -21,7 +21,8 @@ a:hover.pr_join_a{ background:#41a8c8;}
|
|||
.pr_info_score a{ color:#ff7143;}
|
||||
.pr_info_score a:hover{ color:#64bdd9;}
|
||||
|
||||
.img_private{ background:url(../images/project/img_project.png) 0 0 no-repeat; width:33px; height:16px; color:#fff; font-size:12px; padding-left:7px; }
|
||||
.img_private{ background:url(../images/new_project/img_project.png) 0 0 no-repeat; width:33px; height:16px; color:#fff; font-size:12px; padding-left:7px; }
|
||||
/*.img_private{ background:url(../images/project/img_project.png) 0 0 no-repeat; width:33px; height:16px; color:#fff; font-size:12px; padding-left:7px; }*/
|
||||
.info_foot_num{ color:#3ca5c6; }
|
||||
.pr_info_foot{ color:#7f7f7f; margin-top:5px; }
|
||||
.info_foot_num:hover{ color:#2390b2;}
|
||||
|
|
Loading…
Reference in New Issue