merger stash

This commit is contained in:
Vladimir Sharshov 2012-08-07 00:48:29 +04:00
parent 08c58a84df
commit 69fb368911
2 changed files with 40 additions and 41 deletions

View File

@ -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 :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 :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 } 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_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 :recent, order("name ASC")
scope :search_order, order("CHAR_LENGTH(name) ASC") scope :search_order, order("CHAR_LENGTH(name) ASC")
@ -83,13 +84,12 @@ class Project < ActiveRecord::Base
owner == user owner == user
end 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) # Select main and project platform repository(contrib, non-free and etc)
# If main does not exist, will connect only project platform repository # If main does not exist, will connect only project platform repository
# If project platform repository is main, only main will be connect # If project platform repository is main, only main will be connect
build_reps = [platform.repositories.find_by_name('main')] main_rep_id = platform.repositories.find_by_name('main').id
build_reps += platform.repositories.select {|rep| self.repository_ids.include? rep.id} build_reps_ids = [main_rep_id, repository_id].compact.uniq
build_reps_ids = build_reps.compact.map(&:id).uniq
arch = Arch.find_by_name(arch) if arch.acts_like?(:string) arch = Arch.find_by_name(arch) if arch.acts_like?(:string)
build_lists.create do |bl| build_lists.create do |bl|
bl.save_to_platform = platform bl.save_to_platform = platform
@ -103,6 +103,7 @@ class Project < ActiveRecord::Base
bl.include_repos = build_reps_ids bl.include_repos = build_reps_ids
bl.priority = priority bl.priority = priority
bl.mass_build_id = mass_build_id bl.mass_build_id = mass_build_id
bl.save_to_repository_id = repository_id
end end
end end

View File

@ -106,8 +106,9 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.string "project_version" t.string "project_version"
t.integer "project_id" t.integer "project_id"
t.integer "arch_id" t.integer "arch_id"
t.datetime "created_at", :null => false t.datetime "notified_at"
t.datetime "updated_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "is_circle", :default => false t.boolean "is_circle", :default => false
t.text "additional_repos" t.text "additional_repos"
t.string "name" t.string "name"
@ -136,8 +137,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.string "commentable_type" t.string "commentable_type"
t.integer "user_id" t.integer "user_id"
t.text "body" t.text "body"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.decimal "commentable_id", :precision => 50, :scale => 0 t.decimal "commentable_id", :precision => 50, :scale => 0
t.integer "project_id" t.integer "project_id"
end end
@ -154,8 +155,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.string "controller" t.string "controller"
t.string "action" t.string "action"
t.text "message" t.text "message"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
create_table "flash_notifies", :force => true do |t| create_table "flash_notifies", :force => true do |t|
@ -167,8 +168,6 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end 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| create_table "groups", :force => true do |t|
t.integer "owner_id" t.integer "owner_id"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
@ -185,8 +184,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.string "title" t.string "title"
t.text "body" t.text "body"
t.string "status", :default => "open" t.string "status", :default => "open"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "user_id" t.integer "user_id"
t.datetime "closed_at" t.datetime "closed_at"
t.integer "closed_by" t.integer "closed_by"
@ -246,14 +245,14 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.string "description" t.string "description"
t.string "name", :null => false t.string "name", :null => false
t.integer "parent_platform_id" t.integer "parent_platform_id"
t.datetime "created_at" t.datetime "created_at", :null => false
t.datetime "updated_at" t.datetime "updated_at", :null => false
t.boolean "released", :default => false, :null => false t.boolean "released", :default => false, :null => false
t.integer "owner_id" t.integer "owner_id"
t.string "owner_type" t.string "owner_type"
t.string "visibility", :default => "open", :null => false t.string "visibility", :default => "open", :null => false
t.string "platform_type", :default => "main", :null => false t.string "platform_type", :default => "main", :null => false
t.string "distrib_type", :null => false t.string "distrib_type"
end end
add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false 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.integer "platform_id"
t.string "login" t.string "login"
t.string "password" t.string "password"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "user_id" t.integer "user_id"
end end
create_table "product_build_lists", :force => true do |t| create_table "product_build_lists", :force => true do |t|
t.integer "product_id" t.integer "product_id"
t.integer "status", :default => 2, :null => false t.integer "status", :default => 2, :null => false
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
add_index "product_build_lists", ["product_id"], :name => "index_product_build_lists_on_product_id" 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| create_table "project_to_repositories", :force => true do |t|
t.integer "project_id" t.integer "project_id"
t.integer "repository_id" t.integer "repository_id"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
create_table "projects", :force => true do |t| create_table "projects", :force => true do |t|
t.string "name" t.string "name"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "owner_id" t.integer "owner_id"
t.string "owner_type" t.string "owner_type"
t.string "visibility", :default => "open" t.string "visibility", :default => "open"
@ -354,8 +353,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.string "actor_type" t.string "actor_type"
t.integer "target_id" t.integer "target_id"
t.string "target_type" t.string "target_type"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.string "role" t.string "role"
end end
@ -384,8 +383,8 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
create_table "subscribes", :force => true do |t| create_table "subscribes", :force => true do |t|
t.string "subscribeable_type" t.string "subscribeable_type"
t.integer "user_id" t.integer "user_id"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.boolean "status", :default => true t.boolean "status", :default => true
t.integer "project_id" t.integer "project_id"
t.decimal "subscribeable_id", :precision => 50, :scale => 0 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| create_table "users", :force => true do |t|
t.string "name" t.string "name"
t.string "email", :default => "", :null => false t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false t.string "encrypted_password", :default => "", :null => false
t.string "password_salt", :default => "", :null => false
t.string "reset_password_token" t.string "reset_password_token"
t.datetime "remember_created_at" t.datetime "remember_created_at"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.text "ssh_key"
t.string "uname" t.string "uname"
t.string "role" 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.string "confirmation_token"
t.datetime "confirmed_at" t.datetime "confirmed_at"
t.datetime "confirmation_sent_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.text "professional_experience"
t.string "site" t.string "site"
t.string "company" t.string "company"
@ -416,11 +414,11 @@ ActiveRecord::Schema.define(:version => 20120730214052) do
t.string "avatar_content_type" t.string "avatar_content_type"
t.integer "avatar_file_size" t.integer "avatar_file_size"
t.datetime "avatar_updated_at" t.datetime "avatar_updated_at"
t.integer "failed_attempts", :default => 0 t.integer "failed_attempts", :default => 0
t.string "unlock_token" t.string "unlock_token"
t.datetime "locked_at" t.datetime "locked_at"
t.string "authentication_token" t.string "authentication_token"
t.integer "build_priority", :default => 50 t.integer "build_priority", :default => 50
end end
add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token" 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", ["uname"], :name => "index_users_on_uname", :unique => true
add_index "users", ["unlock_token"], :name => "index_users_on_unlock_token", :unique => true add_index "users", ["unlock_token"], :name => "index_users_on_unlock_token", :unique => true
end end