个人首页的项目社区
This commit is contained in:
parent
224c0b686c
commit
1875b6ecf7
|
@ -1995,6 +1995,61 @@ class UsersController < ApplicationController
|
|||
|
||||
# 项目社区
|
||||
def project_community
|
||||
# 看别人的主页显示动态
|
||||
#更新用户申请成为课程老师或教辅消息的状态
|
||||
shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Project'").map(&:shield_id)
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
user_project_ids = (@user.favorite_projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.favorite_projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||
project_types = "('Message','Issue','Project')"
|
||||
principal_types = "JournalsForMessage"
|
||||
container_type = ''
|
||||
act_type = ''
|
||||
if params[:type].present?
|
||||
case params[:type]
|
||||
when "project_issue"
|
||||
container_type = 'Project'
|
||||
act_type = 'Issue'
|
||||
when "project_message"
|
||||
container_type = 'Project'
|
||||
act_type = 'Message'
|
||||
when "user_journals"
|
||||
container_type = 'Principal'
|
||||
act_type = 'JournalsForMessage'
|
||||
when "current_user"
|
||||
container_type = 'Principal'
|
||||
act_type = 'Principal'
|
||||
when "all"
|
||||
container_type = 'all'
|
||||
act_type = 'all'
|
||||
end
|
||||
end
|
||||
if container_type != '' && container_type != 'all'
|
||||
if container_type == 'Project'
|
||||
sql = "container_type = '#{container_type}' and container_id in #{user_project_ids} and act_type = '#{act_type}'"
|
||||
elsif container_type == 'Principal' && act_type == 'JournalsForMessage'
|
||||
sql = "container_type = '#{container_type}' and act_type= '#{act_type}' and container_id = #{@user.id}"
|
||||
elsif container_type == 'Principal' && act_type == 'Principal'
|
||||
sql = "user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}))"
|
||||
end
|
||||
if User.current != @user
|
||||
sql += " and user_id = #{@user.id}"
|
||||
end
|
||||
else
|
||||
if User.current != @user
|
||||
blog_ids = "("+@user.blog.id.to_s+")"
|
||||
else
|
||||
blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")"
|
||||
end
|
||||
sql = "(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
|
||||
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " +
|
||||
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})"
|
||||
if container_type != 'all' && User.current != @user
|
||||
sql = "user_id = #{@user.id} and(" + sql + ")"
|
||||
end
|
||||
end
|
||||
@user_activities_count = UserActivity.where("#{sql}").order('updated_at desc').count
|
||||
@user_activities = UserActivity.where("#{sql}").order('updated_at desc').limit(10).offset(@page * 10)
|
||||
@type = params[:type]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {render :layout => 'base_project_community'}
|
||||
|
@ -3792,7 +3847,7 @@ class UsersController < ApplicationController
|
|||
@my_joined_projects_count = @my_joined_projects.count
|
||||
|
||||
respond_to do |format|
|
||||
format.html {render :layout => 'new_base_user'}
|
||||
format.html {render :layout => 'base_project_community'}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -109,7 +109,8 @@
|
|||
<!--
|
||||
<div id="show_more_activities" class="loadMore mt10 f_grey">点击展开更多<%#=link_to "", user_activities_path(@user.id,:type => type,:page => page),:id => "more_activities_link",:remote => "true",:class => "none" %></div>
|
||||
-->
|
||||
<%= link_to "点击展开更多",user_activities_path(@user.id,:type => type,:page => page),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%>
|
||||
<%= link_to "点击展开更多", action == "project_community" ? user_project_community_path(@user.id, :type => type, :page => page) : user_course_community_path(@user.id, :type => type,:page => page),
|
||||
:id => "show_more_activities", :remote => "true", :class => "loadMore mt10 f_grey" %>
|
||||
<% end%>
|
||||
|
||||
<!--
|
||||
|
|
|
@ -4,18 +4,18 @@
|
|||
<div class="NewsBannerName">消息动态</div>
|
||||
<ul class="resourcesSelect">
|
||||
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
|
||||
<ul class="homepagePostType" style="position:static; width: 80px" >
|
||||
<ul class="homepagePostType" style="margin-left:95px; width:80px" >
|
||||
<li>
|
||||
<ul class="homepagePostTypeHomework fl">
|
||||
<% if hidden_unproject_infos %>
|
||||
<li><%= link_to "全部动态", {:controller => "users", :action => "course_community", :type => "all"}, :class => "homepagePostTypeAll postTypeGrey" %>
|
||||
<li><%= link_to @user == User.current ? "我的动态" : "他的动态", {:controller => "users", :action => "course_community", :type => "current_user"}, :class => "homepagePostTypeMine postTypeGrey" %>
|
||||
<li><%= link_to "作业动态", {:controller => "users", :action => "course_community", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey" %>
|
||||
<li><%= link_to "通知动态", {:controller => "users", :action => "course_community", :type => "course_news"}, :class => "homepagePostTypeNotice postTypeGrey" %>
|
||||
<li><%= link_to "论坛动态", {:controller => "users", :action => "course_community", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey" %>
|
||||
<li><%= link_to "问卷动态", {:controller => "users", :action => "course_community", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey" %>
|
||||
<li><%= link_to "班级留言", {:controller => "users", :action => "course_community", :type => "course_journals"}, :class => "homepagePostTypeMessage postTypeGrey" %>
|
||||
<li><%= link_to "个人留言", {:controller => "users", :action => "course_community", :type => "user_journals"}, :class => "homepagePostTypeMessage postTypeGrey" %>
|
||||
<li><%= link_to "全部动态", {:controller => "users", :action => "course_community", :type => "all"}, :class => "homepagePostTypeAll postTypeGrey" %></li>
|
||||
<li><%= link_to @user == User.current ? "我的动态" : "他的动态", {:controller => "users", :action => "course_community", :type => "current_user"}, :class => "homepagePostTypeMine postTypeGrey" %></li>
|
||||
<li><%= link_to "作业动态", {:controller => "users", :action => "course_community", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey" %></li>
|
||||
<li><%= link_to "通知动态", {:controller => "users", :action => "course_community", :type => "course_news"}, :class => "homepagePostTypeNotice postTypeGrey" %></li>
|
||||
<li><%= link_to "论坛动态", {:controller => "users", :action => "course_community", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey" %></li>
|
||||
<li><%= link_to "问卷动态", {:controller => "users", :action => "course_community", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey" %></li>
|
||||
<li><%= link_to "班级留言", {:controller => "users", :action => "course_community", :type => "course_journals"}, :class => "homepagePostTypeMessage postTypeGrey" %></li>
|
||||
<li><%= link_to "个人留言", {:controller => "users", :action => "course_community", :type => "user_journals"}, :class => "homepagePostTypeMessage postTypeGrey" %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -30,7 +30,8 @@
|
|||
<%#= render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id} %>
|
||||
<%# end %>
|
||||
<% if @user_activities_count > 0 %>
|
||||
<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities, :page => 0, :type => @type, :user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id)} %>
|
||||
<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities, :page => 0, :type => @type,
|
||||
:user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id), :action => params[:action] } %>
|
||||
<% else %>
|
||||
<div class="mb10">
|
||||
<%= render :partial => 'users/no_data' %>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',
|
||||
:locals => {:user_activities => @user_activities,
|
||||
:page => @page,
|
||||
:type => @type,
|
||||
:user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id),
|
||||
:action => "course_community"} )%>");
|
|
@ -0,0 +1,37 @@
|
|||
<script src="/javascripts/i18n/jquery.ui.datepicker-zh-CN.js" type="text/javascript"></script>
|
||||
<input type="hidden" value="<%= @type%>" name="type" id="user_activities_type">
|
||||
<div class="homepageRightBanner">
|
||||
<div class="NewsBannerName">消息动态</div>
|
||||
<ul class="resourcesSelect">
|
||||
<li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
|
||||
<ul class="homepagePostType" style="margin-left:95px; width:80px" >
|
||||
<li>
|
||||
<ul class="homepagePostTypeHomework fl">
|
||||
<% if hidden_unproject_infos %>
|
||||
<li><%= link_to "全部动态", {:controller => "users", :action => "project_community", :type => "all"}, :class => "homepagePostTypeAll postTypeGrey" %></li>
|
||||
<li><%= link_to @user == User.current ? "我的动态" : "他的动态", {:controller => "users", :action => "project_community", :type => "current_user"},
|
||||
:class => "homepagePostTypeMine postTypeGrey" %></li>
|
||||
<li><%= link_to "问题动态", {:controller => "users", :action => "project_community", :type => "project_issue"}, :class => "homepagePostTypeQuestion postTypeGrey"%></li>
|
||||
<li><%= link_to "论坛动态", {:controller => "users", :action => "project_community", :type => "project_message"}, :class => "homepagePostTypeForum postTypeGrey"%></li>
|
||||
<li><%= link_to "个人留言", {:controller => "users", :action => "project_community", :type => "user_journals"}, :class => "homepagePostTypeMessage postTypeGrey" %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!--显示个人主页-->
|
||||
<%# if @user.blog.homepage_id and BlogComment.where("id=?", @user.blog.homepage_id).count > 0 %>
|
||||
<%# homepage = BlogComment.find(@user.blog.homepage_id) %>
|
||||
<%#= render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id} %>
|
||||
<%# end %>
|
||||
<% if @user_activities_count > 0 %>
|
||||
<%= render :partial => 'users/user_activities', :locals => { :user_activities => @user_activities, :page => 0, :type => @type,
|
||||
:user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id), :action => params[:action] } %>
|
||||
<% else %>
|
||||
<div class="mb10">
|
||||
<%= render :partial => 'users/no_data' %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -0,0 +1,6 @@
|
|||
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',
|
||||
:locals => {:user_activities => @user_activities,
|
||||
:page => @page,
|
||||
:type => @type,
|
||||
:user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id),
|
||||
:action => "project_community"} )%>");
|
Loading…
Reference in New Issue