From 69fb368911ffef411bcd4a32e009ed44292ad6c8 Mon Sep 17 00:00:00 2001 From: Vladimir Sharshov Date: Tue, 7 Aug 2012 00:48:29 +0400 Subject: [PATCH] merger stash --- app/models/project.rb | 11 +++---- db/schema.rb | 70 +++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index c69f1125e..e2c89a12c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -23,10 +23,11 @@ class Project < ActiveRecord::Base validates :name, :uniqueness => {:scope => [:owner_id, :owner_type], :case_sensitive => false}, :presence => true, :format => {:with => /^#{NAME_REGEXP}$/, :message => I18n.t("activerecord.errors.project.uname")} validates :owner, :presence => true + validates :visibility, :presence => true, :inclusion => {:in => VISIBILITIES} validate { errors.add(:base, :can_have_less_or_equal, :count => MAX_OWN_PROJECTS) if owner.projects.size >= MAX_OWN_PROJECTS } attr_accessible :name, :description, :visibility, :srpm, :is_package, :default_branch, :has_issues, :has_wiki - attr_readonly :name + attr_readonly :name, :owner_id, :owner_type scope :recent, order("name ASC") scope :search_order, order("CHAR_LENGTH(name) ASC") @@ -83,13 +84,12 @@ class Project < ActiveRecord::Base owner == user end - def build_for(platform, user, arch = 'i586', auto_publish = false, mass_build_id = nil, priority = 0) + def build_for(platform, repository_id, user, arch = 'i586', auto_publish = false, mass_build_id = nil, priority = 0) # Select main and project platform repository(contrib, non-free and etc) # If main does not exist, will connect only project platform repository # If project platform repository is main, only main will be connect - build_reps = [platform.repositories.find_by_name('main')] - build_reps += platform.repositories.select {|rep| self.repository_ids.include? rep.id} - build_reps_ids = build_reps.compact.map(&:id).uniq + main_rep_id = platform.repositories.find_by_name('main').id + build_reps_ids = [main_rep_id, repository_id].compact.uniq arch = Arch.find_by_name(arch) if arch.acts_like?(:string) build_lists.create do |bl| bl.save_to_platform = platform @@ -103,6 +103,7 @@ class Project < ActiveRecord::Base bl.include_repos = build_reps_ids bl.priority = priority bl.mass_build_id = mass_build_id + bl.save_to_repository_id = repository_id end end diff --git a/db/schema.rb b/db/schema.rb index f9df9fb18..7a529a422 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -106,8 +106,9 @@ ActiveRecord::Schema.define(:version => 20120730214052) do t.string "project_version" t.integer "project_id" t.integer "arch_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "notified_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.boolean "is_circle", :default => false t.text "additional_repos" t.string "name" @@ -136,8 +137,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do t.string "commentable_type" t.integer "user_id" t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.decimal "commentable_id", :precision => 50, :scale => 0 t.integer "project_id" end @@ -154,8 +155,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do t.string "controller" t.string "action" t.text "message" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "flash_notifies", :force => true do |t| @@ -167,8 +168,6 @@ ActiveRecord::Schema.define(:version => 20120730214052) do t.datetime "updated_at", :null => false end - add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false - create_table "groups", :force => true do |t| t.integer "owner_id" t.datetime "created_at", :null => false @@ -185,8 +184,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do t.string "title" t.text "body" t.string "status", :default => "open" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "user_id" t.datetime "closed_at" t.integer "closed_by" @@ -246,14 +245,14 @@ ActiveRecord::Schema.define(:version => 20120730214052) do t.string "description" t.string "name", :null => false t.integer "parent_platform_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.boolean "released", :default => false, :null => false t.integer "owner_id" t.string "owner_type" t.string "visibility", :default => "open", :null => false t.string "platform_type", :default => "main", :null => false - t.string "distrib_type", :null => false + t.string "distrib_type" end add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false @@ -262,16 +261,16 @@ ActiveRecord::Schema.define(:version => 20120730214052) do t.integer "platform_id" t.string "login" t.string "password" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "user_id" end create_table "product_build_lists", :force => true do |t| t.integer "product_id" t.integer "status", :default => 2, :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end add_index "product_build_lists", ["product_id"], :name => "index_product_build_lists_on_product_id" @@ -309,14 +308,14 @@ ActiveRecord::Schema.define(:version => 20120730214052) do create_table "project_to_repositories", :force => true do |t| t.integer "project_id" t.integer "repository_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "projects", :force => true do |t| t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "owner_id" t.string "owner_type" t.string "visibility", :default => "open" @@ -354,8 +353,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do t.string "actor_type" t.integer "target_id" t.string "target_type" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "role" end @@ -384,8 +383,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do create_table "subscribes", :force => true do |t| t.string "subscribeable_type" t.integer "user_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.boolean "status", :default => true t.integer "project_id" t.decimal "subscribeable_id", :precision => 50, :scale => 0 @@ -393,21 +392,20 @@ ActiveRecord::Schema.define(:version => 20120730214052) do create_table "users", :force => true do |t| t.string "name" - t.string "email", :default => "", :null => false - t.string "encrypted_password", :limit => 128, :default => "", :null => false - t.string "password_salt", :default => "", :null => false + t.string "email", :default => "", :null => false + t.string "encrypted_password", :default => "", :null => false t.string "reset_password_token" t.datetime "remember_created_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "ssh_key" t.string "uname" t.string "role" - t.string "language", :default => "en" + t.string "language", :default => "en" + t.integer "own_projects_count", :default => 0, :null => false t.string "confirmation_token" t.datetime "confirmed_at" t.datetime "confirmation_sent_at" - t.integer "own_projects_count", :default => 0, :null => false - t.datetime "reset_password_sent_at" t.text "professional_experience" t.string "site" t.string "company" @@ -416,11 +414,11 @@ ActiveRecord::Schema.define(:version => 20120730214052) do t.string "avatar_content_type" t.integer "avatar_file_size" t.datetime "avatar_updated_at" - t.integer "failed_attempts", :default => 0 + t.integer "failed_attempts", :default => 0 t.string "unlock_token" t.datetime "locked_at" t.string "authentication_token" - t.integer "build_priority", :default => 50 + t.integer "build_priority", :default => 50 end add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token" @@ -430,4 +428,4 @@ ActiveRecord::Schema.define(:version => 20120730214052) do add_index "users", ["uname"], :name => "index_users_on_uname", :unique => true add_index "users", ["unlock_token"], :name => "index_users_on_unlock_token", :unique => true -end \ No newline at end of file +end