build list items and more statuses
This commit is contained in:
parent
62d0985fcb
commit
82869f57a7
|
@ -1,12 +1,12 @@
|
|||
class BuildListsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
before_filter :find_platform, :only => [:index, :filter]
|
||||
before_filter :find_repository, :only => [:index, :filter]
|
||||
before_filter :find_project, :only => [:index, :filter]
|
||||
before_filter :find_platform, :only => [:index, :filter, :show]
|
||||
before_filter :find_repository, :only => [:index, :filter, :show]
|
||||
before_filter :find_project, :only => [:index, :filter, :show]
|
||||
before_filter :find_arches, :only => [:index, :filter]
|
||||
before_filter :find_branches, :only => [:index, :filter]
|
||||
|
||||
before_filter :find_build_list_by_bs, :only => [:status_build, :pre_build]
|
||||
before_filter :find_build_list_by_bs, :only => [:status_build, :pre_build, :new_bbdt]
|
||||
|
||||
def index
|
||||
@build_lists = @project.build_lists.recent.paginate :page => params[:page]
|
||||
|
@ -20,13 +20,20 @@ class BuildListsController < ApplicationController
|
|||
render :action => "index"
|
||||
end
|
||||
|
||||
def show
|
||||
@build_list = @project.build_lists.find(params[:id])
|
||||
@item_groups = @build_list.items.group_by_level
|
||||
end
|
||||
|
||||
def status_build
|
||||
#
|
||||
# @build_list.status = params[:status]
|
||||
# @build_list.container_path = params[:container_path]
|
||||
# @build_list.notified_at = Time.now
|
||||
#
|
||||
# @build_list.save
|
||||
@item = @build_list.items.find_by_name!(params[:package_name])
|
||||
@item.status = params[:status]
|
||||
@item.save
|
||||
|
||||
@build_list.container_path = params[:container_path]
|
||||
@build_list.notified_at = Time.now
|
||||
|
||||
@build_list.save
|
||||
|
||||
render :nothing => true, :status => 200
|
||||
end
|
||||
|
@ -61,6 +68,15 @@ class BuildListsController < ApplicationController
|
|||
render :nothing => true, :status => 200
|
||||
end
|
||||
|
||||
def new_bbdt
|
||||
@build_list.name = params[:name]
|
||||
@build_list.additional_repos = params[:additional_repos]
|
||||
@build_list.set_items(params[:items])
|
||||
@build_list.save
|
||||
|
||||
render :nothing => true, :status => 200
|
||||
end
|
||||
|
||||
protected
|
||||
def find_platform
|
||||
@platform = Platform.find params[:platform_id]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class BuildList < ActiveRecord::Base
|
||||
belongs_to :project
|
||||
belongs_to :arch
|
||||
has_many :items, :class_name => "BuildList::Item", :dependent => :destroy
|
||||
|
||||
validates :project_id, :presence => true
|
||||
validates :branch_name, :presence => true
|
||||
|
@ -8,12 +9,8 @@ class BuildList < ActiveRecord::Base
|
|||
BUILD_PENDING = 2
|
||||
BUILD_STARTED = 3
|
||||
|
||||
STATUSES = [BuildServer::SUCCESS, BUILD_PENDING, BUILD_STARTED, BuildServer::BUILD_ERROR] #, BuildServer::DEPENDENCIES_FAIL, BuildServer::SRPM_NOT_FOUND, BuildServer::MOCK_NOT_FOUND]
|
||||
# BUILD_ERROR_STATUSES = [ BuildServer::BUILD_ERROR, BuildServer::MOCK_NOT_FOUND, BuildServer::DEPENDENCIES_FAIL, BuildServer::SRPM_NOT_FOUND]
|
||||
STATUSES = [BuildServer::SUCCESS, BUILD_PENDING, BUILD_STARTED, BuildServer::BUILD_ERROR]
|
||||
HUMAN_STATUSES = { BuildServer::BUILD_ERROR => :build_error,
|
||||
# BuildServer::MOCK_NOT_FOUND => :mock_not_found,
|
||||
# BuildServer::DEPENDENCIES_FAIL => :dependencies_fail,
|
||||
# BuildServer::SRPM_NOT_FOUND => :srpm_not_found,
|
||||
BUILD_PENDING => :build_pending,
|
||||
BUILD_STARTED => :build_started,
|
||||
BuildServer::SUCCESS => :success
|
||||
|
@ -44,6 +41,8 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
}
|
||||
|
||||
serialize :additional_repos
|
||||
|
||||
def self.human_status(status)
|
||||
I18n.t("layout.build_lists.statuses.#{HUMAN_STATUSES[status]}")
|
||||
end
|
||||
|
@ -52,4 +51,14 @@ class BuildList < ActiveRecord::Base
|
|||
self.class.human_status(status)
|
||||
end
|
||||
|
||||
def set_items(items_hash)
|
||||
self.items = []
|
||||
|
||||
items_hash.each do |level, items|
|
||||
items.each do |item|
|
||||
self.items << self.items.build(:name => item, :level => level.to_i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,38 @@
|
|||
class BuildList::Item < ActiveRecord::Base
|
||||
belongs_to :build_list
|
||||
|
||||
attr_protected :build_list_id
|
||||
|
||||
STATUSES = [BuildServer::SUCCESS, BuildServer::DEPENDENCIES_FAIL, BuildServer::SRPM_NOT_FOUND, BuildServer::MOCK_NOT_FOUND]
|
||||
HUMAN_STATUSES = {
|
||||
BuildServer::MOCK_NOT_FOUND => :mock_not_found,
|
||||
BuildServer::DEPENDENCIES_FAIL => :dependencies_fail,
|
||||
BuildServer::SRPM_NOT_FOUND => :srpm_not_found,
|
||||
BuildServer::SUCCESS => :success
|
||||
}
|
||||
|
||||
scope :recent, order("level ASC, name ASC")
|
||||
|
||||
def self.group_by_level
|
||||
items = scoped({}).recent
|
||||
|
||||
groups = []
|
||||
current_level = -1
|
||||
items.each do |item|
|
||||
groups << [] if current_level < item.level
|
||||
groups.last << item
|
||||
current_level = item.level
|
||||
end
|
||||
|
||||
groups
|
||||
end
|
||||
|
||||
def self.human_status(status)
|
||||
I18n.t("layout.build_lists.items.statuses.#{HUMAN_STATUSES[status]}")
|
||||
end
|
||||
|
||||
def human_status
|
||||
self.class.human_status(status)
|
||||
end
|
||||
|
||||
end
|
|
@ -12,4 +12,4 @@
|
|||
.inner
|
||||
= render :partial => "build_lists/build_lists", :object => @build_lists
|
||||
|
||||
- content_for :sidebar, render(:partial => 'git/shared/sidebar')
|
||||
-#- content_for :sidebar, render(:partial => 'sidebar')
|
|
@ -0,0 +1,76 @@
|
|||
.block
|
||||
.secondary-navigation
|
||||
%ul.wat-cf
|
||||
%li.first= link_to t("layout.build_lists.current"), platform_repository_project_path(@platform, @repository, @project) + "#build_lists"
|
||||
%li= link_to t("layout.build_lists.all"), platform_repository_project_build_lists_path(@platform, @repository, @project)
|
||||
|
||||
.content
|
||||
.inner
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.build_list.name")
|
||||
\:
|
||||
= @build_list.present? ? @build_list.name : t("layout.build_lists.name_not_yet_defined")
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.build_list.bs_id")
|
||||
\:
|
||||
= @build_list.bs_id
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.build_list.container_path")
|
||||
\:
|
||||
= @build_list.container_path
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.build_list.status")
|
||||
\:
|
||||
= @build_list.human_status
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.build_list.branch_name")
|
||||
\:
|
||||
= @build_list.branch_name
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.build_list.project")
|
||||
\:
|
||||
= @build_list.project.name
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.build_list.arch")
|
||||
\:
|
||||
= @build_list.arch.name
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.build_list.notified_at")
|
||||
\:
|
||||
= @build_list.notified_at
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.build_list.is_circle")
|
||||
\:
|
||||
= @build_list.is_circle
|
||||
|
||||
%p
|
||||
%b
|
||||
= t("activerecord.attributes.build_list.additional_repos")
|
||||
\:
|
||||
= @build_list.additional_repos
|
||||
|
||||
.block
|
||||
.content
|
||||
.inner
|
||||
- @item_groups.each_with_index do |group, level|
|
||||
%h3.title Level ##{level}
|
||||
%table.table
|
||||
%tr
|
||||
%th.first= t("activerecord.attributes.build_list/item.name")
|
||||
%th.last= t("activerecord.attributes.build_list/item.status")
|
||||
|
||||
- group.each do |item|
|
||||
%tr{:class => cycle("odd", "even")}
|
||||
%td= item.name
|
||||
%td.last= item.human_status
|
||||
|
||||
-#- content_for :sidebar, render(:partial => 'sidebar')
|
|
@ -90,6 +90,13 @@ ru:
|
|||
created_at_end: "Время постановки на сборку по:"
|
||||
notified_at_start: "Время последнего обновления от BS с:"
|
||||
notified_at_end: "Время последнего обновления от BS по:"
|
||||
items:
|
||||
statuses:
|
||||
build_error: ошибка сборки
|
||||
mock_not_found: mock не найден
|
||||
dependencies_fail: dependencies fail
|
||||
srpm_not_found: srpm не найден
|
||||
success: собран
|
||||
statuses:
|
||||
build_error: ошибка сборки
|
||||
mock_not_found: mock не найден
|
||||
|
@ -140,6 +147,8 @@ ru:
|
|||
project: Проект
|
||||
rpm: RPM
|
||||
user: Пользователь
|
||||
build_list: Сборочный лист
|
||||
build_list item: Элемент сборочного листа
|
||||
|
||||
attributes:
|
||||
repository:
|
||||
|
@ -198,6 +207,7 @@ ru:
|
|||
|
||||
build_list:
|
||||
bs_id: Id
|
||||
name: Название
|
||||
container_path: Путь до контейнера
|
||||
status: Статус
|
||||
branch_name: Branch
|
||||
|
@ -207,5 +217,12 @@ ru:
|
|||
arch: Архитектура
|
||||
is_circle: Циклическая сборка
|
||||
notified_at: Информация получена
|
||||
additional_repos: Дополнительные репозитории
|
||||
updated_at: Обновлен
|
||||
created_at: Создан
|
||||
|
||||
build_list/item:
|
||||
name: Название
|
||||
level: Уровень
|
||||
status: Статус
|
||||
build_list: Сборочный лист
|
||||
|
|
|
@ -10,7 +10,7 @@ Rosa::Application.routes.draw do
|
|||
resources :repositories do
|
||||
resources :projects do
|
||||
resource :repo, :controller => "git/repositories", :only => [:show]
|
||||
resources :build_lists, :only => [:index] do
|
||||
resources :build_lists, :only => [:index, :show] do
|
||||
collection do
|
||||
get :recent
|
||||
post :filter
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
class CreateBuildListItems < ActiveRecord::Migration
|
||||
def self.up
|
||||
create_table :build_list_items, :force => true do |t|
|
||||
t.string :name
|
||||
t.integer :level
|
||||
t.integer :status
|
||||
|
||||
t.integer :build_list_id
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :build_list_items, :build_list_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :build_list_items, :build_list_id
|
||||
|
||||
drop_table :build_list_items
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class AddAdditionalReposToBuildLists < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :build_lists, :additional_repos, :text
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :build_lists, :additional_repos
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class AddNameToBuildLists < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :build_lists, :name, :string
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :build_lists, :name
|
||||
end
|
||||
end
|
17
db/schema.rb
17
db/schema.rb
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20110407144147) do
|
||||
ActiveRecord::Schema.define(:version => 20110408134718) do
|
||||
|
||||
create_table "arches", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
|
@ -20,6 +20,17 @@ ActiveRecord::Schema.define(:version => 20110407144147) do
|
|||
|
||||
add_index "arches", ["name"], :name => "index_arches_on_name", :unique => true
|
||||
|
||||
create_table "build_list_items", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "level"
|
||||
t.integer "status"
|
||||
t.integer "build_list_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
add_index "build_list_items", ["build_list_id"], :name => "index_build_list_items_on_build_list_id"
|
||||
|
||||
create_table "build_lists", :force => true do |t|
|
||||
t.integer "bs_id"
|
||||
t.string "container_path"
|
||||
|
@ -30,7 +41,9 @@ ActiveRecord::Schema.define(:version => 20110407144147) do
|
|||
t.datetime "notified_at"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.boolean "is_circle", :default => false
|
||||
t.boolean "is_circle", :default => false
|
||||
t.text "additional_repos"
|
||||
t.string "name"
|
||||
end
|
||||
|
||||
add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id"
|
||||
|
|
Loading…
Reference in New Issue