added migration, updated models, UI

This commit is contained in:
Vokhmin Alexey V 2012-11-06 18:13:16 +04:00
parent 541a739c12
commit ecec330b4d
12 changed files with 169 additions and 75 deletions

View File

@ -23,6 +23,7 @@ class Platforms::ProductsController < Platforms::BaseController
end
def create
@product.project = find_project
if @product.save
flash[:notice] = t('flash.product.saved')
redirect_to platform_product_path(@platform, @product)
@ -34,6 +35,7 @@ class Platforms::ProductsController < Platforms::BaseController
end
def update
@product.project = find_project
if @product.update_attributes(params[:product])
flash[:notice] = t('flash.product.saved')
redirect_to platform_product_path(@platform, @product)
@ -53,4 +55,19 @@ class Platforms::ProductsController < Platforms::BaseController
redirect_to platform_products_path(@platform)
end
def autocomplete_project
items = Project.accessible_by(current_ability, :membered).
search(params[:term]).search_order
items.select! {|e| e.repo.branches.count > 0}
render :json => items.map{ |p|
{:id => p.id, :label => p.name_with_owner, :value => p.name_with_owner}
}
end
protected
def find_project
args = params[:src_project].try(:split, '/') || []
(args.length == 2) ? Project.find_by_owner_and_name(*args) : nil
end
end

View File

@ -1,5 +1,7 @@
# -*- encoding : utf-8 -*-
class BuildList < ActiveRecord::Base
include Modules::Models::CommitAndVersion
belongs_to :project
belongs_to :arch
belongs_to :save_to_platform, :class_name => 'Platform'
@ -32,11 +34,6 @@ class BuildList < ActiveRecord::Base
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_include_repos')) unless build_for_platform.repository_ids.include? ir.to_i
}
}
validate lambda {
if commit_hash.blank? || project.repo.commit(commit_hash).blank?
errors.add :commit_hash, I18n.t('flash.build_list.wrong_commit_hash', :commit_hash => commit_hash)
end
}
LIVE_TIME = 4.week # for unpublished
MAX_LIVE_TIME = 3.month # for published
@ -115,7 +112,6 @@ class BuildList < ActiveRecord::Base
after_commit :place_build
after_destroy :delete_container
before_validation :set_commit_and_version
@queue = :clone_and_build
@ -349,13 +345,4 @@ class BuildList < ActiveRecord::Base
yield p
end
end
def set_commit_and_version
if project_version.present? && commit_hash.blank?
self.commit_hash = project.repo.commits(project_version.match(/^latest_(.+)/).to_a.last ||
project_version).try(:first).try(:id)
elsif project_version.blank? && commit_hash.present?
self.project_version = commit_hash
end
end
end

View File

@ -3,6 +3,7 @@ class Product < ActiveRecord::Base
ATTRS_TO_CLONE = [ 'build_path', 'build_script', 'counter', 'ks', 'menu', 'tar', 'use_cron', 'cron_tab' ]
belongs_to :platform
belongs_to :project
has_many :product_build_lists, :dependent => :destroy
after_validation :merge_tar_errors
@ -15,7 +16,9 @@ class Product < ActiveRecord::Base
scope :recent, order("name ASC")
attr_accessible :name, :counter, :ks, :menu, :tar, :cron_tab, :use_cron, :description, :build_script, :delete_tar
attr_accessible :name, :counter, :ks, :menu, :tar,
:cron_tab, :use_cron, :description, :build_script,
:delete_tar, :lst, :repos, :project_id
attr_readonly :platform_id
def delete_tar

View File

@ -1,5 +1,7 @@
# -*- encoding : utf-8 -*-
class ProductBuildList < ActiveRecord::Base
include Modules::Models::CommitAndVersion
BUILD_STARTED = 2
BUILD_COMPLETED = 0
BUILD_FAILED = 1
@ -15,12 +17,15 @@ class ProductBuildList < ActiveRecord::Base
}
belongs_to :product
belongs_to :project
belongs_to :arch
validates :product_id, :status, :presence => true
validates :status, :inclusion => { :in => [BUILD_STARTED, BUILD_COMPLETED, BUILD_FAILED] }
attr_accessor :base_url
attr_accessible :status, :base_url
attr_accessible :status, :base_url, :branch, :arch_id, :project_id
attr_readonly :product_id

View File

@ -37,6 +37,15 @@
= render "crontab", :form => f
%b
= t('layout.products.new_iso_builder')
%br
%br
= render 'iso_build_form', :f => f
.both
.both
.button_block
= submit_tag t("layout.save")

View File

@ -0,0 +1,10 @@
.leftlist= f.label :lst, t("activerecord.attributes.product.lst"), :class => :label
.rightlist= f.text_field :lst, :class => 'text_field'
.both
.leftlist= f.label :repos, t("activerecord.attributes.product.repos"), :class => :label
.rightlist= f.text_area :repos, :class => 'text_field resizable'
.both
.leftlist= f.label :project, t("activerecord.attributes.product.project"), :class => :label
.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)

View File

@ -1,6 +1,7 @@
en:
layout:
products:
new_iso_builder: Params for new ISO builder (betta version)
list: List
about: About product
build_lists_monitoring: Build lists monitoring
@ -55,3 +56,5 @@ en:
system_wide: System-wide
cron_tab: Cron tab
use_cron: Use cron
repos: Repositories
project: Project

View File

@ -1,6 +1,7 @@
ru:
layout:
products:
new_iso_builder: Параметры для нового сборщика ISO образов (бетта версия)
list: Список
about: О продукте
build_lists_monitoring: Мониторинг сборочных заданий
@ -55,3 +56,5 @@ ru:
system_wide: Общесистемный
cron_tab: Cron tab
use_cron: Использовать крон
repos: Репозитории
project: Проект

View File

@ -146,6 +146,7 @@ Rosa::Application.routes.draw do
resources :key_pairs, :only => [:create, :index, :destroy]
resources :products do
resources :product_build_lists, :only => [:create, :destroy]
collection { get :autocomplete_project }
end
resources :maintainers, :only => [:index]
end

View File

@ -0,0 +1,17 @@
class IntegrateNewIsoBuilderWithProducts < ActiveRecord::Migration
def change
add_column :products, :project_id, :integer
add_column :product_build_lists, :project_id, :integer
add_column :product_build_lists, :project_version, :string
add_column :product_build_lists, :commit_hash, :string
add_column :products, :lst, :string
add_column :product_build_lists, :lst, :string
add_column :products, :repos, :text
add_column :product_build_lists, :repo, :string
add_column :product_build_lists, :arch_id, :integer
end
end

View File

@ -11,14 +11,14 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20121005100158) do
ActiveRecord::Schema.define(:version => 20121106113338) do
create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false
t.string "kind"
t.text "data"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "advisories", :force => true do |t|
@ -53,8 +53,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) do
create_table "arches", :force => true do |t|
t.string "name", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "arches", ["name"], :name => "index_arches_on_name", :unique => true
@ -63,8 +63,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) do
t.integer "user_id"
t.string "provider"
t.string "uid"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "authentications", ["provider", "uid"], :name => "index_authentications_on_provider_and_uid", :unique => true
@ -75,8 +75,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) do
t.integer "level"
t.integer "status"
t.integer "build_list_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.string "version"
end
@ -110,8 +110,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) do
t.integer "project_id"
t.integer "arch_id"
t.datetime "notified_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "is_circle", :default => false
t.text "additional_repos"
t.string "name"
@ -142,8 +142,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) 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"
t.datetime "updated_at"
t.decimal "commentable_id", :precision => 50, :scale => 0
t.integer "project_id"
t.text "data"
@ -161,8 +161,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) 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"
t.datetime "updated_at"
end
create_table "flash_notifies", :force => true do |t|
@ -176,8 +176,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) do
create_table "groups", :force => true do |t|
t.integer "owner_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.string "uname"
t.integer "own_projects_count", :default => 0, :null => false
t.text "description"
@ -194,8 +194,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) 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"
t.datetime "updated_at"
t.integer "user_id"
t.datetime "closed_at"
t.integer "closed_by"
@ -255,14 +255,14 @@ ActiveRecord::Schema.define(:version => 20121005100158) do
t.string "description"
t.string "name", :null => false
t.integer "parent_platform_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
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"
t.string "distrib_type", :null => false
end
add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false
@ -271,16 +271,22 @@ ActiveRecord::Schema.define(:version => 20121005100158) 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"
t.datetime "updated_at"
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.integer "status", :default => 2, :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "project_id"
t.string "project_version"
t.string "commit_hash"
t.string "lst"
t.string "repo"
t.integer "arch_id"
end
add_index "product_build_lists", ["product_id"], :name => "index_product_build_lists_on_product_id"
@ -288,8 +294,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) do
create_table "products", :force => true do |t|
t.string "name", :null => false
t.integer "platform_id", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.text "build_script"
t.text "counter"
t.text "ks"
@ -301,6 +307,9 @@ ActiveRecord::Schema.define(:version => 20121005100158) do
t.text "cron_tab"
t.boolean "use_cron", :default => false
t.text "description"
t.integer "project_id"
t.string "lst"
t.text "repos"
end
create_table "project_imports", :force => true do |t|
@ -308,8 +317,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) do
t.string "name"
t.string "version"
t.datetime "file_mtime"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "platform_id"
end
@ -318,25 +327,25 @@ ActiveRecord::Schema.define(:version => 20121005100158) 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"
t.datetime "updated_at"
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"
t.datetime "updated_at"
t.integer "owner_id"
t.string "owner_type"
t.string "visibility", :default => "open"
t.text "description"
t.string "ancestry"
t.boolean "has_issues", :default => true
t.boolean "has_wiki", :default => false
t.string "srpm_file_name"
t.string "srpm_content_type"
t.integer "srpm_file_size"
t.datetime "srpm_updated_at"
t.string "srpm_content_type"
t.boolean "has_wiki", :default => false
t.string "default_branch", :default => "master"
t.boolean "is_package", :default => true, :null => false
t.integer "average_build_time", :default => 0, :null => false
@ -364,8 +373,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) do
t.string "token"
t.boolean "approved", :default => false
t.boolean "rejected", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.string "interest"
t.text "more"
t.string "language"
@ -379,16 +388,16 @@ ActiveRecord::Schema.define(:version => 20121005100158) 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"
t.datetime "updated_at"
t.string "role"
end
create_table "repositories", :force => true do |t|
t.string "description", :null => false
t.integer "platform_id", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.string "name", :null => false
t.boolean "publish_without_qa", :default => true
end
@ -400,8 +409,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) do
t.boolean "new_comment_reply", :default => true
t.boolean "new_issue", :default => true
t.boolean "issue_assign", :default => true
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "new_comment_commit_owner", :default => true
t.boolean "new_comment_commit_repo_owner", :default => true
t.boolean "new_comment_commit_commentor", :default => true
@ -412,8 +421,8 @@ ActiveRecord::Schema.define(:version => 20121005100158) 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"
t.datetime "updated_at"
t.boolean "status", :default => true
t.integer "project_id"
t.decimal "subscribeable_id", :precision => 50, :scale => 0
@ -421,21 +430,18 @@ ActiveRecord::Schema.define(:version => 20121005100158) do
create_table "users", :force => true do |t|
t.string "name"
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "email", :default => "", :null => false
t.string "encrypted_password", :limit => 128, :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.text "ssh_key"
t.string "uname"
t.string "role"
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.string "language", :default => "en"
t.integer "own_projects_count", :default => 0, :null => false
t.text "professional_experience"
t.string "site"
t.string "company"
@ -444,11 +450,14 @@ ActiveRecord::Schema.define(:version => 20121005100158) 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 "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_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"

View File

@ -0,0 +1,30 @@
# -*- encoding : utf-8 -*-
module Modules
module Models
module CommitAndVersion
extend ActiveSupport::Concern
included do
validate lambda {
if commit_hash.blank? || project.repo.commit(commit_hash).blank?
errors.add :commit_hash, I18n.t('flash.build_list.wrong_commit_hash', :commit_hash => commit_hash)
end
}
before_validation :set_commit_and_version
end
protected
def set_commit_and_version
if project_version.present? && commit_hash.blank?
self.commit_hash = project.repo.commits(project_version.match(/^latest_(.+)/).to_a.last ||
project_version).try(:first).try(:id)
elsif project_version.blank? && commit_hash.present?
self.project_version = commit_hash
end
end
end
end
end