Remove publish validator. Add can_cancel/can_publish checking to cancel/publish methods. Refs #80

This commit is contained in:
Pavel Chipiga 2011-12-22 04:08:11 +02:00
parent 687fa3e000
commit 96d458875e
1 changed files with 3 additions and 6 deletions

View File

@ -12,9 +12,6 @@ class BuildList < ActiveRecord::Base
validate lambda {
errors.add(:bpl, I18n.t('flash.build_list.wrong_platform')) if pl.platform_type == 'main' && pl_id != bpl_id
}
validate lambda {
errors.add(:bpl, I18n.t('flash.build_list.can_not_published')) if status == BUILD_PUBLISHED && status_was != BuildServer::SUCCESS
}
# The kernel does not send these statuses directly
BUILD_CANCELED = 5000
@ -111,9 +108,9 @@ class BuildList < ActiveRecord::Base
end
def publish
return false unless can_publish?
has_published = BuildServer.publish_container bs_id
update_attribute(:status, BUILD_PUBLISH) if has_published == 0
return has_published == 0
end
@ -122,9 +119,9 @@ class BuildList < ActiveRecord::Base
end
def cancel
return false unless can_cancel?
has_canceled = BuildServer.delete_build_list bs_id
update_attribute(:status, BUILD_CANCELED) if has_canceled == 0
return has_canceled == 0
end