|
|
|
@ -19,14 +19,14 @@ class ShixunsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish,
|
|
|
|
|
:shixun_members_added, :change_manager, :collaborators_delete,
|
|
|
|
|
:cancel_publish, :add_collaborators, :add_file]
|
|
|
|
|
:cancel_apply_public, :cancel_publish, :add_collaborators, :add_file]
|
|
|
|
|
before_action :portion_allowed, only: [:copy]
|
|
|
|
|
|
|
|
|
|
before_action :special_allowed, only: [:send_to_course, :search_user_courses]
|
|
|
|
|
|
|
|
|
|
## 获取课程列表
|
|
|
|
|
def index
|
|
|
|
|
@shixuns = current_laboratory.shixuns.unhidden
|
|
|
|
|
@shixuns = current_laboratory.shixuns.unhidden.publiced
|
|
|
|
|
|
|
|
|
|
## 方向
|
|
|
|
|
if params[:tag_level].present? && params[:tag_id].present?
|
|
|
|
@ -818,6 +818,7 @@ class ShixunsController < ApplicationController
|
|
|
|
|
@status = 0
|
|
|
|
|
@position = []
|
|
|
|
|
begin
|
|
|
|
|
unless @shixun.is_jupyter?
|
|
|
|
|
if @shixun.challenges.count == 0
|
|
|
|
|
@status = 4
|
|
|
|
|
else
|
|
|
|
@ -836,8 +837,10 @@ class ShixunsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if @status == 0
|
|
|
|
|
@shixun.update_attributes!(:status => 1)
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
@shixun.update_attributes!(:status => 2)
|
|
|
|
|
apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first
|
|
|
|
|
if apply && apply.status == 0
|
|
|
|
|
@status = 0
|
|
|
|
@ -851,6 +854,7 @@ class ShixunsController < ApplicationController
|
|
|
|
|
@status = 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
logger.error("pushlish game #{e}")
|
|
|
|
|
end
|
|
|
|
@ -993,14 +997,24 @@ class ShixunsController < ApplicationController
|
|
|
|
|
:disposition => 'attachment' #inline can open in browser
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 撤销发布
|
|
|
|
|
def cancel_publish
|
|
|
|
|
tip_exception("实训已经发布,无法撤销") if @shixun.status == 2
|
|
|
|
|
# 撤销申请公开
|
|
|
|
|
def cancel_apply_public
|
|
|
|
|
tip_exception("实训已经公开,无法撤销") if @shixun.public == 2
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
apply = ApplyAction.where(:container_type => "ApplyShixun", :container_id => @shixun.id).order("created_at desc").first
|
|
|
|
|
if apply && apply.status == 0
|
|
|
|
|
apply.update_attribute(:status, 3)
|
|
|
|
|
apply.tidings.destroy_all
|
|
|
|
|
apply.update_attributes!(status: 3)
|
|
|
|
|
apply.tidings&.destroy_all
|
|
|
|
|
end
|
|
|
|
|
@shixun.update_column(:public, 0)
|
|
|
|
|
end
|
|
|
|
|
normal_status(0, "成功撤销申请")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 撤销发布
|
|
|
|
|
def cancel_publish
|
|
|
|
|
tip_exception("请先撤销申请公开,再撤销发布") if @shixun.public == 1
|
|
|
|
|
tip_exception("实训已经公开,无法撤销") if @shixun.public == 2
|
|
|
|
|
@shixun.update_column(:status, 0)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|