diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bdbaf1738..860e4ca30 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1724,7 +1724,7 @@ class UsersController < ApplicationController end end - @user_activities = UserActivity.where("#{sql}").order('updated_at desc').limit(10).offset(@page * 10) + @user_activities = UserActivity.where("#{sql}").order('updated_at desc').limit(5).offset(@page * 5) @type = params[:type] respond_to do |format| format.js diff --git a/app/views/layouts/_course_base_info.html.erb b/app/views/layouts/_course_base_info.html.erb index 469382b48..6428aa5fa 100644 --- a/app/views/layouts/_course_base_info.html.erb +++ b/app/views/layouts/_course_base_info.html.erb @@ -59,7 +59,7 @@ <% end %>
- <% cache [:course_righthead,@course.id.to_s] do%> + <% cache [:course_righthead,@course.id.to_s+"-"+@course.updated_at.to_i.to_s] do%>

<%= link_to @course.syllabus.title, syllabus_path(@course.syllabus_id), :class =>'c_dark', :target => '_blank'%> diff --git a/app/views/layouts/_user_courses.html.erb b/app/views/layouts/_user_courses.html.erb index 60db07db0..6ccd754a1 100644 --- a/app/views/layouts/_user_courses.html.erb +++ b/app/views/layouts/_user_courses.html.erb @@ -1,7 +1,10 @@ <% courses.each do |course|%> + <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %> + <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> + <% wechat_count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> + <% cache [:homepage_course_info,course.id.to_s+"-"+is_teacher.to_s+"-"+(User.current == user).to_s+"-"+(User.current.member_of_course?(course)).to_s+"-"+count.to_s+"-"+wechat_count.to_s+course.updated_at.to_i.to_s] do%>
  • - <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %>

    <% title = "#{course.syllabus.title}".html_safe %> <%= link_to title, syllabus_path(course.syllabus_id), :target => '_blank', :class => 'hidden', :style => "max-width:91px; display:inline-block;"%> @@ -16,9 +19,6 @@

    <%#= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :id => "show_course_#{course.id}", :class => 'course_list_menu hidden', :target => '_blank', :title => (course.is_public? ? "公开班级:":"私有班级:")+course.name+"("+current_time_and_term(course)+")"%> - <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> - <% wechat_count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> -
    • @@ -83,7 +83,7 @@ <% end %>
    • <% end %> - <% if User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %> + <% if is_teacher %>
    • <%= link_to course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => course,:user_page => true}, :id => "set_course_public_#{course.id.to_s}",:remote=>true, :class => 'user_navmore_li',:confirm=>"您确定要设置为"+(course.is_public == 0 ? "公开" : "私有")+"吗"%> @@ -95,6 +95,7 @@
  • + <% end %> <% end %> <% if all_count > (page.to_i+1) * 10%> diff --git a/app/views/layouts/_user_projects.html.erb b/app/views/layouts/_user_projects.html.erb index e8a7f0755..4e5a375b3 100644 --- a/app/views/layouts/_user_projects.html.erb +++ b/app/views/layouts/_user_projects.html.erb @@ -1,9 +1,15 @@ <% projects.each do |project|%> + <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count %> + <% wechat_count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count %> + <% is_logged = User.current.logged? %> + <% is_admin = User.current.admin? %> + <% current_user_isuser = User.current == @user %> + <% can_setting = User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, project) %> + <% is_manager = is_project_manager?(User.current,project) %> + <% cache [:homepage_project_info,project.id.to_s+"-"+is_logged.to_s+"-"+is_admin.to_s+"-"+current_user_isuser.to_s+"-"+can_setting.to_s+"-"+count.to_s+"-"+wechat_count.to_s+"-"+is_manager.to_s+"-"+project.updated_on.to_i.to_s] do%>
  • - <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count %> <%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "project_list_menu hidden",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%> -
    • @@ -32,7 +38,7 @@
    • - <% if ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count == 0 %> + <% if count == 0 %> <%= link_to "屏蔽动态", shield_activities_path(:user_id => user.id, :project_id => project.id), :method => 'post',:remote => true,:class => "user_navmore_li" %> <% else %> <%= link_to "显示动态", show_acts_shield_activities_path(:user_id => user.id, :project_id => project.id),:method => 'delete',:remote => true,:class => "user_navmore_li" %> @@ -40,7 +46,7 @@
    • - <% if ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count == 0 %> + <% if wechat_count == 0 %> <%= link_to "屏蔽微信消息", shield_wechat_messages_path(:user_id => user.id, :project_id => project.id), :method => 'post',:remote => true,:class => "user_navmore_li" %> <% else %> <%= link_to "接收微信消息", show_messages_shield_wechat_messages_path(:user_id => user.id, :project_id => project.id),:method => 'delete',:remote => true,:class => "user_navmore_li" %> @@ -60,6 +66,7 @@
  • + <% end %> <% end %> <% if all_count > (page.to_i+1) * 10%> diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 5a0065f86..759571e0d 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -1,5 +1,6 @@ <% unless activity.author.nil? %>
    + <% cache [:user_projectissue_activity,activity.id.to_s+"-"+User.current.logged?.to_s+"-"+(defined?(project_id)).to_s+"-"+(defined?(user_id)).to_s+"-"+(activity.editable?).to_s+"-"+(User.current.allowed_to?(:edit_issues, activity.project)).to_s+"-"+(User.current.allowed_to?(:delete_issues, activity.project)).to_s+"-"+(User.current.allowed_to?(:add_issues, activity.project)).to_s+"-"+activity.updated_on.to_i.to_s] do%>
    <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> @@ -95,6 +96,7 @@
    + <% end %>
    <%= render :partial => 'users/project_issue_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id} %>
    diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb index d590b9a66..ad5a4fc23 100644 --- a/app/views/users/_project_message.html.erb +++ b/app/views/users/_project_message.html.erb @@ -1,4 +1,6 @@
    + <% update_time = get_forge_act_message(activity, activity.class.to_s) %> + <% cache [:user_projectmessage_activity,activity.id.to_s+"-"+User.current.logged?.to_s+"-"+(activity.author.id == User.current.id).to_s+"-"+(activity.editable_by?(User.current)).to_s+"-"+(activity.destroyable_by?(User.current)).to_s+"-"+update_time] do%>
    <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> @@ -29,7 +31,7 @@ 发帖时间:<%= format_time(activity.created_on) %>
    - 更新时间:<%= get_forge_act_message(activity, activity.class.to_s) %> + 更新时间:<%= update_time %>
    <% if activity.parent_id.nil? %> @@ -81,6 +83,7 @@
    + <% end %> <% all_comments = []%> <% count=get_all_children(all_comments, activity).count %> <%# allow_delete = (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher,activity.course)) %> diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index b97cdfcfe..3eab57256 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -106,7 +106,7 @@ <% end %> <% end %> <%# end %> -<% if user_activities.count == 10%> +<% if user_activities.count == 5%>