From b963c9342a7787d46d0ae91d72a2419a5fd765fd Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Mon, 6 Aug 2012 14:59:07 +0400 Subject: [PATCH] [issue #590] Repository fetches through project and platform --- app/controllers/projects/build_lists_controller.rb | 10 ++++++---- app/views/projects/build_lists/new.html.haml | 2 +- ...0727141521_add_save_to_repository_to_build_lists.rb | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index af142fce9..81e2ce5cb 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -42,12 +42,14 @@ class Projects::BuildListsController < Projects::BaseController def create notices, errors = [], [] - @repository = Repository.find params[:build_list][:save_to_repository_id] - @platform = @repository.platform - params[:build_list][:save_to_platform_id] = @platform.id + @platform = Platform.includes(:repositories).find params[:build_list][:save_to_platform_id] + + @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 - if current_user.can?(:write, save_to_repository) + if can?(:write, @repository) Arch.where(:id => params[:arches]).each do |arch| Platform.main.where(:id => params[:build_for_platforms]).each do |build_for_platform| @build_list = @project.build_lists.build(params[:build_list]) diff --git a/app/views/projects/build_lists/new.html.haml b/app/views/projects/build_lists/new.html.haml index 756535df9..ccda36113 100644 --- a/app/views/projects/build_lists/new.html.haml +++ b/app/views/projects/build_lists/new.html.haml @@ -11,7 +11,7 @@ .offset25{:style => 'padding-left: 25px'}= render 'include_repos', :platform => pl %section.right %h3= t("activerecord.attributes.build_list.save_to_platform") - .lineForm= f.select :save_to_repository_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.id]} + .lineForm= f.select :save_to_platform_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]} %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) || "latest_" + @project.default_branch %h3= t("activerecord.attributes.build_list.arch") diff --git a/db/migrate/20120727141521_add_save_to_repository_to_build_lists.rb b/db/migrate/20120727141521_add_save_to_repository_to_build_lists.rb index 3a9322515..87baab1d8 100644 --- a/db/migrate/20120727141521_add_save_to_repository_to_build_lists.rb +++ b/db/migrate/20120727141521_add_save_to_repository_to_build_lists.rb @@ -13,6 +13,7 @@ class AddSaveToRepositoryToBuildLists < ActiveRecord::Migration bl.save_to_repository_id = rep bl.save! rescue Exception => e + puts e.inspect false end end