diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index ec52390e6..4fd84d586 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -21,7 +21,7 @@ class ShixunsController < ApplicationController end def index - @shixuns = Shixun.where(:status => 2) + @shixuns = Shixun.where(:authentication => 1).order('updated_at desc') @shixun_my_score = Game.sum(:final_score) @current_user_had_passed = Myshixun.where(:status => 1).count @shixuns_count = @shixuns.count @@ -30,7 +30,16 @@ class ShixunsController < ApplicationController def shixun_search # 确定 sort 1升序 2 降序 - @order, @sort, @type = params[:order] || 1, params[:sort] || 1, params[:type] || 1 + if params[:time_reorder] + order = "#{Shixun.table_name}.updated_at #{params[:time_reorder]}" + elsif params[:hot_reorder] + order = "shixun_count #{params[:hot_reorder]}, #{Shixun.table_name}.updated_at #{params[:hot_reorder]}" + else + order = "#{Shixun.table_name}.updated_at desc" + end + + # @order, @sort, @type = params[:order] || 1, params[:sort] || 1, params[:type] || 1 +=begin if @order.to_i == @type.to_i @sort = (@sort.to_i == 1 ? 2 : 1) else @@ -38,9 +47,15 @@ class ShixunsController < ApplicationController end sort_name = "updated_on" sort_type = @sort == 1 ? "asc" : "desc" - @shixuns = Shixun.where(:status => 2).reorder() +=end + @shixuns = Shixun.where(:authentication => 1).reorder(order) +=begin order = params[:sort] @shixuns = Shixun.where(:status => 2).order("#{order.nil? ? 'created_at' : order} desc") +=end + respond_to do |format| + format.js + end end # jenkins回调脚本 diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 9cd7c320a..001a922db 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -1,6 +1,6 @@ # status 控制实训的状态,0:未开启;1: 已开启(TPM); 2:已认证 class Shixun < ActiveRecord::Base - attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language, :identifier + attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language, :identifier, :authentication, :hixun_count has_many :users, :through => :shixun_members has_many :shixun_members diff --git a/app/views/shixuns/index.html.erb b/app/views/shixuns/index.html.erb index 99161ff15..6975a3e1f 100644 --- a/app/views/shixuns/index.html.erb +++ b/app/views/shixuns/index.html.erb @@ -1,4 +1,4 @@ -