From f3f590a8341dd97e3b95eee2bd5973744a933072 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 30 Jan 2015 10:27:21 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=20#=20=E8=BF=99=E5=86=99=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=8F=91=E7=8E=B0=E6=B2=A1=E6=9C=89=E7=94=A8=E8=80=8C=E4=B8=94?= =?UTF-8?q?=E6=8B=96=E6=85=A2=E9=80=9F=E5=BA=A6=20=20=20=20=20#@teachers?= =?UTF-8?q?=3D=20searchTeacherAndAssistant(@course)=20=20=20=20=20#@canSho?= =?UTF-8?q?wRealName=20=3D=20isCourseTeacher(User.current.id,@course)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index e81b57ad7..7653be94d 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -828,6 +828,7 @@ class CoursesController < ApplicationController end def show + # try to redirect to the requested menu item if params[:jump] && redirect_to_course_menu_item(@course, params[:jump]) return @@ -866,6 +867,7 @@ class CoursesController < ApplicationController @activity.scope_select {|t| has["show_#{t}"]} # modify by nwb # 添加私密性判断 + if User.current.member_of_course?(@course)|| User.current.admin? events = @activity.events(@days, @course.created_at) else @@ -890,14 +892,13 @@ class CoursesController < ApplicationController @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} # documents @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' - # - @teachers= searchTeacherAndAssistant(@course) - @canShowRealName = isCourseTeacher(User.current.id,@course) + # 这写变量发现没有用而且拖慢速度 + #@teachers= searchTeacherAndAssistant(@course) + #@canShowRealName = isCourseTeacher(User.current.id,@course) if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id))) @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id) end - respond_to do |format| format.html{render :layout => 'base_courses'} format.api From 078538481341394ce36096fcef1c4b812d62b03f Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 30 Jan 2015 10:28:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug=EF=BC=8C=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=8A=A8=E6=80=81=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/acts_as_activity_provider.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb index f4712fa3e..35d168732 100644 --- a/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb +++ b/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb @@ -98,20 +98,13 @@ module Redmine # Author lizanle # Description 删除 unless scope.all,因为这个执行查询,并且没有加入时间限制,与下边 scope.all(provider_options[:find_options].dup)重复 if options[:course] - if provider_options[:timestamp].include? "updated_on" - to = scope.scoped(:order => "#{provider_options[:timestamp]} desc").all(provider_options[:find_options].dup).first.updated_on - else - to = scope.scoped(:order => "#{provider_options[:timestamp]} desc").all(provider_options[:find_options].dup).first.created_on - end - from = (to - days.days) > created_time ? (to - days.days) : created_time.to_date + scope.all(provider_options[:find_options].dup) else - #from = to - Setting.activity_days_default.to_i - end - - if from && to - scope = scope.scoped(:conditions => ["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to]) + if from && to + scope = scope.scoped(:conditions => ["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to]) + scope.all(provider_options[:find_options].dup) + end end - scope.all(provider_options[:find_options].dup) end # 为了首页获取数据基本复制了上面的方法,改变了用户查看权限,增加了对讨论区的识别。