局部刷新测试
This commit is contained in:
parent
7763ce0d66
commit
3582f70a6b
|
@ -901,17 +901,15 @@ class ProjectsController < ApplicationController
|
|||
uri = URI.parse("http://123.59.135.74:9999/jenkins-exec/api/buildJob")
|
||||
begin
|
||||
res = uri_exec uri, params
|
||||
# 任务开启成功后创建一条留言提示,并发布
|
||||
# @training_task.update_attribute(:status, 2)
|
||||
# 轮询获取
|
||||
for i in 0..8 do
|
||||
for i in 0..60 do
|
||||
sleep(1)
|
||||
result = TrainingTask.where(:id => @training_task.id).first.try(:result)
|
||||
if (result != 0)
|
||||
break
|
||||
end
|
||||
end
|
||||
@training_task = TrainingTask.find(@training_task.id)
|
||||
# @training_task = TrainingTask.find(@training_task.id)
|
||||
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'TrainingTask','Message','News', 'Project', 'Attachment','Commit')", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10)
|
||||
rescue Exception => e
|
||||
|
@ -949,7 +947,7 @@ class ProjectsController < ApplicationController
|
|||
forked_count = @project.forked_count.to_i + 1
|
||||
@project.update_attributes(:forked_count => forked_count)
|
||||
# 发布实训任务,只发布实训任务的第一个
|
||||
publish_training_tasks(@project.id, new_training_project.id, 1)
|
||||
publish_training_tasks(@project.id, new_training_project.id, 1, @project.user_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -979,7 +977,7 @@ class ProjectsController < ApplicationController
|
|||
ActiveRecord::Base.transaction do
|
||||
if position < original_tasks_count
|
||||
# 继续发布下一个任务
|
||||
publish_training_tasks original_project_id, @training_task.project_id, position + 1
|
||||
publish_training_tasks original_project_id, @training_task.project_id, position + 1, original_project.user_id
|
||||
end
|
||||
@training_task.update_attribute(:status, 1)
|
||||
@training_task.update_attribute(:result, 1)
|
||||
|
@ -1009,7 +1007,7 @@ class ProjectsController < ApplicationController
|
|||
|
||||
# 实训开启成功后,发布第一个任务
|
||||
# REDO:失败后提醒用户,及相关处理
|
||||
def publish_training_tasks original_project_id, new_training_project_id, position
|
||||
def publish_training_tasks original_project_id, new_training_project_id, position, user_id
|
||||
original_task = TrainingTask.where(:project_id => original_project_id, :position => position).first
|
||||
training_task = TrainingTask.new
|
||||
training_task.save_attachments(params[:attachments] || (params[:training_task] && params[:training_task][:uploads]))
|
||||
|
@ -1018,13 +1016,12 @@ class ProjectsController < ApplicationController
|
|||
training_task.position = original_task.position
|
||||
training_task.project_id = new_training_project_id
|
||||
training_task.author_id = User.current.id
|
||||
if training_task.save
|
||||
respond_to do |format|
|
||||
format.html{redirect_to project_url(new_training_project_id)}
|
||||
end
|
||||
else
|
||||
raise "create task failed"
|
||||
begin
|
||||
training_task.save
|
||||
rescue Exception => e
|
||||
puts e
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# 复制项目
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<%= render :partial => 'projects/act_messages', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :is_course => 1, :is_board => 0} %>
|
||||
<!--Attachment -->
|
||||
<% when "Attachment" %>
|
||||
<%= render :partial => 'projects/project_attachment', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %>
|
||||
<%#= render :partial => 'projects/project_attachment', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %>
|
||||
<% when "Commit" %>
|
||||
<%= render :partial => 'projects/project_commit', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :identifier => get_rep_identifier_by_project(@project) } %>
|
||||
<% end %>
|
||||
|
|
|
@ -1 +1 @@
|
|||
$("#task_action_status_<%= @training_task.id %>").html('<%= escape_javascript( render :partial => 'training_tasks/action_status', :locals => {:activity => @training_task}) %>');
|
||||
alert("test");
|
Loading…
Reference in New Issue