个人主页->访客
This commit is contained in:
parent
b7c4449f4b
commit
00c50d8114
|
@ -40,14 +40,14 @@ class UsersController < ApplicationController
|
|||
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
|
||||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index,
|
||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show]
|
||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist]
|
||||
#edit has been deleted by huang, 2013-9-23
|
||||
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
|
||||
:user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
|
||||
:watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
|
||||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,
|
||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show]
|
||||
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist]
|
||||
before_filter :auth_user_extension, only: :show
|
||||
#before_filter :rest_user_score, only: :show
|
||||
#before_filter :select_entry, only: :user_projects
|
||||
|
@ -58,6 +58,9 @@ class UsersController < ApplicationController
|
|||
#before_filter :refresh_changests, :only =>[:user_activities,:user_courses,:user_projects,:user_newfeedback]
|
||||
|
||||
|
||||
#visitor
|
||||
before_filter :recorded_visitor, :only => [:show,:user_fanslist,:user_watchlist,:user_visitorlist]
|
||||
|
||||
helper :sort
|
||||
include SortHelper
|
||||
helper :custom_fields
|
||||
|
@ -1025,6 +1028,17 @@ class UsersController < ApplicationController
|
|||
@action = 'fans'
|
||||
render :layout=>'base_users_new'
|
||||
end
|
||||
def user_visitorlist
|
||||
limit = 10;
|
||||
#query = @user.watcher_users;
|
||||
query = User.joins("join visitors v on #{User.table_name}.id=v.user_id")
|
||||
query = query.where("v.master_id=?",@user.id)
|
||||
@obj_count = query.count();
|
||||
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||
@list = query.order("v.updated_on desc").limit(limit).offset(@obj_pages.offset).all();
|
||||
@action = 'visitor'
|
||||
render :template=>'users/user_fanslist',:layout=>'base_users_new'
|
||||
end
|
||||
|
||||
#william
|
||||
def update_extensions(user_extensions)
|
||||
|
@ -1128,4 +1142,20 @@ class UsersController < ApplicationController
|
|||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
def recorded_visitor
|
||||
if(User.current.logged? && User.current != @user)
|
||||
#impl = Visitor.where('user_id=? and master_id=?',User.current.id,@user.id).find;
|
||||
# impl = Visitor.find_by_sql('user_id=? and master_id=?',[User.current.id,@user.id]);
|
||||
impl = Visitor.find_by_user_id_and_master_id(User.current.id,@user.id);
|
||||
if(impl.nil?)
|
||||
impl = Visitor.new
|
||||
impl.user_id = User.current.id
|
||||
impl.master_id = @user.id
|
||||
else
|
||||
impl.updated_on = Time.now
|
||||
end
|
||||
impl.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -321,6 +321,15 @@ module UsersHelper
|
|||
list = obj.watcher_users.order("#{Watcher.table_name}.id desc").limit(10).all
|
||||
return [count,list];
|
||||
end
|
||||
def get_visitor_users(obj)
|
||||
query = Visitor.where("master_id=?",obj.id)
|
||||
count = query.count
|
||||
if count == 0
|
||||
return [0,[]]
|
||||
end
|
||||
list = query.order("updated_on desc").limit(10).all
|
||||
return [count,list];
|
||||
end
|
||||
|
||||
def get_create_course_count(user)
|
||||
return Course.where("tea_id = ?",user.id).count()
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class Visitor < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
end
|
|
@ -253,23 +253,18 @@ $(".subNav").click(function(){
|
|||
|
||||
<%= render :partial => 'layouts/user_watch_list', :locals => {:user => @user} %>
|
||||
<%= render :partial => 'layouts/user_fans_list', :locals => {:user => @user} %>
|
||||
<!--<div class="leftbox mt10" >-->
|
||||
<!--<h4 class="fl">访客</h4><a href="javascirpt:void();" class="more fr mr10">更多</a>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--<div class="mt5">-->
|
||||
<!--<a href="javascirpt:void();" class="pic_members"><img src="images/pic_users.jpg" width="38" height="38" alt="头像" /></a>-->
|
||||
<!--<a href="javascirpt:void();" class="pic_members"><img src="images/pic_users.jpg" width="38" height="38" alt="头像" /></a>-->
|
||||
<!--<a href="javascirpt:void();" class="pic_members"><img src="images/pic_users.jpg" width="38" height="38" alt="头像" /></a>-->
|
||||
<!--<a href="javascirpt:void();" class="pic_members"><img src="images/pic_users.jpg" width="38" height="38" alt="头像" /></a>-->
|
||||
<!--<a href="javascirpt:void();" class="pic_members"><img src="images/pic_users.jpg" width="38" height="38" alt="头像" /></a>-->
|
||||
<!--<a href="javascirpt:void();" class="pic_members"><img src="images/pic_users.jpg" width="38" height="38" alt="头像" /></a>-->
|
||||
<!--<a href="javascirpt:void();" class="pic_members"><img src="images/pic_users.jpg" width="38" height="38" alt="头像" /></a>-->
|
||||
<!--<a href="javascirpt:void();" class="pic_members"><img src="images/pic_users.jpg" width="38" height="38" alt="头像" /></a>-->
|
||||
<!--<a href="javascirpt:void();" class="pic_members"><img src="images/pic_users.jpg" width="38" height="38" alt="头像" /></a>-->
|
||||
<!--<a href="javascirpt:void();" class="pic_members"><img src="images/pic_users.jpg" width="38" height="38" alt="头像" /></a>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--</div>-->
|
||||
<!--</div><!–leftbox end–>-->
|
||||
<% visitor_count,visitor_list = get_visitor_users(@user) %>
|
||||
<div class="leftbox mt10" style="display:<%= visitor_count==0 ? 'none' : 'block' %>">
|
||||
<h4 class="fl">访客</h4><a href="<%=url_for(:controller => 'users', :action => 'user_visitorlist', :id=>@user.id)%>" data-count="<%= visitor_count %>" style="display:<%= visitor_count>10 ? 'block' : 'block' %>" class="more fr mr10">更多</a>
|
||||
<div class="cl"></div>
|
||||
<div class="mt5">
|
||||
<% for visitor in visitor_list %>
|
||||
<%= link_to image_tag(url_to_avatar(visitor.user), :style => "width:38px;height:38px;"), user_path(visitor.user), :class => "pic_members", :title => "#{visitor.user.name}" %>
|
||||
<% end %>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!--LSide end-->
|
||||
|
||||
<%= yield %>
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<div id="RSide" class="fl">
|
||||
<div class="courses_box">
|
||||
<div class="courses_top mb10" id="<%= @action == 'fans' ? 'nh_fans_list' : 'nh_wacth_list' %>">
|
||||
<div class="courses_top mb10" id="<%= (@action == 'fans' || @action == 'visitor' ) ? 'nh_fans_list' : 'nh_wacth_list' %>">
|
||||
<% if @action == 'fans' %>
|
||||
<h2 class="courses_h2 fl">粉丝</h2>
|
||||
<div class="courses_select fr">共有<span class="c_orange" nh_name="fans_count"><%=@obj_count%></span>名粉丝</div>
|
||||
<% elsif @action == 'visitor' %>
|
||||
<h2 class="courses_h2 fl">访客</h2>
|
||||
<div class="courses_select fr">共有<span class="c_orange"><%=@obj_count%></span>访客</div>
|
||||
<% else %>
|
||||
<h2 class="courses_h2 fl">关注</h2>
|
||||
<div class="courses_select fr">一共关注<span class="c_orange" nh_name="watcher_count"><%=@obj_count%></span>人</div>
|
||||
|
|
|
@ -302,6 +302,7 @@ RedmineApp::Application.routes.draw do
|
|||
match 'user_course_activities', :to => 'users#user_course_activities', :via => :get
|
||||
match 'user_project_activities', :to => 'users#user_project_activities', :via => :get
|
||||
match 'user_feedback4show', :to => 'users#user_feedback4show', :via => :get
|
||||
match 'user_visitorlist', :to => 'users#user_visitorlist', :via => :get
|
||||
match 'user_homeworks', :to => 'users#user_homeworks', :via => :get
|
||||
match 'watch_projects', :to => 'users#watch_projects', :via => :get
|
||||
# added by bai
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
class CreateVisitors < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :visitors do |t|
|
||||
t.integer :user_id
|
||||
t.integer :master_id
|
||||
t.datetime :updated_on
|
||||
t.datetime :created_on
|
||||
|
||||
end
|
||||
add_index "visitors", ["user_id"], :name => "index_visitors_user_id"
|
||||
add_index "visitors", ["master_id"], :name => "index_visitors_master_id"
|
||||
add_index "visitors", ["updated_on"], :name => "index_visitors_updated_on"
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue