Merge branch 'sw_new_course' of http://repository.trustie.net/xianbo/trustie2 into sw_new_course

This commit is contained in:
sw 2015-08-26 13:56:53 +08:00
commit f0a4d364b0
7 changed files with 77 additions and 17 deletions

View File

@ -1276,8 +1276,8 @@ class UsersController < ApplicationController
@obj_count = query.count();
@obj_pages = Paginator.new @obj_count,limit,params['page']
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
render :template=>'users/user_fanslist',:layout=>'base_users_new'
@action = 'watch'
render :template=>'users/user_fanslist',:layout=>'new_base_user'
end
###add by huang
def user_fanslist
@ -1287,7 +1287,7 @@ class UsersController < ApplicationController
@obj_pages = Paginator.new @obj_count,limit,params['page']
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
@action = 'fans'
render :layout=>'base_users_new'
render :layout=>'new_base_user'
end
def user_visitorlist
limit = 10;

View File

@ -22,9 +22,26 @@ class WatchersController < ApplicationController
def watch
s = WatchesService.new
watchables = s.watch params.merge(:current_user_id => User.current.id)
if params[:action_name] == 'watch'
limit = 10;
query = User.watched_by(params[:target_id]);
@obj_count = query.count();
@obj_pages = Paginator.new @obj_count,limit,params['page']
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
@action = 'watch'
elsif params[:action_name] == 'fans'
limit = 10;
query = User.find(params[:target_id]).watcher_users;
@obj_count = query.count();
@obj_pages = Paginator.new @obj_count,limit,params['page']
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
@action = 'fans'
else
end
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (true ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'add'} }
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'add',:list => @list,:action_name=>params[:action_name],:page=>params[:page]} }
end
rescue Exception => e
if e.message == "404"
@ -38,9 +55,25 @@ class WatchersController < ApplicationController
def unwatch
s = WatchesService.new
watchables = s.unwatch params.merge(:current_user_id => User.current.id)
if params[:action_name] == 'watch'
limit = 10;
query = User.watched_by(params[:target_id]);
@obj_count = query.count();
@obj_pages = Paginator.new @obj_count,limit,params['page']
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
@action = 'watch'
elsif params[:action_name] == 'fans'
limit = 10;
query = User.find(params[:target_id]).watcher_users;
@obj_count = query.count();
@obj_pages = Paginator.new @obj_count,limit,params['page']
@list = query.order("#{Watcher.table_name}.id desc").limit(limit).offset(@obj_pages.offset).all();
@action = 'fans'
else
end
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (false ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'delete'} }
format.js { render :partial => 'set_watcher', :locals => {:user => User.current, :watched => watchables,:params=>params,:opt=>'delete',:list=>@list,:action_name=>params[:action_name],:page=>params[:page]} }
end
rescue Exception => e
if e.message == "404"

View File

@ -7,7 +7,7 @@
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'new_user', 'user_leftside','users', :media => 'all' %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'new_user', 'user_leftside','users',:media => 'all' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= javascript_include_tag "bootstrap","avatars","new_user"%>
@ -66,14 +66,14 @@
</div>
<div>
<div class="homepageImageBlock">
<div>
<div id="watch_user_number_div">
<%= link_to User.watched_by(@user.id).count.to_s, {:controller=>"users", :action=>"user_watchlist",:id=>@user.id},:class=>"homepageImageNumber" %>
</div>
<div class="homepageImageText">关注</div>
</div>
<div class="homepageVerDiv"></div>
<div class="homepageImageBlock">
<div>
<div id="fans_user_number_div">
<%= link_to @user.watcher_users.count.to_s, {:controller=>"users", :action=>"user_fanslist",:id=>@user.id},:class=>"homepageImageNumber", :id => "user_fans_number"%>
</div>
<div class="homepageImageText">粉丝</div>

View File

@ -1,3 +1,5 @@
<% unless list.nil?%>
<% for item in list %>
<div class="courses_list line" id="fans_item_<%=item.id%>">
<div class="courses_list_pic fl">
<a href="<%= user_path(item) %>">
@ -39,12 +41,15 @@
</tr></tbody></table>
</div>
</div>
<!-- 如果只有自己的关注页面才能关注人 取消关注操作,那么还要加 一句&& User.current.id == target.id-->
<% if(User.current.logged? && User.current != item )%>
<%if(item.watched_by?(User.current))%>
<a href="<%= watch_path(:object_type=>'user',:object_id=>item.id,:target_id=>target.id) %>" class="grey_n_btn fr mt20" data-method="delete" data-remote="true" title="取消关注">取消关注</a>
<a href="<%= watch_path(:object_type=>'user',:object_id=>item.id,:target_id=>target.id,:action_name=>action_name,:page=>page) %>" class="grey_n_btn fr mt20" data-method="delete" data-remote="true" title="取消关注">取消关注</a>
<% else %>
<a href="<%= watch_path(:object_type=>'user',:object_id=>item.id,:target_id=>target.id) %>" class="blue_n_btn fr mt20" data-method="post" data-remote="true" title="添加关注">添加关注</a>
<a href="<%= watch_path(:object_type=>'user',:object_id=>item.id,:target_id=>target.id,:action_name=>action_name,:page=>page) %>" class="blue_n_btn fr mt20" data-method="post" data-remote="true" title="添加关注">添加关注</a>
<% end %>
<% end %>
<div class="cl"></div>
</div>
<% end %>
<% end %>

View File

@ -1,4 +1,12 @@
<div id="RSide" class="fl">
<!--<div id="RSide" class="fl">-->
<script>
function addWatch(){
}
function cancelWatch(){
}
</script>
<div class="courses_box">
<div class="courses_top mb10" id="<%= (@action == 'fans' || @action == 'visitor' ) ? 'nh_fans_list' : 'nh_wacth_list' %>">
<% if @action == 'fans' %>
@ -13,13 +21,15 @@
<% end %>
<div class="cl"></div>
</div>
<% for item in @list %>
<%= render :partial => 'users/user_fans_item', :locals => {:item => item,:target=>@user} %>
<% end %>
<div id="users_list">
<%# for item in @list %>
<%= render :partial => 'users/user_fans_item', :locals => {:list => @list,:target=>@user,:action_name=>@action,:page=>params[:page]} %>
<%# end %>
</div>
<p id="nodata" class="nodata" style="display:<%= @list.count > 0 ? 'none' : 'block' %>;"><%= l(:label_no_data) %></p>
</div>
<ul class="wlist" style=" border:none;">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
</ul>
<div class="cl"></div>
</div>
<!--</div>-->

View File

@ -5,10 +5,14 @@
$("#user_fans_number").html("<%= watched.first.watcher_users.count.to_s%>");
//在当前用户的粉丝、关注页面
<% elsif( params[:target_id] == User.current.id.to_s )%>
$("#users_list").html("<%= escape_javascript (render :partial => 'users/user_fans_item', :locals => {:list => list,:target=>User.current,:action_name=>action_name,:page=>params[:page]}) %>");
$("#watch_user_number_div").html('<%= escape_javascript ( link_to User.watched_by(params[:target_id]).count.to_s, {:controller=>"users", :action=>"user_watchlist",:id=>params[:target_id]},:class=>"homepageImageNumber") %>');
$("#fans_user_number_div").html('<%= escape_javascript ( link_to User.find(params[:target_id]).watcher_users.count.to_s, {:controller=>"users", :action=>"user_fanslist",:id=>params[:target_id]},:class=>"homepageImageNumber", :id => "user_fans_number") %>');
//在其他用户的粉丝、关注页面
<% else %>
$("#users_list").html("<%= escape_javascript (render :partial => 'users/user_fans_item', :locals => {:list => list,:target=>User.find(params[:target_id]),:action_name=>action_name,:page=>params[:page]}) %>");
//在他人的用户分析下关注,不会改变他人的关注数,所以不必要刷新
//$("#watch_user_number").html('<%#= escape_javascript ( link_to User.watched_by(params[:target_id]).count.to_s, {:controller=>"users", :action=>"user_watchlist",:id=>params[:target_id]},:class=>"homepageImageNumber") %>');
<% end %>
<% else %>

View File

@ -619,6 +619,14 @@ a.loginChooseTab {color:#484848; height:30px; display:block;}
.loginSignAlert {font-size:12px; margin-left:60px;}
.loginSignRow {height:60px; min-height:60px;}
/*关注列表*/
.inf_user_image{ padding-left:8px; margin:0px; background-color:#fff; height: auto;padding-bottom: 8px;}
ul.list_watch{
padding-left: 0px;
list-style-type:none;
height:auto;
border-bottom: 1px dashed rgb(204, 204, 204);
}
/*底部*/