#757: rename #extra_containers to #extra_build_lists

This commit is contained in:
Vokhmin Alexey V 2013-02-22 15:04:14 +04:00
parent 3aae65f744
commit 7a2b547d2b
13 changed files with 54 additions and 53 deletions

View File

@ -17,7 +17,7 @@ $(document).ready(function() {
use_save_to_repository.removeAttr('disabled');
auto_create_container.removeAttr('checked');
} else {
updateExtraReposAndContainers();
updateExtraReposAndBuildLists();
use_save_to_repository.attr('disabled', 'disabled').attr('checked', 'checked');
all_repositories.attr('disabled', 'disabled');
var parent = build_platform.parent();
@ -36,29 +36,29 @@ $(document).ready(function() {
auto_create_container.attr('checked', 'checked');
}
var path = '/build_lists/autocomplete_to_extra_repos_and_containers?platform_id=' + platform_id;
var path = '/build_lists/autocomplete_to_extra_repos_and_builds?platform_id=' + platform_id;
$('#extra_repos').attr('data-autocomplete', path);
});
$('#build_list_save_to_repository_id').trigger('change');
$('#extra-repos-and-containers #add').click(function() {
updateExtraReposAndContainers();
$('#extra-repos-and-build-lists #add').click(function() {
updateExtraReposAndBuildLists();
return false;
});
$(document).on('click', '#extra-repos-and-containers .delete', function() {
$(document).on('click', '#extra-repos-and-build-lists .delete', function() {
$(this)[0].parentElement.parentElement.remove();
});
$('#extra-repos-and-containers-dialog').dialog({
$('#extra-repos-and-build-lists-dialog').dialog({
autoOpen: false,
resizable: false,
width: 400
});
$('#extra-repos-and-containers .icon-question-sign').click(function() {
var dialog = $('#extra-repos-and-containers-dialog');
$('#extra-repos-and-build-lists .icon-question-sign').click(function() {
var dialog = $('#extra-repos-and-build-lists-dialog');
if (dialog.is(':visible')) { dialog.dialog('close'); } else { dialog.dialog('open'); }
});
@ -98,10 +98,10 @@ $(document).ready(function() {
});
function updateExtraReposAndContainers() {
$.get("/build_lists/update_extra_repos_and_containers", $('#new_build_list').serialize())
function updateExtraReposAndBuildLists() {
$.get("/build_lists/update_extra_repos_and_builds", $('#new_build_list').serialize())
.done(function(data) {
$("#extra-repos-and-containers table tbody").html(data);
$("#extra-repos-and-build-lists table tbody").html(data);
});
}

View File

@ -1767,7 +1767,7 @@ table#myTable thead tr.search th form.button_to div input {
border: 1px solid #DDDDDD;
}
#extra-repos-and-containers {
#extra-repos-and-build-lists {
width: 330px;
.actions { width: 15px; }
}
@ -1822,15 +1822,15 @@ table#myTable thead tr.search th form.button_to div input {
margin-left: 10px;
}
#extra-repos-and-containers {
#extra-repos-and-build-lists {
width: 330px;
.actions { width: 15px; }
.icon-question-sign {
background-position: -96px -96px;
}
}
#extra-repos-and-containers-dialog, .ui-dialog-titlebar { font-size: 12px; }
#extra-repos-and-containers-dialog {
#extra-repos-and-build-lists-dialog, .ui-dialog-titlebar { font-size: 12px; }
#extra-repos-and-build-lists-dialog {
text-align: left;
p { margin: 0; }
}

View File

@ -114,7 +114,7 @@ class Projects::BuildListsController < Projects::BaseController
}
end
def autocomplete_to_extra_repos_and_containers
def autocomplete_to_extra_repos_and_builds
results, save_to_platform = [], Platform.find(params[:platform_id])
bl = BuildList.where(:id => params[:term]).published_container.accessible_by(current_ability, :read)
if save_to_platform.main?
@ -129,12 +129,12 @@ class Projects::BuildListsController < Projects::BaseController
render json: results.to_json
end
def update_extra_repos_and_containers
def update_extra_repos_and_builds
results, save_to_repository = [], Repository.find(params[:build_list][:save_to_repository_id])
extra_repos = params[:build_list][:extra_repositories] || []
extra_containers = params[:build_list][:extra_containers] || []
(params[:extra_repo].gsub!(/-build-list$/, '') ? extra_containers : extra_repos) << params[:extra_repo]
build_lists = BuildList.where(:id => extra_containers).published_container.accessible_by(current_ability, :read)
extra_bls = params[:build_list][:extra_build_lists] || []
(params[:extra_repo].gsub!(/-build-list$/, '') ? extra_bls : extra_repos) << params[:extra_repo]
build_lists = BuildList.where(:id => extra_bls).published_container.accessible_by(current_ability, :read)
if save_to_repository.platform.main?
build_lists = build_lists.where(:save_to_platform_id => save_to_repository.platform_id)
else

View File

@ -42,15 +42,15 @@ 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)
}
before_validation :prepare_extra_repositories, :on => :create
before_validation :prepare_extra_containers, :on => :create
before_validation :prepare_extra_repositories, :on => :create
before_validation :prepare_extra_build_lists, :on => :create
before_create :use_save_to_repository_for_main_platforms
attr_accessible :include_repos, :auto_publish, :build_for_platform_id, :commit_hash,
:arch_id, :project_id, :save_to_repository_id, :update_type,
:save_to_platform_id, :project_version, :use_save_to_repository,
:auto_create_container, :extra_repositories, :extra_containers
:auto_create_container, :extra_repositories, :extra_build_lists
LIVE_TIME = 4.week # for unpublished
MAX_LIVE_TIME = 3.month # for published
@ -131,8 +131,8 @@ class BuildList < ActiveRecord::Base
serialize :additional_repos
serialize :include_repos
serialize :results, Array
serialize :extra_repositories, Array
serialize :extra_containers, Array
serialize :extra_repositories, Array
serialize :extra_build_lists, Array
after_commit :place_build
after_destroy :remove_container
@ -284,12 +284,13 @@ class BuildList < ActiveRecord::Base
def can_publish?(check_only_status = false)
by_status = [SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED].include?(status)
check_only_status ? by_status : (by_status && extra_containers_published?)
check_only_status ? by_status : (by_status && extra_build_lists_published?)
end
def extra_containers_published?
def extra_build_lists_published?
# All extra build lists should be published before publishing this build list for main platforms!
return true unless save_to_platform.main?
BuildList.where(:id => extra_containers).where('status != ?', BUILD_PUBLISHED).count == 0
BuildList.where(:id => extra_build_lists).where('status != ?', BUILD_PUBLISHED).count == 0
end
def can_reject_publish?
@ -423,7 +424,7 @@ class BuildList < ActiveRecord::Base
end
end
host = EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host]
BuildList.where(:id => extra_containers).each do |bl|
BuildList.where(:id => extra_build_lists).each do |bl|
path = "http://#{host}/downloads/#{bl.save_to_platform.name}/container/"
path << "#{bl.id}/#{bl.arch.name}/#{bl.save_to_repository.name}/release"
include_repos_hash["container_#{bl.id}"] = path
@ -490,8 +491,8 @@ class BuildList < ActiveRecord::Base
end
end
def prepare_extra_containers
bls = BuildList.where(:id => extra_containers).published_container.accessible_by(current_ability, :read)
def prepare_extra_build_lists
bls = BuildList.where(:id => extra_build_lists).published_container.accessible_by(current_ability, :read)
if save_to_platform && save_to_platform.main?
bls = bls.where(:save_to_platform_id => save_to_platform.id)
if save_to_platform.distrib_type == 'rhel'
@ -504,7 +505,7 @@ class BuildList < ActiveRecord::Base
end
end
self.extra_containers = bls.pluck('build_lists.id')
self.extra_build_lists = bls.pluck('build_lists.id')
end
end

View File

@ -56,11 +56,11 @@ json.build_list do |json|
:json => json_extra_repos
end
extra_containers = BuildList.where(:id => @build_list.extra_containers)
json.extra_containers extra_containers do |json_extra_containers, bl|
json_extra_containers.(bl, :id, :status)
json_extra_containers.container_path container_url(false, bl)
json_extra_containers.url api_v1_build_list_path(bl, :format => :json)
extra_build_lists = BuildList.where(:id => @build_list.extra_build_lists)
json.extra_build_lists extra_build_lists do |json_extra_build_lists, bl|
json_extra_build_lists.(bl, :id, :status)
json_extra_build_lists.container_path container_url(false, bl)
json_extra_build_lists.url api_v1_build_list_path(bl, :format => :json)
end

View File

@ -4,6 +4,6 @@
- else
%td= link_to "#{extra.platform.name}/#{extra.name}", [extra.platform, extra]
%td.actions
- field = extra.is_a?(BuildList) ? 'extra_containers' : 'extra_repositories'
- field = extra.is_a?(BuildList) ? 'extra_build_lists' : 'extra_repositories'
= hidden_field_tag "build_list[#{field}][]", extra.id
%span.delete &nbsp;

View File

@ -23,14 +23,14 @@
%h3= t("activerecord.attributes.build_list.update_type")
.lineForm= f.select :update_type, BuildList::UPDATE_TYPES
#extra-repos-and-containers
#extra-repos-and-build-lists
%h3= t("activerecord.attributes.build_list.extra_repos")
= autocomplete_field_tag 'extra_repos', nil, autocomplete_to_extra_repos_and_containers_build_lists_path, :id_element => '#extra_repo_field'
= autocomplete_field_tag 'extra_repos', nil, autocomplete_to_extra_repos_and_builds_build_lists_path, :id_element => '#extra_repo_field'
= hidden_field_tag 'extra_repo', nil, :id => 'extra_repo_field'
= submit_tag t("layout.add"), :class => 'button', :id => 'add'
%span.icon-question-sign
%div#extra-repos-and-containers-dialog{:title => t("activerecord.attributes.build_list.extra_repos")}
%div#extra-repos-and-build-lists-dialog{:title => t("activerecord.attributes.build_list.extra_repos")}
%b= t('activerecord.attributes.build_list.extra_repos_help.message1')
%p= t('activerecord.attributes.build_list.extra_repos_help.message2')
%p= t('activerecord.attributes.build_list.extra_repos_help.message3')
@ -41,7 +41,7 @@
%table.tablesorter{:cellpadding => "0", :cellspacing => "0"}
%tbody
= render :partial => 'extra', :collection => Repository.where(id: @build_list.extra_repositories)
= render :partial => 'extra', :collection => BuildList.where(id: @build_list.extra_containers)
= render :partial => 'extra', :collection => BuildList.where(id: @build_list.extra_build_lists)
%h3= t("activerecord.attributes.build_list.preferences")
- [:auto_publish, :auto_create_container, :use_save_to_repository].each do |kind|

View File

@ -72,12 +72,12 @@
.rightlist= t("layout.#{@build_list.new_core?}_")
.both
- if @build_list.extra_containers.present? || @build_list.extra_repositories.present?
- if @build_list.extra_build_lists.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|
%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_build_lists).each do |bl|
%p= link_to "#{bl.id} (#{bl.project.name} - #{bl.arch.name})", bl
.both
@ -152,7 +152,7 @@
- if @build_list.build_published?
= submit_tag t("layout.publish_again"), :confirm => t("layout.publish_again_warning"), :name => 'publish'
- elsif @build_list.can_publish?(true)
- if !@build_list.extra_containers_published?
- if !@build_list.extra_build_lists_published?
- confirm = t('layout.build_lists.publish_with_extra_fail')
- elsif @build_list.tests_failed?
- confirm = t('layout.build_lists.tests_failed')

View File

@ -7,7 +7,7 @@ en:
build_list:
bs_id: Id
name: Name
extra_repos: Extra repositories and containers
extra_repos: Extra repositories and build lists
extra_repos_help:
message1: 'Add ID of build list which need to connect:'
message2: '- Only build list with container can be connected;'
@ -80,7 +80,7 @@ en:
create_container_fail: 'Errors during container creating!'
publish_success: 'Build is queued for publishing'
publish_fail: 'Errors during build publishing!'
publish_with_extra_fail: 'All extra containers should be published before publishing this build list!'
publish_with_extra_fail: 'All extra build lists should be published before publishing this build list!'
cancel_success: 'Build canceled'
cancel_fail: 'Errors during build cancelation!'
reject_publish_success: 'Publishing rejected'

View File

@ -7,7 +7,7 @@ ru:
build_list:
bs_id: Id
name: Название
extra_repos: Дополнительные репозитории и контейнеры
extra_repos: Дополнительные репозитории и сборки
extra_repos_help:
message1: 'Добавьте ID билд листа, который необходимо подключить:'
message2: '- Только билд лист с контейнером может быть подключен;'
@ -81,7 +81,7 @@ ru:
cancel_fail: 'При отмене сборки произошла ошибка!'
publish_success: 'Сборка поставлена в очередь на публикацию.'
publish_fail: 'При публикации сборки произошла ошибка!'
publish_with_extra_fail: 'Все дополнительные контейнеры должны быть опубликованы до публикации этой сборки!'
publish_with_extra_fail: 'Все дополнительные сборки должны быть опубликованы до публикации этой сборки!'
reject_publish_success: 'Публикация отклонена'
reject_publish_fail: 'Не удалось отклонить публикацию сборки'
container_published: 'Контейнер размещен в репозитории'

View File

@ -221,8 +221,8 @@ Rosa::Application.routes.draw do
get :log
end
collection {
get :autocomplete_to_extra_repos_and_containers
get :update_extra_repos_and_containers
get :autocomplete_to_extra_repos_and_builds
get :update_extra_repos_and_builds
post :search
}
end

View File

@ -2,6 +2,6 @@ class AddExtraRepositoriesAndContainersToBuildList < ActiveRecord::Migration
def change
add_column :build_lists, :auto_create_container, :boolean, :default => false
add_column :build_lists, :extra_repositories, :text
add_column :build_lists, :extra_containers, :text
add_column :build_lists, :extra_build_lists, :text
end
end

View File

@ -136,7 +136,7 @@ ActiveRecord::Schema.define(:version => 20130218135847) do
t.boolean "use_save_to_repository", :default => true
t.boolean "auto_create_container", :default => false
t.text "extra_repositories"
t.text "extra_containers"
t.text "extra_build_lists"
end
add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"