Rename delete_build_list to cancel_build_list. Rescue XML get_status exception. Refs #2261

This commit is contained in:
Pavel Chipiga 2011-12-01 00:55:47 +02:00
parent 4ea4d7f56e
commit e45ba6692a
5 changed files with 6 additions and 34 deletions

View File

@ -20,14 +20,14 @@ class BuildListsController < ApplicationController
end end
@action_url = all_build_lists_path @action_url = all_build_lists_path
@build_server_status = BuildServer.get_status @build_server_status = BuildServer.get_status rescue {}
render :action => 'index' render :action => 'index'
end end
def cancel def cancel
build_list = BuildList.find(params[:id]) build_list = BuildList.find(params[:id])
if build_list.delete_build_list if build_list.cancel_build_list
redirect_to :back, :notice => t('layout.build_lists.cancel_successed') redirect_to :back, :notice => t('layout.build_lists.cancel_successed')
else else
redirect_to :back, :notice => t('layout.build_lists.cancel_failed') redirect_to :back, :notice => t('layout.build_lists.cancel_failed')

View File

@ -112,7 +112,7 @@ class BuildList < ActiveRecord::Base
self.status == BuildServer::SUCCESS self.status == BuildServer::SUCCESS
end end
def delete_build_list def cancel_build_list
has_canceled = BuildServer.delete_build_list bs_id has_canceled = BuildServer.delete_build_list bs_id
update_attribute(:status, BUILD_CANCELED) if has_canceled == 0 update_attribute(:status, BUILD_CANCELED) if has_canceled == 0
@ -120,7 +120,7 @@ class BuildList < ActiveRecord::Base
end end
#TODO: Share this checking on product owner. #TODO: Share this checking on product owner.
def can_canceled? def can_cancel?
self.status == BUILD_PENDING && bs_id self.status == BUILD_PENDING && bs_id
end end

View File

@ -19,7 +19,7 @@
%td= build_list.arch.name %td= build_list.arch.name
%td= t("layout.#{build_list.is_circle?}_") %td= t("layout.#{build_list.is_circle?}_")
- if controller.action_name = 'all' - if controller.action_name = 'all'
%td= link_to t("layout.build_lists.cancel_button"), build_list_cancel_path(build_list) if build_list.can_canceled? %td= link_to t("layout.build_lists.cancel_button"), build_list_cancel_path(build_list) if build_list.can_cancel?
%td.last= build_list.notified_at %td.last= build_list.notified_at
= will_paginate build_lists = will_paginate build_lists

View File

@ -1,28 +0,0 @@
/ .block
/ - if controller.action_name != 'all'
/ .secondary-navigation
/ %ul.wat-cf
/ %li.first= link_to t("layout.build_lists.current"), project_path(@project) + "#build_lists"
/ %li.active= link_to t("layout.build_lists.all"), project_build_lists_path(@project)
/
/ .content
/ - if controller.action_name == 'all'
/ .inner
/ %h2= t('layout.build_lists.build_server_status.header')
/ .field
/ %span= t('layout.build_lists.build_server_status.client_count') + ":"
/ %span= @build_server_status['client_count']
/ .field
/ %span= t('layout.build_lists.build_server_status.count_new_task') + ":"
/ %span= @build_server_status['count_new_task']
/ .field
/ %span= t('layout.build_lists.build_server_status.count_build_task') + ":"
/ %span= @build_server_status['count_build_task']
/
/ .inner
/ = render :partial => "build_lists/filter", :action_url => @action_url
/
/ .inner
/ = render :partial => "build_lists/build_lists", :object => @build_lists
/
/ - content_for :sidebar, render(:partial => 'sidebar') if controller.action_name != 'all'

View File

@ -32,7 +32,7 @@ module XMLRPC
# raise args.inspect # raise args.inspect
case case
when args.first == 'get_status' when args.first == 'get_status'
{:client_count => '1', :count_new_task => '2', :count_build_task => 3} {'client_count' => 1, 'count_new_task' => 2, 'count_build_task' => 3}
else; 0 else; 0
end end
end end