[issue #590] Repository fetches through project and platform

This commit is contained in:
George Vinogradov 2012-08-06 14:59:07 +04:00
parent 2fe615047e
commit b963c9342a
3 changed files with 8 additions and 5 deletions

View File

@ -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])

View File

@ -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")

View File

@ -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