From 70940aa38bdf65076ab557f72c04d10a2f15e028 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 30 Jun 2017 14:04:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=BC=80=E5=90=AF=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=B8=8D=E5=90=88=E7=90=86=E5=A4=84=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E6=88=90=E7=82=B9=E5=87=BB=E5=90=8E=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=8F=8A=E5=BC=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 7 +++++++ app/views/shixuns/_shixun_top.html.erb | 9 ++++++--- app/views/shixuns/operation.js.erb | 12 ++++++++++++ config/routes.rb | 1 + 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 app/views/shixuns/operation.js.erb 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]