diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index c274d83db..553bce027 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -115,21 +115,21 @@ class Projects::BuildListsController < Projects::BaseController def autocomplete_to_extra platforms = Platform.includes(:repositories).search(params[:term]).search_order.limit(5) results = [] - platforms.each{ |p| p.repositories.each{ |r| results << {id: r.id, label: "#{p.name}/#{r.name}", value: "#{p.name}/#{r.name}"} } } + platforms.each{ |p| p.repositories.each{ |r| results << {:id => r.id, :label => "#{p.name}/#{r.name}", :value => "#{p.name}/#{r.name}"} } } - bl = BuildList.where(id: params[:term], container_status: BuildList::BUILD_PUBLISHED).first - results << {id: "#{bl.id}-build-list", value: bl.id, label: "#{bl.id} (#{bl.project.name} - #{bl.arch.name})"} if bl + bl = BuildList.where(:id => params[:term], :container_status => BuildList::BUILD_PUBLISHED).first + results << {:id => "#{bl.id}-build-list", :value => bl.id, :label => "#{bl.id} (#{bl.project.name} - #{bl.arch.name})"} if bl render json: results.to_json end def add_extra if params[:extra_id] =~ /-build-list$/ id = params[:extra_id].gsub(/-build-list$/, '') - subject = BuildList.where(id: id, container_status: BuildList::BUILD_PUBLISHED).first + subject = BuildList.where(:id => id, :container_status => BuildList::BUILD_PUBLISHED).first else subject = Repository.find params[:extra_id] end - render partial: 'extra', locals: {subject: subject} + render :partial => 'extra', :locals => {:subject => subject} end protected diff --git a/app/models/build_list.rb b/app/models/build_list.rb index f6883f6f8..e3117cb84 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -42,11 +42,19 @@ 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 { + errors.add(:extra_repositories, I18n.t('flash.build_list.wrong_extra_repositories')) if extra_repositories.present? && Repository.where(:id => extra_repositories).count != extra_repositories.count + }, :on => :create + validate lambda { + errors.add(:extra_containers, I18n.t('flash.build_list.wrong_extra_containers')) if extra_containers.present? && BuildList.where(:id => extra_containers, :container_status => BUILD_PUBLISHED).count != extra_containers.count + }, :on => :create before_validation(:on => :create) do if save_to_repository && save_to_repository.platform.main? self.extra_repositories = nil 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 before_create :use_save_to_repository_for_main_platforms diff --git a/app/views/projects/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml index a2f5044a4..05816217d 100644 --- a/app/views/projects/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -33,10 +33,10 @@ %table.tablesorter{:cellpadding => "0", :cellspacing => "0"} %tbody - Repository.where(id: @build_list.extra_repositories).each do |repo| - = render 'extra', subject: repo + = render 'extra', :subject => repo - BuildList.where(id: @build_list.extra_containers).each do |bl| - = render 'extra', subject: bl + = render 'extra', :subject => bl %h3= t("activerecord.attributes.build_list.preferences") - [:auto_publish, :auto_create_container, :use_save_to_repository].each do |kind| diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 45a967747..026c22619 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -75,9 +75,9 @@ - if @build_list.extra_containers.present? || @build_list.extra_repositories.present? .leftlist= t("activerecord.attributes.build_list.extra_repos") .rightlist - - Repository.where(id: @build_list.extra_repositories).each do |repo| + - Repository.where(:id => @build_list.extra_repositories).each do |repo| %p= link_to "#{repo.platform.name}/#{repo.name}", [repo.platform, repo] - - BuildList.where(id: @build_list.extra_containers).each do |bl| + - BuildList.where(:id => @build_list.extra_containers).each do |bl| %p= link_to "#{bl.id} (#{bl.project.name} - #{bl.arch.name})", bl .both diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index cc0ce1ff7..a32f1bc52 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -163,3 +163,5 @@ en: 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 diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index a4c079e05..196463794 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -162,3 +162,5 @@ ru: frozen_platform: В случае выбора репозитория для сохранения пакетов из замороженнной платформы разрешены только bugfix и security обновления wrong_include_repos: Включаемые репозитории должны принадлежать платформе для сборки wrong_commit_hash: Невозможно найти коммит '%{commit_hash}' в проекте + wrong_extra_repositories: Некоторые репозитории не существуют + wrong_extra_containers: Некоторые контейнеры не существуют