added #show action for product_build_list

This commit is contained in:
Vokhmin Alexey V 2012-11-06 22:01:54 +04:00
parent e39ca302d7
commit 6a7035d551
7 changed files with 56 additions and 14 deletions

View File

@ -2,9 +2,9 @@
class Platforms::ProductBuildListsController < Platforms::BaseController
before_filter :authenticate_user!, :except => [:status_build]
skip_before_filter :authenticate_user!, :only => [:index] if APP_CONFIG['anonymous_access']
load_and_authorize_resource :platform, :only => [:create, :destroy, :new]
load_and_authorize_resource :product, :through => :platform, :only => [:create, :destroy, :new]
load_and_authorize_resource :product_build_list, :through => :product, :only => [:create, :destroy, :new]
load_and_authorize_resource :platform, :only => [:create, :destroy, :new, :show]
load_and_authorize_resource :product, :through => :platform, :only => [:create, :destroy, :new, :show]
load_and_authorize_resource :product_build_list, :through => :product, :only => [:create, :destroy, :new, :show]
load_and_authorize_resource :only => [:index]
before_filter :authenticate_product_builder!, :only => [:status_build]
@ -16,8 +16,14 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
@arches = Arch.recent.map{ |a| [a.name, a.id] }
end
def show
end
def create
@product.product_build_lists.create! :base_url => "http://#{request.host_with_port}"
pbl = @product.product_build_lists.new params[:product_build_list]
pbl.project = @product.project
pbl.base_url = "http://#{request.host_with_port}"
pbl.save!
flash[:notice] = t('flash.product.build_started')
redirect_to [@platform, @product]
end

View File

@ -37,7 +37,7 @@ module BuildListsHelper
def build_list_version_link(build_list, str_version = false)
if build_list.commit_hash.present?
link_to str_version ? "#{shortest_hash_id @build_list.commit_hash} ( #{@build_list.project_version} )" : shortest_hash_id(build_list.commit_hash),
link_to str_version ? "#{shortest_hash_id build_list.commit_hash} ( #{build_list.project_version} )" : shortest_hash_id(build_list.commit_hash),
commit_path(build_list.project.owner, build_list.project, build_list.commit_hash)
else
build_list.project_version

View File

@ -25,7 +25,7 @@ class ProductBuildList < ActiveRecord::Base
validates :status, :inclusion => { :in => [BUILD_STARTED, BUILD_COMPLETED, BUILD_FAILED] }
attr_accessor :base_url
attr_accessible :status, :base_url, :branch, :arch_id, :project_id, :main_script, :iso_folder, :params, :project_version
attr_accessible :status, :base_url, :branch, :arch_id, :project_id, :main_script, :iso_folder, :params, :project_version, :commit_hash
attr_readonly :product_id

View File

@ -1,8 +1,13 @@
%tr{:class => cycle("odd", "even")}
%td= product_build_list.id
%td= product_build_list.human_status
%td= link_to nil, product_build_list.container_path
%td= link_to product_build_list.product.name, platform_product_path(product_build_list.product.platform, product_build_list.product)
- pbl = product_build_list
%td= link_to image_tag('x.png'), platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl), :method => :delete, :confirm => t("layout.confirm") if can?(:destroy, pbl) && pbl.can_destroy?
%td= l(product_build_list.updated_at, :format => :long)
- product = pbl.product
- platform = product.platform
- if pbl.project
%td= link_to pbl.id, platform_product_product_build_list_path(platform, product, pbl)
- else
%td= pbl.id
%td= product_build_list.human_status
%td= link_to nil, pbl.container_path
%td= link_to pbl.product.name, platform_product_path(platform, product)
%td= link_to image_tag('x.png'), platform_product_product_build_list_path(platform, product, pbl), :method => :delete, :confirm => t("layout.confirm") if can?(:destroy, pbl) && pbl.can_destroy?
%td= l(pbl.updated_at, :format => :long)

View File

@ -0,0 +1,31 @@
-set_meta_tags :title => [title_object(@product_build_list.product), t('layout.product_build_lists.show')]
= render 'submenu'
= render 'sidebar'
.leftlist= t("activerecord.attributes.product_build_lists.lst")
.rightlist= @product_build_list.product.try(:lst)
.both
.leftlist= t("activerecord.attributes.product_build_lists.project")
.rightlist= @product_build_list.project.try(:name_with_owner)
.both
.leftlist= t("activerecord.attributes.product_build_lists.project_version")
.rightlist= @product_build_list.project ? build_list_version_link(@product_build_list, true) : ''
.both
.leftlist= t("activerecord.attributes.product_build_lists.arch")
.rightlist= @product_build_list.arch.try(:name)
.both
.leftlist= t("activerecord.attributes.product_build_lists.main_script")
.rightlist= @product_build_list.main_script
.both
.leftlist= t("activerecord.attributes.product_build_lists.params")
.rightlist= @product_build_list.params
.both
.leftlist= t("activerecord.attributes.product_build_lists.iso_folder")
.rightlist= @product_build_list.iso_folder
.both

View File

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

View File

@ -18,7 +18,7 @@ module Modules
protected
def set_commit_and_version
if project_version.present? && commit_hash.blank?
if project && 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?