diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 0e36a10fe..bade03b03 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -450,6 +450,13 @@ class ShixunsController < ApplicationController end end + # 实训行为操作 + def operation + @myshixun = Myshixun.where(:id => params[:myshixun_id]).first + @is_modify = ShixunModify.where(:myshixun_id => params[:myshixun_id], :shixun_id => @shixun.try(:id), :status => 1).first + @mail = User.current.mail.blank? + end + private # REDO: 新增类型copy的时候 # 复制项目 diff --git a/app/views/shixuns/_shixun_top.html.erb b/app/views/shixuns/_shixun_top.html.erb index bc67a0678..3834166e3 100644 --- a/app/views/shixuns/_shixun_top.html.erb +++ b/app/views/shixuns/_shixun_top.html.erb @@ -9,18 +9,21 @@ <% if allow_shixun_exec(@shixun) %> <% if @shixun.status == 0 %> <% if User.current.manager_of_shixun?(@shixun) %> - <%= link_to_shixun_exec myshixun, @shixun, '模拟实战' %> + <%= link_to "模拟实战", operation_shixun_path(@shixun, :myshixun_id => myshixun.try(:id)), :class => "fr shixun-task-btn task-btn-orange mr15", :remote => true %> + <%#= link_to_shixun_exec myshixun, @shixun, '模拟实战' %> 申请发布 <%#= link_to "申请发布", publish_shixun_path(@shixun), :class => "fr shixun-task-btn task-btn-green mr15", :id => "challenge_begin", :remote => true %> <% end %> <% elsif @shixun.status == 1 %> - <%= link_to_shixun_exec myshixun, @shixun, '模拟实战' %> + <%= link_to "模拟实战", operation_shixun_path(@shixun, :myshixun_id => myshixun.try(:id)), :class => "fr shixun-task-btn task-btn-orange mr15", :remote => true %> + <%#= link_to_shixun_exec myshixun, @shixun, '模拟实战' %> <% if User.current.manager_of_shixun?(@shixun) %> <%= link_to "撤销发布", cancel_publish_shixun_path(@shixun), :class => "fr shixun-task-btn task-btn-grey-white mr15", :id => "challenge_begin" %> <% end %> <% elsif @shixun.status == 2 %> <% if myshixun.blank? %> - <%= link_to_shixun_exec myshixun, @shixun, '开始实战' %> + <%= link_to "开始实战", operation_shixun_path(@shixun, :myshixun_id => myshixun.try(:id)), :class => "fr shixun-task-btn task-btn-orange mr15", :remote => true %> + <%#= link_to_shixun_exec myshixun, @shixun, '开始实战' %> <% else %> <%= link_to "继续实战", myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun), :class => "fr shixun-task-btn task-btn-orange mr15", :id => "challenge_begin", :target => "_blank"%> <% end %> diff --git a/app/views/shixuns/operation.js.erb b/app/views/shixuns/operation.js.erb new file mode 100644 index 000000000..da5fe0fa3 --- /dev/null +++ b/app/views/shixuns/operation.js.erb @@ -0,0 +1,12 @@ +<% if @mail %> +notice_box_redirect('#{security_settings_path}', '开启实训,请先绑定邮箱') +<% else %> +<% if @is_modify.blank? %> +//为了防止浏览器阻挡 +var tempwindow = window.open(); +tempwindow.location = '<%= shixun_exec_shixun_path(@shixun) %>'; +//window.open("<%#= shixun_exec_shixun_path(@shixun) %>"); +<% else %> +sure_box_redirect('<%= myshixun_reset_myshixun_path(@myshixun) %>', '实训已经更新啦,系统正在为您重置') +<% end %> +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index de696c186..fde690704 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -54,6 +54,7 @@ RedmineApp::Application.routes.draw do get 'apply_publish' get 'cancel_publish' get 'close' + get 'operation' end collection do match 'search', :via => [:get, :post]