diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 552f18973..c53e80a0f 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -26,10 +26,10 @@ class BuildList < ActiveRecord::Base validates :update_type, :inclusion => {:in => RELEASE_UPDATE_TYPES, :message => I18n.t('flash.build_list.frozen_platform')}, :if => Proc.new { |b| b.advisory.present? } validate lambda { - errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_platform')) if save_to_platform.platform_type == 'main' && save_to_platform_id != build_for_platform_id + errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_platform')) if save_to_platform.main? && save_to_platform_id != build_for_platform_id } validate lambda { - errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_build_for_platform')) unless build_for_platform.platform_type == 'main' + errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_build_for_platform')) unless build_for_platform.main? } validate lambda { errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_repository')) unless save_to_repository_id.in? save_to_platform.repositories.map(&:id) @@ -42,11 +42,11 @@ class BuildList < ActiveRecord::Base validate lambda { errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_project')) unless save_to_repository.projects.exists?(project_id) } - validate lambda { - if save_to_platform.main? && use_save_to_repository - errors.add(:use_save_to_repository, I18n.t('flash.build_list.wrong_disable_repository')) - end - } + + before_create do |build_list| + build_list.use_save_to_repository = false if save_to_platform.main? + nil + end attr_accessible :include_repos, :auto_publish, :build_for_platform_id, :commit_hash, :arch_id, :project_id, :save_to_repository_id, :update_type, diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 556ea38ad..c53208d3b 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -144,7 +144,6 @@ en: flash: build_list: - wrong_disable_repository: Repository to save package may be disabled only for personal platform. saved: Build list for project version '%{project_version}', platform '%{build_for_platform}' and architecture '%{arch}' has been created successfully save_error: Build list for project version '%{project_version}', platform '%{build_for_platform}' and architecture '%{arch}' could not been created no_project_version_selected: Select any version of the project diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index dc96d27b6..ea2ac63c9 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -143,7 +143,6 @@ ru: flash: build_list: - wrong_disable_repository: Репозиторий для сохранения может быть отключен только для персональной платформы. saved: Билд лист для версии '%{project_version}', платформы '%{build_for_platform}' и архитектуры '%{arch}' создан успешно save_error: Не удалось сохранить билд лист для версии '%{project_version}', платформы '%{build_for_platform}' и архитектуры '%{arch}' no_project_version_selected: Выберите какую-нибудь версию diff --git a/db/migrate/20130201094007_add_use_personal_repository_to_build_list.rb b/db/migrate/20130201094007_add_use_personal_repository_to_build_list.rb index 16f39875d..ae24ae61e 100644 --- a/db/migrate/20130201094007_add_use_personal_repository_to_build_list.rb +++ b/db/migrate/20130201094007_add_use_personal_repository_to_build_list.rb @@ -1,5 +1,5 @@ class AddUsePersonalRepositoryToBuildList < ActiveRecord::Migration def change - add_column :build_lists, :use_save_to_repository, :boolean, :default => false + add_column :build_lists, :use_save_to_repository, :boolean, :default => true end end diff --git a/db/schema.rb b/db/schema.rb index a179946c6..d8d8791d0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -133,7 +133,7 @@ ActiveRecord::Schema.define(:version => 20130201094007) do t.boolean "new_core", :default => true t.string "last_published_commit_hash" t.integer "container_status" - t.boolean "use_save_to_repository", :default => false + t.boolean "use_save_to_repository", :default => true end add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"