From b85cb31b887f3e480d3ed7c1b7e7efbf7fb4288b Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Mon, 21 May 2012 17:59:04 +0400 Subject: [PATCH] [refs #442] Remove def is_rpm. Change auto_publish default value. Change MassBuild set_name. Fix schema --- app/models/mass_build.rb | 11 ++++++----- app/models/platform.rb | 2 +- app/models/project.rb | 4 ---- app/views/platforms/platforms/build_all.html.haml | 2 +- db/schema.rb | 2 +- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index dc42e2a85..b626bed53 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -1,17 +1,18 @@ class MassBuild < ActiveRecord::Base belongs_to :platform - before_save :set_name - scope :by_platform, lambda { |platform| where(:platform_id => platform.id) } def build_all(opts={}) + set_name opts[:repositories] platform.build_all opts.merge({:mass_build_id => self.id}) end - protected + private - def set_name - self.name = "#{Date.today.to_s}-#{platform.name}" + def set_name(repositories_ids) + rep_names = Repository.where(:id => repositories_ids).map(&:name).join(", ") + self.name = "#{Date.today.strftime("%d.%b")}-#{platform.name}(#{rep_names})" + self.save! end end diff --git a/app/models/platform.rb b/app/models/platform.rb index bde879c34..2face5a28 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -161,7 +161,7 @@ class Platform < ActiveRecord::Base # Set options to build all need repositories = opts[:repositories] ? self.repositories.where(:id => opts[:repositories]) : self.repositories arches = opts[:arches] ? Arch.where(:id => opts[:arches]) : Arch.all - auto_publish = opts[:auto_publish] || false + auto_publish = opts[:auto_publish] || true user = opts[:user] mass_build_id = opts[:mass_build_id] diff --git a/app/models/project.rb b/app/models/project.rb index 0398448b6..d8b9d70bc 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -55,10 +55,6 @@ class Project < ActiveRecord::Base include Modules::Models::Owner - def is_rpm - is_package - end - def to_param name end diff --git a/app/views/platforms/platforms/build_all.html.haml b/app/views/platforms/platforms/build_all.html.haml index b482c2db6..393811013 100644 --- a/app/views/platforms/platforms/build_all.html.haml +++ b/app/views/platforms/platforms/build_all.html.haml @@ -20,7 +20,7 @@ .table %h3= t("activerecord.attributes.build_list.preferences") .lefter - = check_box_tag :auto_publish, true, params[:auto_publish].present?, :id => 'auto_publish' + = check_box_tag :auto_publish, true, params[:auto_publish].present? ? params[:auto_publish].present? : true, :id => 'auto_publish' = label_tag :auto_publish .both .both diff --git a/db/schema.rb b/db/schema.rb index 2de938188..7ee386593 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -230,7 +230,7 @@ ActiveRecord::Schema.define(:version => 20120518105225) do t.string "owner_type" t.string "visibility", :default => "open", :null => false t.string "platform_type", :default => "main", :null => false - t.string "distrib_type" + t.string "distrib_type", :null => false end add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false