From ac762388a4d147a17450742dab27cd5dd5af6eb9 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Mon, 24 Dec 2012 16:35:29 +0400 Subject: [PATCH] #800: enable "new_core" for personal platforms --- app/assets/javascripts/extra/build_list.js | 4 ++++ app/controllers/api/v1/build_lists_controller.rb | 2 +- app/controllers/projects/build_lists_controller.rb | 3 +-- app/models/build_list.rb | 4 ---- app/views/projects/build_lists/new.html.haml | 7 +++---- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/extra/build_list.js b/app/assets/javascripts/extra/build_list.js index 99241e9cf..26eaad39c 100644 --- a/app/assets/javascripts/extra/build_list.js +++ b/app/assets/javascripts/extra/build_list.js @@ -9,9 +9,13 @@ $(document).ready(function() { var build_platform = $('#build_for_pl_' + platform_id); var all_repositories = $('.all_platforms input'); all_repositories.removeAttr('checked'); + + var new_core = $('#build_list_new_core'); if (build_platform.size() == 0) { all_repositories.removeAttr('disabled'); + new_core.removeAttr('disabled').attr('checked', 'checked'); } else { + new_core.removeAttr('checked').attr('disabled', 'disabled'); all_repositories.attr('disabled', 'disabled'); var parent = build_platform.parent(); parent.find('input').removeAttr('disabled'); diff --git a/app/controllers/api/v1/build_lists_controller.rb b/app/controllers/api/v1/build_lists_controller.rb index 6d9889357..dd0fea821 100644 --- a/app/controllers/api/v1/build_lists_controller.rb +++ b/app/controllers/api/v1/build_lists_controller.rb @@ -26,7 +26,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController @build_list.user = current_user @build_list.priority = current_user.build_priority # User builds more priority than mass rebuild with zero priority - @build_list.new_core = BuildList.has_access_to_new_core?(current_user) && bl_params[:new_core] == '1' + @build_list.new_core = save_to_repository.platform.personal? && bl_params[:new_core] == '1' if @build_list.save render :action => 'show' diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index c13d5c254..33560307a 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -55,8 +55,7 @@ class Projects::BuildListsController < Projects::BaseController build_for_platforms = Repository.select(:platform_id). where(:id => params[:build_list][:include_repos]).group(:platform_id).map(&:platform_id) - new_core = BuildList.has_access_to_new_core?(current_user) && params[:build_list][:new_core] == '1' - params[:build_list][:auto_publish] = false if new_core + new_core = @platform.personal? && params[:build_list][:new_core] == '1' Arch.where(:id => params[:arches]).each do |arch| Platform.main.where(:id => build_for_platforms).each do |build_for_platform| @build_list = @project.build_lists.build(params[:build_list]) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 981cde909..c3cd0f5f1 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -328,10 +328,6 @@ class BuildList < ActiveRecord::Base @status end - def self.has_access_to_new_core?(user) - user && (user.admin? || user.tester?) - end - def self.human_status(status) I18n.t("layout.build_lists.statuses.#{HUMAN_STATUSES[status]}") end diff --git a/app/views/projects/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml index 86e077fa9..1abd63f5a 100644 --- a/app/views/projects/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -29,10 +29,9 @@ .both = f.check_box :build_requires = f.label :build_requires - - if BuildList.has_access_to_new_core?(current_user) - .both - = f.check_box :new_core - = f.label :new_core + .both + = f.check_box :new_core + = f.label :new_core %br = f.submit t("layout.projects.build_button")