Merge branches 'dev_aliyun' and 'dev_jupyter' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_jupyter

chromesetting
杨树明 5 years ago
commit 4ca2f980c2

@ -1,8 +1,8 @@
class HacksController < ApplicationController class HacksController < ApplicationController
before_action :require_login, except: [:index] before_action :require_login, except: [:index]
before_action :find_hack, only: [:edit, :update, :publish, :start, :update_set, :delete_set, :destroy] before_action :find_hack, only: [:edit, :update, :publish, :start, :update_set, :delete_set, :destroy, :cancel_publish]
before_action :require_teacher_identity, only: [:create] before_action :require_teacher_identity, only: [:create]
before_action :require_auth_identity, only: [:update, :edit, :publish, :update_set, :delete_set, :destroy] before_action :require_auth_identity, only: [:update, :edit, :publish, :update_set, :delete_set, :destroy, :cancel_publish]
# 开启编程,如果第一次开启,创建一条记录,如果已经开启过的话,直接返回标识即可 # 开启编程,如果第一次开启,创建一条记录,如果已经开启过的话,直接返回标识即可
@ -99,6 +99,12 @@ class HacksController < ApplicationController
render_ok render_ok
end end
# 取消发布
def cancel_publish
@hack.update_attribute(:status, 0)
render_ok
end
# 发布列表 # 发布列表
def unpulished_list def unpulished_list
limit = params[:limit] || 16 limit = params[:limit] || 16

@ -1,5 +1,5 @@
json.hack do json.hack do
json.(@hack, :name, :difficult, :time_limit, :description, :score, :identifier) json.(@hack, :name, :difficult, :time_limit, :description, :score, :identifier, :status)
json.language @hack.language json.language @hack.language
json.username @hack.user.real_name json.username @hack.user.real_name
json.code @my_hack.code json.code @my_hack.code

@ -8,6 +8,6 @@ end
json.hacks_count @hacks_count json.hacks_count @hacks_count
json.hacks_list do json.hacks_list do
json.array! @hacks do |hack| json.array! @hacks do |hack|
json.(hack,:identifier, :name , :hack_user_lastest_codes_count, :difficult, :passed_rate, :category) json.(hack,:identifier, :name , :hack_user_lastest_codes_count, :difficult, :passed_rate, :category, :open_or_not, :status)
end end
end end

@ -55,6 +55,7 @@ Rails.application.routes.draw do
end end
member do member do
post :publish post :publish
post :cancel_publish
get :start get :start
post :update_set post :update_set
delete :delete_set delete :delete_set

Loading…
Cancel
Save