From db7a6f892ff1c036a3f6ecb36758c67fc02a5621 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 1 Feb 2013 17:49:48 +0400 Subject: [PATCH] #881: add validation --- app/models/build_list.rb | 5 +++++ config/locales/models/build_list.en.yml | 1 + config/locales/models/build_list.ru.yml | 1 + db/schema.rb | 2 +- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index bc2576125..552f18973 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -42,6 +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 + } 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 c53208d3b..556ea38ad 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -144,6 +144,7 @@ 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 ea2ac63c9..dc96d27b6 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -143,6 +143,7 @@ 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/schema.rb b/db/schema.rb index e9652db41..a179946c6 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" + t.boolean "use_save_to_repository", :default => false end add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"