#881: add validation

This commit is contained in:
Vokhmin Alexey V 2013-02-01 17:49:48 +04:00
parent 2a2385dc53
commit db7a6f892f
4 changed files with 8 additions and 1 deletions

View File

@ -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,

View File

@ -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

View File

@ -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: Выберите какую-нибудь версию

View File

@ -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"