diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 0100d8f12..d4a43df2e 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -138,8 +138,7 @@ class Projects::BuildListsController < Projects::BaseController else results.concat Repository.where(:id => extra_repos).accessible_by(current_ability, :read) end - results.concat build_lists - render :partial => 'extra', :collection => results + render :partial => 'extra', :collection => results.concat(build_lists) end protected diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 5005f4271..09cfd1b77 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -42,9 +42,8 @@ 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 :check_extra_repositories, :on => :create - validate :check_extra_containers, :on => :create - before_validation :prepare_extra_repositories_and_containers, :on => :create + before_validation :prepare_extra_repositories, :on => :create + before_validation :prepare_extra_containers, :on => :create before_create :use_save_to_repository_for_main_platforms @@ -476,28 +475,19 @@ class BuildList < ActiveRecord::Base @current_ability ||= Ability.new(user) end - def check_extra_repositories - if extra_repositories.present? && user - repos_count = Repository.where(:id => extra_repositories). - accessible_by(current_ability, :read).count - errors.add(:extra_repositories, I18n.t('flash.build_list.wrong_extra_repositories')) if repos_count != extra_repositories.count + def prepare_extra_repositories + if save_to_platform && save_to_platform.main? + self.extra_repositories = nil + else + self.extra_repositories = Repository.where(:id => extra_repositories). + accessible_by(current_ability, :read).pluck(:id) end end - def check_extra_containers - if extra_containers.present? && user - bls_count = BuildList.where(:id => extra_containers). - published_container.accessible_by(current_ability, :read).count - errors.add(:extra_containers, I18n.t('flash.build_list.wrong_extra_containers')) if bls_count != extra_containers.count - end + def prepare_extra_containers + bls = BuildList.where(:id => extra_containers).published_container.accessible_by(current_ability, :read) + bls = bls.where(:save_to_platform_id => save_to_platform.id) if save_to_platform && save_to_platform.main? + self.extra_containers = bls.pluck(:id) end - def prepare_extra_repositories_and_containers - if save_to_repository && save_to_repository.platform.main? - self.extra_repositories = self.extra_containers = nil - end - self.extra_repositories = extra_repositories.uniq if extra_repositories.present? - self.extra_containers = extra_containers.uniq if extra_containers.present? - end - -end +end \ No newline at end of file diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 3f322b5e4..6d1940063 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -162,6 +162,4 @@ en: can_not_published: Build can only be published with status "Build complete" frozen_platform: In case of a repository for package storage with frozen platform allowed only bugfix and security updates wrong_include_repos: Include repos have to belongs to build for platform - wrong_commit_hash: Unable find commit '%{commit_hash}' in project - wrong_extra_repositories: Some repositories does not exist - wrong_extra_containers: Some containers does not exist + wrong_commit_hash: Unable find commit '%{commit_hash}' in project \ No newline at end of file diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 62e8a2d7b..5335f628a 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -161,6 +161,4 @@ ru: can_not_published: Опубликовать сборку можно только со статусом "Собран" frozen_platform: В случае выбора репозитория для сохранения пакетов из замороженнной платформы разрешены только bugfix и security обновления wrong_include_repos: Включаемые репозитории должны принадлежать платформе для сборки - wrong_commit_hash: Невозможно найти коммит '%{commit_hash}' в проекте - wrong_extra_repositories: Некоторые репозитории не существуют - wrong_extra_containers: Некоторые контейнеры не существуют + wrong_commit_hash: Невозможно найти коммит '%{commit_hash}' в проекте \ No newline at end of file