#231: selects default arches at creation of build_list

This commit is contained in:
Vokhmin Alexey V 2013-07-25 11:37:16 +04:00
parent 2f9ba0b700
commit 44df993cbf
5 changed files with 26 additions and 4 deletions

View File

@ -21,6 +21,7 @@ $(document).ready(function() {
extra_repos.show();
} else {
all_repositories.attr('disabled', 'disabled');
updatedDefaultArches(selected_option);
extra_repos.hide();
var parent = build_platform.parent();
parent.find('input').removeAttr('disabled');
@ -77,6 +78,13 @@ $(document).ready(function() {
});
});
function updatedDefaultArches(selected_option) {
$('input[name="arches[]"]').removeAttr('checked');
_.each(selected_option.attr('default_arches').split(' '), function(id){
$('#arches_' + id).attr('checked', 'checked');
});
}
function updateExtraReposAndBuildLists(save_to_platform_id) {
$.each($('.autocomplete-form'), function() {
var form = $(this);

View File

@ -19,6 +19,20 @@ module BuildListsHelper
.joins(:repositories).uniq
end
def save_to_repositories(project)
project.repositories.collect do |r|
[
"#{r.platform.name}/#{r.name}",
r.id,
{
:publish_without_qa => r.publish_without_qa? ? 1 : 0,
:platform_id => r.platform.id,
:default_arches => r.platform.platform_arch_settings.by_default.pluck(:arch_id).join(' ')
}
]
end
end
def mass_build_options(selected_id)
options_from_collection_for_select(
MassBuild.recent.limit(15),

View File

@ -413,8 +413,7 @@ class BuildList < ActiveRecord::Base
{
:id => id,
:arch => arch.name,
# :time_living => 43200, # 12 hours
:time_living => (build_for_platform.platform_arch_settings.by_arch(arch).time_living.first || PlatformArchSetting::DEFAULT_TIME_LIVING),
:time_living => (build_for_platform.platform_arch_settings.by_arch(arch).first.try(:time_living) || PlatformArchSetting::DEFAULT_TIME_LIVING),
:distrib_type => build_for_platform.distrib_type,
:git_project_address => git_project_address,
:commit_hash => commit_hash,

View File

@ -11,7 +11,8 @@ class PlatformArchSetting < ActiveRecord::Base
validates :arch_id, :platform_id, :presence => true
validates :platform_id, :uniqueness => {:scope => :arch_id}
scope :by_arch, lambda {|arch| where(:arch_id => arch) if arch.present?}
scope :by_arch, lambda {|arch| where(:arch_id => arch) if arch.present?}
scope :by_default, where(:default => true)
attr_accessible :arch_id, :platform_id, :default

View File

@ -9,7 +9,7 @@
.offset25= render 'include_repos', :platform => pl
%section.right
%h3= t("activerecord.attributes.build_list.save_to_repository")
.lineForm= f.select :save_to_repository_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.id, {:publish_without_qa => r.publish_without_qa? ? 1 : 0, :platform_id => r.platform.id}]}
.lineForm= f.select :save_to_repository_id, save_to_repositories(@project)
%h3= t("activerecord.attributes.build_list.project_version")
.lineForm= f.select :project_version, versions_for_group_select(@project), :selected => params[:build_list].try(:fetch, :project_version) || @project.default_branch
%h3= t("activerecord.attributes.build_list.arch")