diff --git a/app/helpers/git_helper.rb b/app/helpers/git_helper.rb index c65d1ff37..a1782ecbd 100644 --- a/app/helpers/git_helper.rb +++ b/app/helpers/git_helper.rb @@ -68,6 +68,7 @@ module GitHelper end def versions_for_group_select(project) + return [] unless project [ ['Branches', project.repo.branches.map(&:name)], ['Tags', project.repo.tags.map(&:name)] ] end diff --git a/app/models/product.rb b/app/models/product.rb index 765ca8346..6b581b161 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -31,7 +31,8 @@ class Product < ActiveRecord::Base :main_script, :params, :platform_id, - :autostart_status + :autostart_status, + :project_version attr_readonly :platform_id def full_clone(attrs = {}) @@ -63,7 +64,7 @@ class Product < ActiveRecord::Base def self.autostart_iso_builds(autostart_status) Product.where(:autostart_status => autostart_status).each do |product| pbl = product.product_build_lists.new - [:params, :main_script, :project].each do |k| + [:params, :main_script, :project, :project_version].each do |k| pbl.send "#{k}=", product.send(k) end owner = product.platform.owner @@ -71,7 +72,6 @@ class Product < ActiveRecord::Base pbl.autostarted = true pbl.base_url = "http://#{product.platform.default_host}" pbl.time_living = product.time_living / 60 - pbl.project_version = product.project.default_branch pbl.save end end diff --git a/app/views/platforms/product_build_lists/new.html.haml b/app/views/platforms/product_build_lists/new.html.haml index 6f03eb78a..24743689f 100644 --- a/app/views/platforms/product_build_lists/new.html.haml +++ b/app/views/platforms/product_build_lists/new.html.haml @@ -9,7 +9,7 @@ .both .leftlist= f.label :project_version, t("activerecord.attributes.product_build_list.project_version"), :class => :label - .rightlist= f.select :project_version, versions_for_group_select(pbl.project), :selected => params[:product_build_lists].try(:fetch, :project_version) || pbl.project.default_branch + .rightlist= f.select :project_version, versions_for_group_select(pbl.project), :selected => params[:product_build_lists].try(:fetch, :project_version) || @product.project_version || pbl.project.default_branch .both = render 'platforms/products/def_fields', :f => f diff --git a/app/views/platforms/products/_form.html.haml b/app/views/platforms/products/_form.html.haml index e1759d958..ede415ad5 100644 --- a/app/views/platforms/products/_form.html.haml +++ b/app/views/platforms/products/_form.html.haml @@ -10,6 +10,10 @@ .rightlist= f.autocomplete_field :project, autocomplete_project_platform_products_path(@platform), :id_element => 'src_project_id', :name => 'src_project', :value => @product.project.try(:name_with_owner) .both +.leftlist= f.label :project_version, t("activerecord.attributes.product_build_list.project_version") +.rightlist= f.select :project_version, versions_for_group_select(@product.project), {:selected => params[:products].try(:fetch, :project_version) || @product.project_version, :include_blank => true} +.both + = render 'def_fields', :f => f .leftlist= f.label :autostart_status diff --git a/db/migrate/20130327120129_add_project_version_to_product.rb b/db/migrate/20130327120129_add_project_version_to_product.rb new file mode 100644 index 000000000..b58828f47 --- /dev/null +++ b/db/migrate/20130327120129_add_project_version_to_product.rb @@ -0,0 +1,5 @@ +class AddProjectVersionToProduct < ActiveRecord::Migration + def change + add_column :products, :project_version, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index ce331079b..62a94da91 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130322132919) do +ActiveRecord::Schema.define(:version => 20130327120129) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -331,6 +331,7 @@ ActiveRecord::Schema.define(:version => 20130322132919) do t.string "main_script" t.integer "time_living" t.integer "autostart_status" + t.string "project_version" end create_table "project_imports", :force => true do |t|