Remove publish validator. Add can_cancel/can_publish checking to cancel/publish methods. Refs #80
This commit is contained in:
parent
687fa3e000
commit
96d458875e
|
@ -12,9 +12,6 @@ class BuildList < ActiveRecord::Base
|
||||||
validate lambda {
|
validate lambda {
|
||||||
errors.add(:bpl, I18n.t('flash.build_list.wrong_platform')) if pl.platform_type == 'main' && pl_id != bpl_id
|
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
|
# The kernel does not send these statuses directly
|
||||||
BUILD_CANCELED = 5000
|
BUILD_CANCELED = 5000
|
||||||
|
@ -111,9 +108,9 @@ class BuildList < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def publish
|
def publish
|
||||||
|
return false unless can_publish?
|
||||||
has_published = BuildServer.publish_container bs_id
|
has_published = BuildServer.publish_container bs_id
|
||||||
update_attribute(:status, BUILD_PUBLISH) if has_published == 0
|
update_attribute(:status, BUILD_PUBLISH) if has_published == 0
|
||||||
|
|
||||||
return has_published == 0
|
return has_published == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -122,9 +119,9 @@ class BuildList < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def cancel
|
def cancel
|
||||||
|
return false unless can_cancel?
|
||||||
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
|
||||||
|
|
||||||
return has_canceled == 0
|
return has_canceled == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue