针对实训子项目,一些权限修改

This commit is contained in:
huang 2017-02-23 17:23:52 +08:00
parent 705f94428e
commit 019ce762f8
4 changed files with 19 additions and 13 deletions

View File

@ -837,6 +837,9 @@ class ProjectsController < ApplicationController
if @project.training_tasks.count == 0 if @project.training_tasks.count == 0
@notice = "实训开启失败:请先发布实训任务" @notice = "实训开启失败:请先发布实训任务"
return return
elsif Repository.where(:project_id => @project.id, :type => "Repository::Gitlab").count == 0
@notice = "实训开启失败:请先创建版本库"
return
end end
jobName = "#{@project.id}" jobName = "#{@project.id}"
pipeLine = "#{Base64.encode64(@project.script)}" pipeLine = "#{Base64.encode64(@project.script)}"
@ -856,7 +859,11 @@ class ProjectsController < ApplicationController
end end
# TrainintTask.status 0评测中 1评测成功 2评测惊醒中 # TrainintTask.status 0评测中 1评测成功 2评测惊醒中
# 非项目成员、非实训子项目不允许执行该方法
def task_execute def task_execute
if !@project.is_child_training_project? || !User.current.member_of?(@project)
return render_403
end
taskId = params[:training_task_id] taskId = params[:training_task_id]
jobName = @project.forked_from_project_id jobName = @project.forked_from_project_id
@training_task = TrainingTask.find(taskId) @training_task = TrainingTask.find(taskId)
@ -938,7 +945,7 @@ class ProjectsController < ApplicationController
training_task.author_id = User.current.id training_task.author_id = User.current.id
if training_task.save if training_task.save
respond_to do |format| respond_to do |format|
format.html{redirect_to project_training_tasks_url(:project_id => new_training_project_id)} format.html{redirect_to project_url(new_training_project_id)}
end end
else else
raise "create task failed" raise "create task failed"

View File

@ -46,9 +46,12 @@
<div class="mb10" style="font-weight:normal;"> <div class="mb10" style="font-weight:normal;">
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %> <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
</div> </div>
<div id="training_project_task_status_<%= activity.id %>"> <% if @project.is_child_training_project? %>
<%= render :partial => "training_tasks/action_status", :locals => {:activity => activity} %> <div id="training_project_task_status_<%= activity.id %>">
</div> <%= render :partial => "training_tasks/action_status", :locals => {:activity => activity} %>
</div>
<% end %>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>

View File

@ -5,7 +5,9 @@
<% elsif activity.status == 2 %> <% elsif activity.status == 2 %>
<span class="task-display-span alert-blue mt10">当前任务正在后台测评中,稍后将显示您的任务完成情况......</span> <span class="task-display-span alert-blue mt10">当前任务正在后台测评中,稍后将显示您的任务完成情况......</span>
<% else %> <% else %>
<%= link_to "提交评测", task_execute_project_path(@project, :training_task_id => activity.id), :class => "task-display-span bBlue mt10", :remote => true %> <% if User.current.member_of?(@project) && @project.is_child_training_project? %>
<%= link_to "提交评测", task_execute_project_path(@project, :training_task_id => activity.id), :class => "task-display-span bBlue mt10", :remote => true %>
<% end %>
<% end %> <% end %>
</div> </div>

View File

@ -26,18 +26,12 @@
</div> </div>
</td> </td>
<td > <td >
<% if activity.journals.count != 0 %> <% if true %>
<a href="javascript:void(0);" class="issues_icons_mes fl mr5 ml5 "></a> <a href="javascript:void(0);" class="issues_icons_mes fl mr5 ml5 "></a>
<a href="javascript:void(0);" class="fl mt2"><%= activity.journals.count %></a> <a href="javascript:void(0);" class="fl mt2"><%= activity.journals.count %></a>
<% end %> <% end %>
</td> </td>
<td>
<% if @project.is_child_training_project? %>
<div id="task_action_status_<%= activity.id %>">
<%= render :partial => 'action_status', :locals => {:activity => activity} %>
</div>
<% end %>
</td>
</tr> </tr>
<% end %> <% end %>