个人主页
This commit is contained in:
parent
e4c9f05c7b
commit
fce523606c
|
@ -552,10 +552,10 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@page = (params[:page] || -1).to_i + 1
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
@type = params[:type]
|
||||
user_project_ids = "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")"
|
||||
user_course_ids = "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
|
||||
user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")"
|
||||
user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
|
||||
if @type
|
||||
case @type
|
||||
when "course_homework"
|
||||
|
@ -575,7 +575,10 @@ class UsersController < ApplicationController
|
|||
@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('created_at desc').limit(10).offset(@page * 10)
|
||||
end
|
||||
# @user_activities = paginateHelper @user_activities,500
|
||||
render :layout=>'new_base_user'
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.html {render :layout => 'new_base_user'}
|
||||
end
|
||||
end
|
||||
|
||||
def show_old
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<% user_activities.each do |user_activity|
|
||||
unless user_activities.nil? %>
|
||||
<% act= user_activity.act unless user_activity.act_type == "ProjectCreateInfo" %>
|
||||
<% case user_activity.container_type.to_s %>
|
||||
<% when 'Course' %>
|
||||
<% if act %>
|
||||
<% case user_activity.act_type.to_s %>
|
||||
<% when 'HomeworkCommon' %>
|
||||
<%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<% when 'News' %>
|
||||
<%= render :partial => 'course_news', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<% when 'Message'%>
|
||||
<%= render :partial => 'course_message', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'Course'%>
|
||||
<%#= render :partial => 'course_create', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'Attachment' %>
|
||||
<%#= render :partial => 'course_attachment', :locals => {:activity => act, :user_activity => user_activity} %>
|
||||
<%# when 'JournalsForMessage' %>
|
||||
<%#= render :partial => 'course_journalsformessage', :locals => {:activity => act, :user_activity => user_activity} %>
|
||||
<%# when 'Poll' %>
|
||||
<%#= render :partial => 'course_poll', :locals => {:activity => act, :user_activity => user_activity} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% when 'Project' %>
|
||||
<% case user_activity.act_type.to_s %>
|
||||
<% when 'Issue' %>
|
||||
<%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<% when 'Message' %>
|
||||
<%= render :partial => 'project_message', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'Journal' %>
|
||||
<%#= render :partial => 'project_journal', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'News' %>
|
||||
<%#= render :partial => 'project_news', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'Document' %>
|
||||
<%#= render :partial => 'project_document', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'Attachment' %>
|
||||
<%#= render :partial => 'project_attachment', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'ProjectCreateInfo' %>
|
||||
<%#= render :partial => 'project_create', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<input type="hidden" value="<%= page%>" id="show_more_activities" />
|
|
@ -1,3 +1,18 @@
|
|||
<script type="text/javascript">
|
||||
var scrollHandler = function(){
|
||||
if ($(window).scrollTop() == $(document).height() - $(window).height()) {
|
||||
$.get(
|
||||
'<%= user_activities_path(@user.id)%>',
|
||||
{ page : $("#show_more_activities").val()},
|
||||
function (data) {
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
$(window).scroll(scrollHandler);
|
||||
</script>
|
||||
|
||||
<div class="resources">
|
||||
<div class="homepageRightBanner">
|
||||
<div class="NewsBannerName">最新动态</div>
|
||||
|
@ -30,49 +45,5 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<% @user_activities.each do |user_activity|
|
||||
unless @user_activities.nil? %>
|
||||
<% act= user_activity.act unless user_activity.act_type == "ProjectCreateInfo" %>
|
||||
<% case user_activity.container_type.to_s %>
|
||||
<% when 'Course' %>
|
||||
<% if act %>
|
||||
<% case user_activity.act_type.to_s %>
|
||||
<% when 'HomeworkCommon' %>
|
||||
<%= render :partial => 'course_homework', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<% when 'News' %>
|
||||
<%= render :partial => 'course_news', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<% when 'Message'%>
|
||||
<%= render :partial => 'course_message', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'Course'%>
|
||||
<%#= render :partial => 'course_create', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'Attachment' %>
|
||||
<%#= render :partial => 'course_attachment', :locals => {:activity => act, :user_activity => user_activity} %>
|
||||
<%# when 'JournalsForMessage' %>
|
||||
<%#= render :partial => 'course_journalsformessage', :locals => {:activity => act, :user_activity => user_activity} %>
|
||||
<%# when 'Poll' %>
|
||||
<%#= render :partial => 'course_poll', :locals => {:activity => act, :user_activity => user_activity} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% when 'Project' %>
|
||||
<% case user_activity.act_type.to_s %>
|
||||
<% when 'Issue' %>
|
||||
<%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<% when 'Message' %>
|
||||
<%= render :partial => 'project_message', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'Journal' %>
|
||||
<%#= render :partial => 'project_journal', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'News' %>
|
||||
<%#= render :partial => 'project_news', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'Document' %>
|
||||
<%#= render :partial => 'project_document', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'Attachment' %>
|
||||
<%#= render :partial => 'project_attachment', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<%# when 'ProjectCreateInfo' %>
|
||||
<%#= render :partial => 'project_create', :locals => {:activity => act,:user_activity =>user_activity} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="pagination">
|
||||
|
||||
</div>
|
||||
<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => @page} %>
|
|
@ -0,0 +1,4 @@
|
|||
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page} )%>");
|
||||
<% if @user_activities.count < 10%>
|
||||
$(window).off("scroll", scrollHandler);
|
||||
<% end%>
|
Loading…
Reference in New Issue