任务开启的时候权限控制
This commit is contained in:
parent
6bd160d642
commit
49f63992d8
|
@ -770,10 +770,14 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def add_script
|
||||
if @project.update_attribute(:script, params[:project_script])
|
||||
@notice = "脚本添加成功"
|
||||
if User.current.admin? || User.current.member_of?(@project)
|
||||
if @project.update_attribute(:script, params[:project_script])
|
||||
@notice = "脚本添加成功"
|
||||
else
|
||||
@notice = "脚本添加失败"
|
||||
end
|
||||
else
|
||||
@notice = "脚本添加失败"
|
||||
return render_403
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -830,16 +834,17 @@ class ProjectsController < ApplicationController
|
|||
|
||||
# training_status: 默认为0; 1代表实训项目; 2:代表实训子项目
|
||||
def training_project_execute
|
||||
if @project.training_tasks.count == 0
|
||||
@notice = "实训开启失败:请先发布实训任务"
|
||||
return
|
||||
end
|
||||
jobName = "#{@project.id}"
|
||||
pipeLine = "#{Base64.encode64(@project.script)}"
|
||||
uri = URI("http://123.59.135.74:9999/jenkins-exec/api/createJob")
|
||||
res = Net::HTTP.post_form(uri, {jobName: jobName, pipeLine: pipeLine}).body
|
||||
# if res.code == 0
|
||||
|
||||
@project.update_attribute(:training_status, 1)
|
||||
@notice = "实训开启成功"
|
||||
# else
|
||||
# flash[:notice] = "启动失败"
|
||||
# end
|
||||
end
|
||||
|
||||
def training_project_update
|
||||
|
|
|
@ -225,7 +225,7 @@ class Project < ActiveRecord::Base
|
|||
|
||||
# 判断项目是否为实训项目
|
||||
def is_training_project?
|
||||
(self.enabled_modules.where("name = 'training_tasks'").empty? && self.training_status == 1) ? false : true
|
||||
(!self.enabled_modules.where("name = 'training_tasks'").empty? && self.training_status == 1) ? true : false
|
||||
end
|
||||
|
||||
# 判断项目是否为开启实训的项目(eg:学生开启实训)
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
<!--项目fork-->
|
||||
<li class="mr5 fl">
|
||||
<!--实训项目条件:1、modules中选中了实训任务 2、不是fork的项目-->
|
||||
<% if @project.is_training_project? %>
|
||||
<% if @project.is_training_project? && User.current.id != @project.user_id %>
|
||||
<%= link_to "开始实训", training_chiled_project_exec_project_path(@project), :class => "sy_btn_green fr", :remote => true %>
|
||||
<% else %>
|
||||
<%= link_to "<span class='vl_fork'></span>".html_safe+"Fork", forked_pop_project_path(@project),
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<% if User.current.allowed_to?(:manage_repository, @project) %>
|
||||
<li><a href="javascript:void(0)" id="pro_st_tb_6" class="<%= show_memu == 'manage_repository' ? 'active' : ''%>" onclick="project_setting(6);">版本库</a></li>
|
||||
<% end %>
|
||||
<% if @project.is_training_project? %>
|
||||
<% if !@project.enabled_modules.where("name = 'training_tasks'").empty? %>
|
||||
<li><a href="javascript:void(0)" id="pro_st_tb_7" class="<%= show_memu == 'trainig_task' ? 'active' : ''%>" onclick="project_setting(7);">实训任务</a></li>
|
||||
<% end %>
|
||||
<!--<li id="pro_st_tb_7" class="pro_st_normaltab" onclick="project_setting(7);">活动(时间跟踪)</li>-->
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
<div class=" sy_new_tchbox clear ">
|
||||
<div id="training_project_filter_tip">
|
||||
<%= render :partial => "projects/settings/training_projects_filter_tip" %>
|
||||
</div>
|
||||
<div id="training_project_filter_tip">
|
||||
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<div class="clear">
|
||||
|
|
Loading…
Reference in New Issue