From d001b4416aee9c2c9455f3b593949bc5e631aa06 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 4 Jul 2014 09:10:17 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E8=AF=BE=E7=A8=8B=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=202.=E4=BC=98=E5=8C=96=E8=AF=BE=E7=A8=8B=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E6=90=9C=E7=B4=A2=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/welcome_controller.rb | 2 +- app/helpers/welcome_helper.rb | 5 + app/views/welcome/course.html.erb | 163 +++++++++++++------------- 3 files changed, 89 insertions(+), 81 deletions(-) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index f16dbd97f..7c60e2dc3 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -32,7 +32,7 @@ class WelcomeController < ApplicationController def course if params[:school_id] @school_id = params[:school_id] - else + elsif User.current.logged? && User.current.user_extensions.school @school_id = User.current.user_extensions.school.id end @logoLink ||= logolink() diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 0054b003f..1004a49ad 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -233,8 +233,13 @@ module WelcomeHelper def find_all_new_hot_course limit = 9 ,school_id = 0 #sort_project_by_hot_rails 1, 'course_ac_para DESC', limit time_now = Time.new.strftime("%Y"); + if school_id courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <> ?", school_id).order("course_ac_para DESC").limit(limit).all + else + courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL + ").order("course_ac_para DESC").limit(limit).all + end courses end diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 9a25d9dbf..e79cc12cf 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -3,26 +3,25 @@