diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f47ba446e..178a82d17 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -725,6 +725,12 @@ class ApplicationController < ActionController::Base #查找首页相关信息 def find_first_page @first_page = FirstPage.where("page_type = 'project'").first + if @first_page.nil? + @first_page = FirstPage.new + @first_page.page_type = 'project' + @first_page.description = "" + @first_page.save() + end @show_course = @first_page.show_course @show_contest = @first_page.show_contest end diff --git a/app/controllers/trackers_controller.rb b/app/controllers/trackers_controller.rb index 94131a2e0..de686493b 100644 --- a/app/controllers/trackers_controller.rb +++ b/app/controllers/trackers_controller.rb @@ -17,7 +17,7 @@ class TrackersController < ApplicationController layout 'admin' - + helper "project_score" before_filter :require_admin, :except => :index before_filter :require_admin_or_api_request, :only => :index accept_api_auth :index @@ -38,6 +38,7 @@ class TrackersController < ApplicationController @tracker ||= Tracker.new(params[:tracker]) @trackers = Tracker.sorted.all @projects = Project.all + @courses = Course.all end def create diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index eaa96e82a..98b24bc12 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -295,8 +295,8 @@ class UsersController < ApplicationController # 活跃度排序, 就是所谓的得分情况 @s_type = 1 @users = scope. - joins("LEFT JOIN user_scores ON users.id = user_scores.user_id"). - reorder('user_scores.active DESC') + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') when '2' # 粉丝数排序 @s_type = 2 @@ -308,8 +308,8 @@ class UsersController < ApplicationController # 默认活跃度排序 @s_type = 1 @users = scope. - joins("LEFT JOIN user_scores ON users.id = user_scores.user_id"). - reorder('user_scores.active DESC') + joins("LEFT JOIN option_numbers ON users.id = option_numbers.user_id and option_numbers.score_type = 1"). + reorder('option_numbers.total_score DESC') end # limit and offset diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 80b4e3576..4e7cf0ce9 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -20,11 +20,12 @@ class WelcomeController < ApplicationController include WelcomeHelper helper :project_score caches_action :robots + before_filter :find_first_page, :only => [:index] # before_filter :fake, :only => [:index, :course] before_filter :entry_select, :only => [:index] def index - @first_page = FirstPage.where("page_type = 'project'").first + #@first_page = FirstPage.where("page_type = 'project'").first #@show_course = @first_page.show_course if @first_page.nil? || @first_page.sort_type.nil? @projects = find_miracle_project(10, 3,"score desc") @@ -76,7 +77,7 @@ class WelcomeController < ApplicationController logo = get_avatar?(@course_page) id = params[:school_id] logo_link = "" - if id.nil? && User.current.user_extensions.school.nil? + if id.nil? && (User.current.user_extensions.nil? || User.current.user_extensions.school.nil?) if logo logo_link = url_to_avatar(@course_page) else @@ -148,8 +149,8 @@ class WelcomeController < ApplicationController private # 判断网站的入口,是课程 course 则跳过index去渲染 course 方法 def entry_select - @first_page = FirstPage.where("page_type = 'project'").first - url = request.original_url + #@first_page = FirstPage.where("page_type = 'project'").first + url = request.original_url.gsub('/','') if url.include?(Setting.host_course) if @first_page.show_course == 1 course diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index a5506be93..10aa39df2 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -54,7 +54,7 @@ class ZipdownController < ApplicationController end rescue => e - render file: 'public/file_not_found.html' + render file: 'public/file_not_found.html' , :layout => 'course_base' end private diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index 3a7a6a8ee..3116a9a68 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -44,11 +44,11 @@ <% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%> <% hasCourse=true%> -
  • <%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %> +
  • <%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id} %> diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index eea7a0f61..d8eb17acd 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -54,7 +54,7 @@