diff --git a/app/assets/javascripts/extra/build_list.js b/app/assets/javascripts/extra/build_list.js index 85ae6f770..9f4fc5793 100644 --- a/app/assets/javascripts/extra/build_list.js +++ b/app/assets/javascripts/extra/build_list.js @@ -7,14 +7,6 @@ $(document).ready(function() { base_platforms.each(function(){ if ($.inArray(platform_id, base_platforms.map(function(){ return $(this).val(); }).get()) >= 0) { if ($(this).val() == platform_id) { - if ($(this).attr('data-released') === '1') { - $('#build_list_auto_publish').removeAttr('checked').attr('disabled', 'disabled'); - //disableUpdateTypes(); - } else { - $('#build_list_auto_publish').removeAttr('disabled').attr('checked', 'checked'); - //enableUpdateTypes(); - } - $(this).attr('checked', 'checked').removeAttr('disabled').trigger('change'); $(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('disabled'); @@ -30,7 +22,6 @@ $(document).ready(function() { } else { $(this).removeAttr('disabled').removeAttr('checked').trigger('change'); $(this).parent().find('.offset25 input[type="checkbox"]').removeAttr('disabled').removeAttr('checked'); - $('#build_list_auto_publish').removeAttr('disabled').attr('checked', 'checked'); } }); @@ -41,7 +32,13 @@ $(document).ready(function() { setBranchSelected(); + checkAccessToAutomatedPublising(); }); + + $('.all_platforms .offset25 input').change(function() { + checkAccessToAutomatedPublising(); + }); + $('#build_list_save_to_platform_id').trigger('change'); $('.offset25 label').click(function() { @@ -57,6 +54,16 @@ $(document).ready(function() { }); +function checkAccessToAutomatedPublising() { + if ($('.all_platforms .offset25 input:checked[publish_wtihout_qa="1"]').length > 0) { + $('#build_list_auto_publish').removeAttr('disabled').attr('checked', 'checked'); + //enableUpdateTypes(); + } else { + $('#build_list_auto_publish').removeAttr('checked').attr('disabled', 'disabled'); + //disableUpdateTypes(); + } +} + function setPlChecked(pointer, checked) { var pl_cbx = $(pointer).parent().parent().parent().find('input[type="checkbox"].build_bpl_ids'); var pl_id = pl_cbx.val(); diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index 3edff9b3d..77bf59daa 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -49,7 +49,7 @@ class Projects::BuildListsController < Projects::BaseController @repository = @project.repositories.where(:id => @platform.repository_ids).first params[:build_list][:save_to_repository_id] = @repository.id - params[:build_list][:auto_publish] = false if @platform.released && !@repository.publish_wtihout_qa + params[:build_list][:auto_publish] = false unless @repository.publish_wtihout_qa? Arch.where(:id => params[:arches]).each do |arch| Platform.main.where(:id => params[:build_for_platforms]).each do |build_for_platform| diff --git a/app/views/projects/build_lists/_include_repos.html.haml b/app/views/projects/build_lists/_include_repos.html.haml index 11ef89f97..95a63c60c 100644 --- a/app/views/projects/build_lists/_include_repos.html.haml +++ b/app/views/projects/build_lists/_include_repos.html.haml @@ -1,4 +1,4 @@ - platform.repositories.each do |repo| .both - = check_box_tag "build_list[include_repos][]", repo.id, repo.name == 'main' || @project.repositories.map(&:id).include?(repo.id), :id => "include_repos_#{repo.id}", :save_to_platform_id => platform.id, :rep_name => repo.name + = check_box_tag "build_list[include_repos][]", repo.id, repo.name == 'main' || @project.repositories.map(&:id).include?(repo.id), :id => "include_repos_#{repo.id}", :save_to_platform_id => platform.id, :rep_name => repo.name, :publish_wtihout_qa => repo.publish_wtihout_qa? ? 1 : 0 = label_tag "include_repos_#{repo.id}", repo.name diff --git a/app/views/projects/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml index ccda36113..542e98c6c 100644 --- a/app/views/projects/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -6,7 +6,7 @@ - Platform.main.each do |pl| - if pl.repository_ids.size > 0 .both - = check_box_tag "build_for_platforms[]", pl.id, (params[:build_for_platforms]||[]).include?(pl.id.to_s), :class => 'build_bpl_ids', :id => "bpls_#{pl.id}", :'data-released' => pl.released ? 1 : 0 + = check_box_tag "build_for_platforms[]", pl.id, (params[:build_for_platforms]||[]).include?(pl.id.to_s), :class => 'build_bpl_ids', :id => "bpls_#{pl.id}" = label_tag "bpls_#{pl.id}", pl.name .offset25{:style => 'padding-left: 25px'}= render 'include_repos', :platform => pl %section.right diff --git a/db/migrate/20120906115648_add_publish_wtihout_qa_to_repositories.rb b/db/migrate/20120906115648_add_publish_wtihout_qa_to_repositories.rb index c5620669b..f9a7cac11 100644 --- a/db/migrate/20120906115648_add_publish_wtihout_qa_to_repositories.rb +++ b/db/migrate/20120906115648_add_publish_wtihout_qa_to_repositories.rb @@ -1,5 +1,19 @@ class AddPublishWtihoutQaToRepositories < ActiveRecord::Migration - def change - add_column :repositories, :publish_wtihout_qa, :boolean, :default => false + + class Platform < ActiveRecord::Base + end + + class Repository < ActiveRecord::Base + belongs_to :platform + end + + def up + add_column :repositories, :publish_wtihout_qa, :boolean, :default => true + Repository.where('platforms.released is true').joins(:platform). + update_all(:publish_wtihout_qa => false) + end + + def down + remove_column :repositories, :publish_wtihout_qa end end diff --git a/db/schema.rb b/db/schema.rb index 85fd8221c..6c06c434c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -367,12 +367,12 @@ ActiveRecord::Schema.define(:version => 20120906115648) do end create_table "repositories", :force => true do |t| - t.string "description", :null => false - t.integer "platform_id", :null => false + t.string "description", :null => false + t.integer "platform_id", :null => false t.datetime "created_at" t.datetime "updated_at" - t.string "name", :null => false - t.boolean "publish_wtihout_qa", :default => false + t.string "name", :null => false + t.boolean "publish_wtihout_qa", :default => true end create_table "settings_notifiers", :force => true do |t|