Merge issues with master

This commit is contained in:
konstantin.grabar 2011-12-26 13:26:13 +04:00
commit 5237939f49
31 changed files with 536 additions and 391 deletions

View File

@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
layout :layout_by_resource layout :layout_by_resource
before_filter lambda { EventLog.current_controller = self }, before_filter lambda { EventLog.current_controller = self },
:only => [:create, :destroy, :open_id, :auto_build, :process_build, :cancel, :publish, :change_visibility] # :update :only => [:create, :destroy, :open_id, :auto_build, :cancel, :publish, :change_visibility] # :update
after_filter lambda { EventLog.current_controller = nil } after_filter lambda { EventLog.current_controller = nil }
helper_method :get_owner helper_method :get_owner

View File

@ -1,67 +1,90 @@
class BuildListsController < ApplicationController class BuildListsController < ApplicationController
CALLBACK_ACTIONS = [:status_build, :pre_build, :post_build, :circle_build, :new_bbdt] CALLBACK_ACTIONS = [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt]
NESTED_ACTIONS = [:index, :new, :create]
before_filter :authenticate_user!, :except => CALLBACK_ACTIONS before_filter :authenticate_user!, :except => CALLBACK_ACTIONS
before_filter :authenticate_build_service!, :only => CALLBACK_ACTIONS before_filter :authenticate_build_service!, :only => CALLBACK_ACTIONS
before_filter :find_project, :only => [:index, :filter, :show, :publish] before_filter :find_project, :only => NESTED_ACTIONS
before_filter :find_arches, :only => [:index, :filter, :all] before_filter :find_build_list, :only => [:show, :publish, :cancel]
before_filter :find_project_versions, :only => [:index, :filter] before_filter :find_build_list_by_bs, :only => [:publish_build, :status_build, :pre_build, :post_build]
before_filter :find_build_list_by_bs, :only => [:status_build, :pre_build, :post_build]
load_and_authorize_resource :except => CALLBACK_ACTIONS load_and_authorize_resource :project, :only => NESTED_ACTIONS
load_and_authorize_resource :through => :project, :only => NESTED_ACTIONS, :shallow => true
load_and_authorize_resource :except => CALLBACK_ACTIONS.concat(NESTED_ACTIONS)
def all def index
if params[:filter] filter_params = params[:filter] || {}
@filter = BuildList::Filter.new(nil, params[:filter]) if @project
@build_lists = @filter.find.paginate :page => params[:page] @action_url = project_build_lists_path(@project)
else else
@filter = BuildList::Filter.new(nil) @action_url = build_lists_path
@build_lists = BuildList.recent.paginate :page => params[:page]
end end
@action_url = all_build_lists_path
@filter = BuildList::Filter.new(@project, filter_params)
@build_lists = @filter.find.accessible_by(current_ability).recent.paginate :page => params[:page]
@build_server_status = begin @build_server_status = begin
BuildServer.get_status BuildServer.get_status
rescue Exception # Timeout::Error rescue Exception # Timeout::Error
{} {}
end end
render :action => 'index'
end end
def cancel def new
build_list = BuildList.find(params[:id]) @build_list = BuildList.new
if build_list.cancel_build_list end
redirect_to :back, :notice => t('layout.build_lists.cancel_successed')
def create
notices, errors = [], []
Arch.where(:id => params[:archs]).each do |arch|
Platform.main.where(:id => params[:bpls]).each do |bpl|
@build_list = @project.build_lists.build(params[:build_list])
@build_list.bpl = bpl; @build_list.arch = arch; @build_list.user = current_user
flash_options = {:project_version => @build_list.project_version, :arch => arch.name, :bpl => bpl.name, :pl => @build_list.pl}
if @build_list.save
notices << t("flash.build_list.saved", flash_options)
else else
redirect_to :back, :notice => t('layout.build_lists.cancel_failed') errors << t("flash.build_list.save_error", flash_options)
end end
end end
def index
@build_lists = @project.build_lists.recent.paginate :page => params[:page]
@filter = BuildList::Filter.new(@project)
@action_url = project_build_lists_path(@project)
end end
errors << t("flash.build_list.no_arch_or_platform_selected") if errors.blank? and notices.blank?
def filter if errors.present?
@filter = BuildList::Filter.new(@project, params[:filter]) @build_list ||= BuildList.new
@build_lists = @filter.find.paginate :page => params[:page] flash[:error] = errors.join('<br>').html_safe
@action_url = project_build_lists_path(@project) render :action => :new
else
render :action => "index" flash[:notice] = notices.join('<br>').html_safe
redirect_to @project
end
end end
def show def show
@build_list = @project.build_lists.find(params[:id])
@item_groups = @build_list.items.group_by_level @item_groups = @build_list.items.group_by_level
end end
def publish def publish
@build_list = @project.build_lists.find(params[:id]) if @build_list.publish
@build_list.publish redirect_to :back, :notice => t('layout.build_lists.publish_success')
else
redirect_to :back, :notice => t('layout.build_lists.publish_fail')
end
end
redirect_to project_build_lists_path(@project) def cancel
if @build_list.cancel
redirect_to :back, :notice => t('layout.build_lists.cancel_success')
else
redirect_to :back, :notice => t('layout.build_lists.cancel_fail')
end
end
def publish_build
@build_list.status = (params[:status].to_i == 0 ? BuildList::BUILD_PUBLISHED : BuildList::FAILED_PUBLISH)
@build_list.notified_at = Time.current
@build_list.save
render :nothing => true, :status => 200
end end
def status_build def status_build
@ -71,7 +94,6 @@ class BuildListsController < ApplicationController
@build_list.container_path = params[:container_path] @build_list.container_path = params[:container_path]
@build_list.notified_at = Time.current @build_list.notified_at = Time.current
@build_list.save @build_list.save
render :nothing => true, :status => 200 render :nothing => true, :status => 200
@ -80,7 +102,6 @@ class BuildListsController < ApplicationController
def pre_build def pre_build
@build_list.status = BuildServer::BUILD_STARTED @build_list.status = BuildServer::BUILD_STARTED
@build_list.notified_at = Time.current @build_list.notified_at = Time.current
@build_list.save @build_list.save
render :nothing => true, :status => 200 render :nothing => true, :status => 200
@ -90,7 +111,6 @@ class BuildListsController < ApplicationController
@build_list.status = params[:status] @build_list.status = params[:status]
@build_list.container_path = params[:container_path] @build_list.container_path = params[:container_path]
@build_list.notified_at = Time.current @build_list.notified_at = Time.current
@build_list.save @build_list.save
render :nothing => true, :status => 200 render :nothing => true, :status => 200
@ -100,7 +120,6 @@ class BuildListsController < ApplicationController
@build_list.is_circle = true @build_list.is_circle = true
@build_list.container_path = params[:container_path] @build_list.container_path = params[:container_path]
@build_list.notified_at = Time.current @build_list.notified_at = Time.current
@build_list.save @build_list.save
render :nothing => true, :status => 200 render :nothing => true, :status => 200
@ -123,16 +142,11 @@ class BuildListsController < ApplicationController
protected protected
def find_project def find_project
@project = Project.find params[:project_id] @project = Project.find_by_id params[:project_id]
end end
def find_arches def find_build_list
@arches = Arch.recent @build_list = BuildList.find(params[:id])
end
def find_project_versions
@git_repository = @project.git_repository
@project_versions = @project.versions
end end
def find_build_list_by_bs def find_build_list_by_bs

View File

@ -10,7 +10,7 @@ class PlatformsController < ApplicationController
def build_all def build_all
@platform.repositories.each do |repository| @platform.repositories.each do |repository|
repository.projects.each do |project| repository.projects.each do |project|
project.delay.build_for(@platform) project.delay.build_for(@platform, current_user)
end end
end end
@ -30,7 +30,7 @@ class PlatformsController < ApplicationController
{:name => p.name, {:name => p.name,
:architectures => ['i586', 'x86_64'], :architectures => ['i586', 'x86_64'],
:repositories => p.repositories.map(&:name), :repositories => p.repositories.map(&:name),
:url => "http://#{request.host_with_port}/downloads/#{p.name}/repository/"} :url => p.public_downloads_url(request.host_with_port)}
end end
} }
end end

View File

@ -4,14 +4,12 @@ class ProjectsController < ApplicationController
belongs_to :user, :group, :polymorphic => true, :optional => true belongs_to :user, :group, :polymorphic => true, :optional => true
before_filter :authenticate_user!, :except => :auto_build before_filter :authenticate_user!, :except => :auto_build
before_filter :find_project, :only => [:show, :edit, :update, :destroy, :fork, :build, :process_build] before_filter :find_project, :only => [:show, :edit, :update, :destroy, :fork]
before_filter :get_paths, :only => [:new, :create, :edit, :update] before_filter :get_paths, :only => [:new, :create, :edit, :update]
load_and_authorize_resource load_and_authorize_resource
def index def index
# puts parent.inspect
# puts parent.is_a? User
@projects = if parent? and !parent.nil? @projects = if parent? and !parent.nil?
parent.projects parent.projects
else else
@ -95,52 +93,6 @@ class ProjectsController < ApplicationController
render :nothing => true render :nothing => true
end end
def build
@arches = Arch.recent
@bpls = Platform.main
@pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.name}", rep.platform.id] }
@project_versions = @project.versions
end
def process_build
@arch_ids = params[:build][:arches].select{|_,v| v == "1"}.collect{|x| x[0].to_i }
@arches = Arch.where(:id => @arch_ids)
@project_version = params[:build][:project_version]
bpls_ids = params[:build][:bpl].blank? ? [] : params[:build][:bpl].select{|_,v| v == "1"}.collect{|x| x[0].to_i }
bpls = Platform.where(:id => bpls_ids)
pl = Platform.find params[:build][:pl]
update_type = params[:build][:update_type]
build_requires = params[:build][:build_requires]
@project_versions = @project.versions
if !check_arches || !check_project_versions
@arches = Arch.recent
@bpls = Platform.main
@pls = @project.repositories.collect { |rep| ["#{rep.platform.name}/#{rep.name}", rep.platform.id] }
render :action => "build"
else
flash[:notice], flash[:error] = "", ""
@arches.each do |arch|
bpls.each do |bpl|
build_list = @project.build_lists.new(:arch => arch, :project_version => @project_version, :pl => pl, :bpl => bpl, :update_type => update_type, :build_requires => build_requires)
if build_list.save
flash[:notice] += t("flash.build_list.saved", :project_version => @project_version, :arch => arch.name, :bpl => bpl.name, :pl => pl)
else
flash[:error] += t("flash.build_list.save_error", :project_version => @project_version, :arch => arch.name, :bpl => bpl.name, :pl => pl)
end
end
end
redirect_to project_path(@project)
end
end
protected protected
def get_paths def get_paths
@ -161,28 +113,4 @@ class ProjectsController < ApplicationController
def find_project def find_project
@project = Project.find params[:id] @project = Project.find params[:id]
end end
def check_arches
if @arch_ids.blank?
flash[:error] = t("flash.build_list.no_arch_selected")
false
elsif @arch_ids.length != @arches.length
flash[:error] = t("flash.build_list.no_arch_found")
false
else
true
end
end
def check_project_versions
if @project_version.blank?
flash[:error] = t("flash.build_list.no_project_version_selected")
false
elsif !@project_versions.flatten.include?(@project_version)
flash[:error] = t("flash.build_list.no_project_version_found", :project_version => @project_version)
false
else
true
end
end
end end

View File

@ -43,22 +43,26 @@ class Ability
can :create, Project can :create, Project
can :create, Group can :create, Group
can :publish, BuildList do |build_list| can :publish, BuildList do |build_list|
build_list.can_published? && build_list.project.relations.exists?(:object_type => 'User', :object_id => user.id) build_list.can_publish? && build_list.project.relations.exists?(:object_type => 'User', :object_id => user.id)
end end
can :read, BuildList do |build_list| can [:index, :read], BuildList, ["build_lists.project_id IN (SELECT id FROM projects WHERE visibility = ?)", 'open'] do |build_list|
build_list.project.public? || build_list.project.relations.exists?(:object_type => 'User', :object_id => user.id) build_list.project.public?
end end
can [:index, :read], BuildList, build_lists_in_relations_with(:object_type => 'User', :object_id => user.id) do |build_list|
build_list.project.relations.exists?(:object_type => 'User', :object_id => user.id)
end
can [:read, :create], PrivateUser, :platform => {:owner_type => 'User', :owner_id => user.id} can [:read, :create], PrivateUser, :platform => {:owner_type => 'User', :owner_id => user.id}
# If rule has multiple conditions CanCan joins them by 'AND' sql operator # If rule has multiple conditions CanCan joins them by 'AND' sql operator
can [:read, :update, :process_build, :build, :destroy], Project, :owner_type => 'User', :owner_id => user.id can [:read, :update, :destroy], Project, :owner_type => 'User', :owner_id => user.id
#can :read, Project, :relations => {:role => 'reader'} #can :read, Project, :relations => {:role => 'reader'}
can :read, Project, projects_in_relations_with(:role => 'reader', :object_type => 'User', :object_id => user.id) do |project| can :read, Project, projects_in_relations_with(:role => 'reader', :object_type => 'User', :object_id => user.id) do |project|
#The can? and cannot? call cannot be used with a raw sql 'can' definition. #The can? and cannot? call cannot be used with a raw sql 'can' definition.
project.relations.exists?(:role => 'reader', :object_type => 'User', :object_id => user.id) project.relations.exists?(:role => 'reader', :object_type => 'User', :object_id => user.id)
end end
#can [:update, :process_build, :build], Project, :relations => {:role => 'writer'} #can [:update], Project, :relations => {:role => 'writer'}
can [:read, :update, :process_build, :build], Project, projects_in_relations_with(:role => ['writer', 'admin'], :object_type => 'User', :object_id => user.id) do |project| can [:read, :update], Project, projects_in_relations_with(:role => ['writer', 'admin'], :object_type => 'User', :object_id => user.id) do |project|
project.relations.exists?(:role => ['writer', 'admin'], :object_type => 'User', :object_id => user.id) project.relations.exists?(:role => ['writer', 'admin'], :object_type => 'User', :object_id => user.id)
end end
@ -132,23 +136,23 @@ class Ability
# Same rights for groups: # Same rights for groups:
can [:read, :create], PrivateUser, :platform => {:owner_type => 'Group', :owner_id => user.group_ids} can [:read, :create], PrivateUser, :platform => {:owner_type => 'Group', :owner_id => user.group_ids}
can :publish, BuildList do |build_list| can :publish, BuildList do |build_list|
build_list.can_published? && build_list.project.relations.exists?(:object_type => 'Group', :object_id => user.group_ids) build_list.can_publish? && build_list.project.relations.exists?(:object_type => 'Group', :object_id => user.group_ids)
end end
can :read, BuildList do |build_list| can [:index, :read], BuildList, build_lists_in_relations_with(:object_type => 'Group', :object_id => user.group_ids) do |build_list|
build_list.project.public? || build_list.project.relations.exists?(:object_type => 'Group', :object_id => user.group_ids) build_list.project.relations.exists?(:object_type => 'Group', :object_id => user.group_ids)
end end
can :manage_collaborators, Project, projects_in_relations_with(:role => 'admin', :object_type => 'Group', :object_id => user.group_ids) do |project| can :manage_collaborators, Project, projects_in_relations_with(:role => 'admin', :object_type => 'Group', :object_id => user.group_ids) do |project|
project.relations.exists? :object_id => user.group_ids, :object_type => 'Group', :role => 'admin' project.relations.exists? :object_id => user.group_ids, :object_type => 'Group', :role => 'admin'
end end
can [:read, :update, :process_build, :build, :destroy], Project, :owner_type => 'Group', :owner_id => user.group_ids can [:read, :update, :destroy], Project, :owner_type => 'Group', :owner_id => user.group_ids
#can :read, Project, :relations => {:role => 'reader', :object_type => 'Group', :object_id => user.group_ids} #can :read, Project, :relations => {:role => 'reader', :object_type => 'Group', :object_id => user.group_ids}
can :read, Project, projects_in_relations_with(:role => 'reader', :object_type => 'Group', :object_id => user.group_ids) do |project| can :read, Project, projects_in_relations_with(:role => 'reader', :object_type => 'Group', :object_id => user.group_ids) do |project|
project.relations.exists?(:role => 'reader', :object_type => 'Group', :object_id => user.group_ids) project.relations.exists?(:role => 'reader', :object_type => 'Group', :object_id => user.group_ids)
end end
#can [:update, :process_build, :build], Project, :relations => {:role => 'writer', :object_type => 'Group', :object_id => user.group_ids} #can [:update], Project, :relations => {:role => 'writer', :object_type => 'Group', :object_id => user.group_ids}
can [:read, :update, :process_build, :build], Project, projects_in_relations_with(:role => ['writer', 'admin'], :object_type => 'Group', :object_id => user.group_ids) do |project| can [:read, :update], Project, projects_in_relations_with(:role => ['writer', 'admin'], :object_type => 'Group', :object_id => user.group_ids) do |project|
project.relations.exists?(:role => ['writer', 'admin'], :object_type => 'Group', :object_id => user.group_ids) project.relations.exists?(:role => ['writer', 'admin'], :object_type => 'Group', :object_id => user.group_ids)
end end
@ -165,6 +169,7 @@ class Ability
end end
can(:fork, Project) {|p| can? :read, p} can(:fork, Project) {|p| can? :read, p}
can(:create, BuildList) {|bl| can? :update, bl.project}
# Things that can not do simple user # Things that can not do simple user
cannot :create, [Platform, User] cannot :create, [Platform, User]
@ -202,6 +207,16 @@ class Ability
return opts.values.unshift query return opts.values.unshift query
end end
def build_lists_in_relations_with(opts)
query = "build_lists.project_id IN (SELECT target_id FROM relations WHERE relations.target_type = 'Project'"
opts.each do |key, value|
query = query + " AND relations.#{ key } #{ value.class == Array ? 'IN (?)' : '= ?' } "
end
query = query + ")"
return opts.values.unshift query
end
## Sub query for project relations ## Sub query for project relations
#def projects_in_relations_with(opts={}) #def projects_in_relations_with(opts={})
# ["projects.id IN (SELECT target_id FROM relations WHERE relations.object_id #{ opts[:object_id].class == Array ? 'IN (?)' : '= ?' } AND relations.object_type = '#{ opts[:object_type] }' AND relations.target_type = 'Platform') AND relations.role", opts[:object_id]] # ["projects.id IN (SELECT target_id FROM relations WHERE relations.object_id #{ opts[:object_id].class == Array ? 'IN (?)' : '= ?' } AND relations.object_type = '#{ opts[:object_type] }' AND relations.target_type = 'Platform') AND relations.role", opts[:object_id]]

View File

@ -3,30 +3,30 @@ class BuildList < ActiveRecord::Base
belongs_to :arch belongs_to :arch
belongs_to :pl, :class_name => 'Platform' belongs_to :pl, :class_name => 'Platform'
belongs_to :bpl, :class_name => 'Platform' belongs_to :bpl, :class_name => 'Platform'
belongs_to :user
has_many :items, :class_name => "BuildList::Item", :dependent => :destroy has_many :items, :class_name => "BuildList::Item", :dependent => :destroy
validates :project_id, :presence => true validates :project_id, :project_version, :arch, :include_repos, :presence => true
validates :project_version, :presence => true
#validates_inclusion_of :update_type, :in => UPDATE_TYPES#, :message => "extension %s is not included in the list"
UPDATE_TYPES = %w[security bugfix enhancement recommended newpackage] UPDATE_TYPES = %w[security bugfix enhancement recommended newpackage]
validates :update_type, :inclusion => UPDATE_TYPES validates :update_type, :inclusion => UPDATE_TYPES
validate lambda { validate lambda {
errors.add(:bpl, I18n.t('flash.build_list.wrong_platform')) if pl.platform_type == 'main' && pl_id != bpl_id errors.add(:bpl, I18n.t('flash.build_list.wrong_platform')) if pl.platform_type == 'main' && pl_id != bpl_id
} }
validate lambda {
errors.add(:bpl, I18n.t('flash.build_list.can_not_published')) if status == BUILD_PUBLISHED && status_was != BuildServer::SUCCESS
}
# The kernel does not send these statuses directly # The kernel does not send these statuses directly
BUILD_CANCELED = 5000 BUILD_CANCELED = 5000
WAITING_FOR_RESPONSE = 4000 WAITING_FOR_RESPONSE = 4000
BUILD_PENDING = 2000 BUILD_PENDING = 2000
BUILD_PUBLISHED = 6000 BUILD_PUBLISHED = 6000
BUILD_PUBLISH = 7000
FAILED_PUBLISH = 8000
STATUSES = [ WAITING_FOR_RESPONSE, STATUSES = [ WAITING_FOR_RESPONSE,
BUILD_CANCELED, BUILD_CANCELED,
BUILD_PENDING, BUILD_PENDING,
BUILD_PUBLISHED, BUILD_PUBLISHED,
BUILD_PUBLISH,
FAILED_PUBLISH,
BuildServer::SUCCESS, BuildServer::SUCCESS,
BuildServer::BUILD_STARTED, BuildServer::BUILD_STARTED,
BuildServer::BUILD_ERROR, BuildServer::BUILD_ERROR,
@ -41,6 +41,8 @@ class BuildList < ActiveRecord::Base
BUILD_CANCELED => :build_canceled, BUILD_CANCELED => :build_canceled,
BUILD_PENDING => :build_pending, BUILD_PENDING => :build_pending,
BUILD_PUBLISHED => :build_published, BUILD_PUBLISHED => :build_published,
BUILD_PUBLISH => :build_publish,
FAILED_PUBLISH => :failed_publish,
BuildServer::BUILD_ERROR => :build_error, BuildServer::BUILD_ERROR => :build_error,
BuildServer::BUILD_STARTED => :build_started, BuildServer::BUILD_STARTED => :build_started,
BuildServer::SUCCESS => :success, BuildServer::SUCCESS => :success,
@ -82,6 +84,7 @@ class BuildList < ActiveRecord::Base
scope :scoped_to_project_name, lambda {|project_name| joins(:project).where('projects.name LIKE ?', "%#{project_name}%")} scope :scoped_to_project_name, lambda {|project_name| joins(:project).where('projects.name LIKE ?', "%#{project_name}%")}
serialize :additional_repos serialize :additional_repos
serialize :include_repos
before_create :set_default_status before_create :set_default_status
after_create :place_build after_create :place_build
@ -105,27 +108,26 @@ class BuildList < ActiveRecord::Base
end end
def publish def publish
return false unless can_published? return false unless can_publish?
has_published = BuildServer.publish_container bs_id
BuildServer.publish_container bs_id update_attribute(:status, BUILD_PUBLISH) if has_published == 0
self.update_attribute(:status, BUILD_PUBLISHED) return has_published == 0
#self.destroy # self.delete
end end
def can_published? def can_publish?
self.status == BuildServer::SUCCESS status == BuildServer::SUCCESS or status == FAILED_PUBLISH
end end
def cancel_build_list def cancel
return false unless can_cancel?
has_canceled = BuildServer.delete_build_list bs_id has_canceled = BuildServer.delete_build_list bs_id
update_attribute(:status, BUILD_CANCELED) if has_canceled == 0 update_attribute(:status, BUILD_CANCELED) if has_canceled == 0
return has_canceled == 0 return has_canceled == 0
end end
#TODO: Share this checking on product owner. #TODO: Share this checking on product owner.
def can_cancel? def can_cancel?
self.status == BUILD_PENDING && bs_id status == BUILD_PENDING && bs_id
end end
def event_log_message def event_log_message
@ -139,8 +141,8 @@ class BuildList < ActiveRecord::Base
end end
def place_build def place_build
#XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web #XML-RPC params: project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos
self.status = BuildServer.add_build_list project.name, project_version, pl.name, arch.name, (pl_id == bpl_id ? '' : bpl.name), update_type, build_requires, id self.status = BuildServer.add_build_list project.name, project_version, pl.name, arch.name, (pl_id == bpl_id ? '' : bpl.name), update_type, build_requires, id, include_repos
self.status = BUILD_PENDING if self.status == 0 self.status = BUILD_PENDING if self.status == 0
save save
end end

View File

@ -14,9 +14,7 @@ class Platform < ActiveRecord::Base
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
validates :description, :presence => true, :uniqueness => true validates :description, :presence => true, :uniqueness => true
if !Rails.env.development? validates :name, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9_\-]+$/ }
validates :name, :uniqueness => true, :presence => true, :format => { :with => /^[a-zA-Z0-9_]+$/ }
end
validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']} validates :distrib_type, :presence => true, :inclusion => {:in => APP_CONFIG['distr_types']}
before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]} before_create :xml_rpc_create, :unless => lambda {Thread.current[:skip]}
@ -45,14 +43,17 @@ class Platform < ActiveRecord::Base
urpmi_commands[pl.name] = [] urpmi_commands[pl.name] = []
local_pair = pl.id != self.id ? blank_pair : pair local_pair = pl.id != self.id ? blank_pair : pair
head = hidden? ? "http://#{local_pair[:login]}@#{local_pair[:pass]}:#{host}/private/" : "http://#{host}/downloads/" head = hidden? ? "http://#{local_pair[:login]}@#{local_pair[:pass]}:#{host}/private/" : "http://#{host}/downloads/"
if pl.distrib_type == APP_CONFIG['distr_types'].first # prefix = prefix_url hidden?, :host => host, :login => local_pair[:login], :password => local_pair[:pass]
if pl.distrib_type == APP_CONFIG['distr_types'].first # mdv
Arch.all.each do |arch| Arch.all.each do |arch|
tail = "/#{arch.name}/main/release" tail = "/#{arch.name}/main/release"
urpmi_commands[pl.name] << "urpmi.addmedia #{name} #{head}#{name}/repository/#{pl.name}#{tail}" urpmi_commands[pl.name] << "urpmi.addmedia #{name} #{head}#{name}/repository/#{pl.name}#{tail}"
# urpmi_commands[pl.name] << "urpmi.addmedia #{name} #{prefix}/#{name}/repository#{pl.downloads_url '', arch.name, 'main', 'release'}"
end end
else else
tail = '' tail = ''
urpmi_commands[pl.name] << "urpmi.addmedia #{name} #{head}#{name}/repository/#{pl.name}#{tail}" urpmi_commands[pl.name] << "urpmi.addmedia #{name} #{head}#{name}/repository/#{pl.name}#{tail}"
# urpmi_commands[pl.name] << "urpmi.addmedia #{name} #{prefix}/#{name}/repository#{pl.downloads_url ''}"
end end
end end
@ -67,6 +68,27 @@ class Platform < ActiveRecord::Base
Rails.root.join("public", "downloads", name) Rails.root.join("public", "downloads", name)
end end
def prefix_url(pub, options = {})
options[:host] ||= EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host]
pub ? "http://#{options[:host]}/downloads" : "http://#{options[:login]}:#{options[:password]}@#{options[:host]}/private"
end
def public_downloads_url(host = nil, arch = nil, repo = nil, suffix = nil)
downloads_url prefix_url(true, :host => host), arch, repo, suffix
end
def private_downloads_url(login, password, host = nil, arch = nil, repo = nil, suffix = nil)
downloads_url prefix_url(false, :host => host, :login => login, :password => password), arch, repo, suffix
end
def downloads_url(prefix, arch = nil, repo = nil, suffix = nil)
"#{prefix}/#{name}/repository/".tap do |url|
url << "#{arch}/" if arch.present?
url << "#{repo}/" if repo.present?
url << "#{suffix}/" if suffix.present?
end
end
def hidden? def hidden?
visibility == 'hidden' visibility == 'hidden'
end end
@ -117,9 +139,7 @@ class Platform < ActiveRecord::Base
system("sudo mkdir -p #{mount_path}") system("sudo mkdir -p #{mount_path}")
system("sudo mount --bind #{path} #{mount_path}") system("sudo mount --bind #{path} #{mount_path}")
Arch.all.each do |arch| Arch.all.each do |arch|
host = EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host] str = "country=Russian Federation,city=Moscow,latitude=52.18,longitude=48.88,bw=1GB,version=2011,arch=#{arch.name},type=distrib,url=#{public_downloads_url}\n"
url = "http://#{host}/downloads/#{name}/repository/"
str = "country=Russian Federation,city=Moscow,latitude=52.18,longitude=48.88,bw=1GB,version=2011,arch=#{arch.name},type=distrib,url=#{url}\n"
File.open(File.join(mount_path, "#{name}.#{arch.name}.list"), 'w') {|f| f.write(str) } File.open(File.join(mount_path, "#{name}.#{arch.name}.list"), 'w') {|f| f.write(str) }
end end
end end

View File

@ -49,7 +49,7 @@ class Project < ActiveRecord::Base
end end
end end
def build_for(platform) def build_for(platform, user)
build_lists.create do |bl| build_lists.create do |bl|
bl.pl = platform bl.pl = platform
bl.bpl = platform bl.bpl = platform
@ -57,6 +57,7 @@ class Project < ActiveRecord::Base
bl.arch = Arch.find_by_name('i586') bl.arch = Arch.find_by_name('i586')
bl.project_version = "latest_#{platform.name}" bl.project_version = "latest_#{platform.name}"
bl.build_requires = false # already set as db default bl.build_requires = false # already set as db default
bl.user = user
end end
end end
@ -129,6 +130,10 @@ class Project < ActiveRecord::Base
end end
end end
def platforms
@platforms ||= repositories.map(&:platform).uniq
end
protected protected
def build_path(dir) def build_path(dir)

View File

@ -7,4 +7,14 @@ class ProjectToRepository < ActiveRecord::Base
after_create lambda { project.xml_rpc_create(repository) }, :unless => lambda {Thread.current[:skip]} after_create lambda { project.xml_rpc_create(repository) }, :unless => lambda {Thread.current[:skip]}
after_destroy lambda { project.xml_rpc_destroy(repository) } after_destroy lambda { project.xml_rpc_destroy(repository) }
# after_rollback lambda { project.xml_rpc_destroy(repository) rescue true if new_record? } # after_rollback lambda { project.xml_rpc_destroy(repository) rescue true if new_record? }
validate :one_project_in_platform_repositories
protected
def one_project_in_platform_repositories
c = Platform.scoped.select('projects.*').joins(:repositories => :projects).where(
:projects => {:name => project.name}, :id => repository.platform_id).count
errors.add(:project, 'should be one in platform') if c > 0
end
end end

View File

@ -11,7 +11,7 @@ class Repository < ActiveRecord::Base
has_many :groups, :through => :objects, :source => :object, :source_type => 'Group' has_many :groups, :through => :objects, :source => :object, :source_type => 'Group'
validates :description, :uniqueness => {:scope => :platform_id}, :presence => true validates :description, :uniqueness => {:scope => :platform_id}, :presence => true
validates :name, :uniqueness => {:scope => :platform_id}, :presence => true, :format => { :with => /^[a-z0-9_]+$/ } validates :name, :uniqueness => {:scope => :platform_id}, :presence => true, :format => { :with => /^[a-z0-9_\-]+$/ }
# validates :platform_id, :presence => true # if you uncomment this platform clone will not work # validates :platform_id, :presence => true # if you uncomment this platform clone will not work
scope :recent, order("name ASC") scope :recent, order("name ASC")

View File

@ -5,6 +5,7 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :validatable #, :trackable, :confirmable, :lockable :recoverable, :rememberable, :validatable #, :trackable, :confirmable, :lockable
has_many :authentications, :dependent => :destroy has_many :authentications, :dependent => :destroy
has_many :build_lists, :dependent => :destroy
has_many :relations, :as => :object, :dependent => :destroy has_many :relations, :as => :object, :dependent => :destroy
has_many :targets, :as => :object, :class_name => 'Relation' has_many :targets, :as => :object, :class_name => 'Relation'
@ -38,6 +39,9 @@ class User < ActiveRecord::Base
self.id.blank? # persisted? self.id.blank? # persisted?
end end
def fullname
return "#{uname} (#{name})"
end
class << self class << self
def find_for_database_authentication(warden_conditions) def find_for_database_authentication(warden_conditions)
conditions = warden_conditions.dup conditions = warden_conditions.dup

View File

@ -5,21 +5,23 @@
%th= t("activerecord.attributes.build_list.project_version") %th= t("activerecord.attributes.build_list.project_version")
%th= t("activerecord.attributes.build_list.project") %th= t("activerecord.attributes.build_list.project")
%th= t("activerecord.attributes.build_list.arch") %th= t("activerecord.attributes.build_list.arch")
%th= t("activerecord.attributes.build_list.user")
%th= t("activerecord.attributes.build_list.is_circle") %th= t("activerecord.attributes.build_list.is_circle")
- if controller.action_name = 'all' - unless @project
%th= t("layout.build_lists.cancel_button_header") %th= t("layout.build_lists.cancel_button_header")
%th.last= t("activerecord.attributes.build_list.notified_at") %th.last= t("activerecord.attributes.build_list.notified_at")
- build_lists.each do |build_list| - build_lists.each do |build_list|
%tr{:class => cycle("odd", "even")} %tr{:class => cycle("odd", "even")}
%td= link_to (build_list.bs_id.present? ? build_list.bs_id : t("layout.build_lists.bs_id_not_set")), project_build_list_path(build_list.project, build_list) %td= link_to (build_list.bs_id.present? ? build_list.bs_id : t("layout.build_lists.bs_id_not_set")), build_list
%td= build_list.human_status %td= build_list.human_status
%td= link_to build_list.project_version, "#" %td= link_to build_list.project_version, "#"
%td= link_to build_list.project.name, project_path(build_list.project) %td= link_to build_list.project.name, project_path(build_list.project)
%td= build_list.arch.name %td= build_list.arch.name
%td= build_list.user.try(:fullname)
%td= t("layout.#{build_list.is_circle?}_") %td= t("layout.#{build_list.is_circle?}_")
- if controller.action_name = 'all' - unless @project
%td= link_to t("layout.build_lists.cancel_button"), build_list_cancel_path(build_list) if build_list.can_cancel? %td= link_to t("layout.build_lists.cancel_button"), cancel_build_list_path(build_list), :method => "put", :confirm => t("layout.confirm") if build_list.can_cancel?
%td.last= build_list.notified_at %td.last= build_list.notified_at
= will_paginate build_lists = will_paginate build_lists

View File

@ -8,12 +8,12 @@
= f.select :status, BuildList::STATUSES.collect{|status| [BuildList.human_status(status), status]}, :include_blank => true, :selected => @filter.status = f.select :status, BuildList::STATUSES.collect{|status| [BuildList.human_status(status), status]}, :include_blank => true, :selected => @filter.status
.group .group
= f.label :arch_id, t("activerecord.attributes.build_list.arch"), :class => :label = f.label :arch_id, t("activerecord.attributes.build_list.arch"), :class => :label
= f.select :arch_id, @arches.collect{|arch| [arch.name, arch.id]}, :include_blank => true, :selected => @filter.arch_id = f.select :arch_id, Arch.recent.collect{|arch| [arch.name, arch.id]}, :include_blank => true, :selected => @filter.arch_id
.column.right .column.right
- if @project_versions - if @project
.group .group
= f.label :project_version, t("activerecord.attributes.build_list.project_version"), :class => :label = f.label :project_version, t("activerecord.attributes.build_list.project_version"), :class => :label
= f.select :project_version, @project_versions, :include_blank => true, :selected => @filter.project_version = f.select :project_version, @project.versions, :include_blank => true, :selected => @filter.project_version
.group .group
= f.label :is_circle, t("activerecord.attributes.build_list.is_circle"), :class => :label = f.label :is_circle, t("activerecord.attributes.build_list.is_circle"), :class => :label
= f.select :is_circle, [[t("layout.yes_"), 1], [t("layout.no_"), 0]], :include_blank => true, :selected => @filter.is_circle.present? ? (@filter.is_circle ? "1" : "0") : nil = f.select :is_circle, [[t("layout.yes_"), 1], [t("layout.no_"), 0]], :include_blank => true, :selected => @filter.is_circle.present? ? (@filter.is_circle ? "1" : "0") : nil

View File

@ -0,0 +1,3 @@
- platform.repositories.each do |repo|
= check_box_tag "build_list[include_repos][]", repo.id, repo.name == 'main' || @project.repositories.map(&:id).include?(repo.id), :id => "include_repos_#{repo.id}" # (params[:build_list]||[]).fetch(:include_repos, []).include?(repo.id.to_s)
= label_tag "include_repos_#{repo.id}", repo.name

View File

@ -1,10 +1,10 @@
.block.notice .block.notice
%h3= t("layout.repositories.current_repository_header") %h3= t("layout.repositories.current_repository_header")
.content .content
- @project.repositories.each do |repository| - project.repositories.each do |repository|
%p= link_to "#{repository.name} (#{repository.platform.name})", platform_repository_path(repository.platform, repository) %p= link_to "#{repository.name} (#{repository.platform.name})", platform_repository_path(repository.platform, repository)
.block.notice .block.notice
%h3= t("layout.projects.current_project_header") %h3= t("layout.projects.current_project_header")
.content .content
%p= link_to @project.name, project_path(@project) %p= link_to project.name, project

View File

@ -1,12 +1,12 @@
.block .block
- if controller.action_name != 'all' - if @project
.secondary-navigation .secondary-navigation
%ul.wat-cf %ul.wat-cf
%li.first= link_to t("layout.build_lists.current"), project_path(@project) + "#build_lists" %li.first= link_to t("layout.build_lists.current"), project_path(@project) + "#build_lists"
%li.active= link_to t("layout.build_lists.all"), project_build_lists_path(@project) %li.active= link_to t("layout.build_lists.all"), project_build_lists_path(@project)
.content .content
- if controller.action_name == 'all' - unless @project
.inner .inner
%h2= t('layout.build_lists.build_server_status.header') %h2= t('layout.build_lists.build_server_status.header')
.field .field
@ -25,4 +25,4 @@
.inner .inner
= render :partial => "build_lists/build_lists", :object => @build_lists = render :partial => "build_lists/build_lists", :object => @build_lists
- content_for :sidebar, render(:partial => 'sidebar') if controller.action_name != 'all' - content_for :sidebar, render('sidebar', :project => @project) if @project

View File

@ -5,46 +5,50 @@
%li= link_to t("layout.projects.new"), new_project_path %li= link_to t("layout.projects.new"), new_project_path
%li= link_to t("layout.projects.show"), project_path(@project) %li= link_to t("layout.projects.show"), project_path(@project)
%li=# link_to "git-repo", project_repo_path(@platform, @repository, @project) %li=# link_to "git-repo", project_repo_path(@platform, @repository, @project)
%li.active= link_to t("layout.projects.build"), build_project_path(@project) %li.active= link_to t("layout.projects.build"), new_project_build_list_path(@project)
.content .content
%h2.title= t("layout.projects.new_build", :project_name => @project.name) %h2.title= t("layout.projects.new_build", :project_name => @project.name)
.inner .inner
= form_for :build, :url => process_build_project_path(@project), :html => { :class => :form, :method => :post } do |f| = form_for [@project, @build_list], :html => { :class => :form, :method => :post } do |f|
.columns.wat-cf .columns.wat-cf
.column.left .column.left
.group .group
= f.label :project_version, t("activerecord.attributes.build_list.project_version"), :class => :label = f.label :project_version, t("activerecord.attributes.build_list.project_version"), :class => :label
= f.select :project_version, @project_versions = f.select :project_version, @project.versions
.group.pl_ids_container .group.base_platforms
= f.label :bpl, t("activerecord.attributes.build_list.bpl"), :class => :label = f.label :bpl, t("activerecord.attributes.build_list.bpl"), :class => :label
- @bpls.each do |bpl| - Platform.main.each do |bpl|
= f.check_box "bpl[#{bpl.id}]", :bpl_id => bpl.id, :class => 'build_bpl_ids' = check_box_tag "bpls[]", bpl.id, (params[:bpls]||[]).include?(bpl.id.to_s), :class => 'build_bpl_ids', :id => "bpls_#{bpl.id}"
= bpl.name = label_tag "bpls_#{bpl.id}", bpl.name
%br %br
.group .group
= f.label :update_type, t("activerecord.attributes.build_list.update_type"), :class => :label = f.label :update_type, t("activerecord.attributes.build_list.update_type"), :class => :label
= f.select :update_type, BuildList::UPDATE_TYPES.collect { |ut| [ut, ut] } = f.select :update_type, BuildList::UPDATE_TYPES
.group .group
= f.check_box :build_requires = f.check_box :build_requires
= t("activerecord.attributes.build_list.build_requires") = f.label :build_requires, t("activerecord.attributes.build_list.build_requires")
.column.right .column.right
.group .group
= f.label :arches, t("activerecord.attributes.build_list.arch"), :class => :label = f.label :arches, t("activerecord.attributes.build_list.arch"), :class => :label
- @arches.each do |arch| - Arch.recent.each do |arch|
= f.check_box "arches[#{arch.id}]" = check_box_tag "archs[]", arch.id, (params[:archs]||[]).include?(arch.id.to_s), :id => "archs_#{arch.id}"
= arch.name = label_tag "archs_#{arch.id}", arch.name
%br %br
.group .group
= f.label :pl, t("activerecord.attributes.build_list.pl"), :class => :label = f.label :pl_id, t("activerecord.attributes.build_list.pl"), :class => :label
= f.select :pl, @pls = f.select :pl_id, @project.repositories.collect{|r| ["#{r.platform.name}/#{r.name}", r.platform.id]}
.group
= f.label :include_repos, t("activerecord.attributes.build_list.include_repos"), :class => :label
#include_repos
.group.navform.wat-cf .group.navform.wat-cf
%button.button{:type => "submit"} %button.button{:type => "submit"}
@ -53,4 +57,6 @@
%span.text_button_padding= t("layout.or") %span.text_button_padding= t("layout.or")
= link_to t("layout.cancel"), root_path, :class => "text_button_padding link_button" = link_to t("layout.cancel"), root_path, :class => "text_button_padding link_button"
-# content_for :sidebar, render(:partial => 'sidebar') .preloaded_include_repos{:style => 'display: none'}
- @project.platforms.each do |p|
%div{:class => "include_repos_#{p.id}"}= render 'include_repos', :platform => p

View File

@ -1,9 +1,9 @@
.block .block
.secondary-navigation .secondary-navigation
%ul.wat-cf %ul.wat-cf
%li.first= link_to t("layout.build_lists.current"), project_path(@project) + "#build_lists" %li.first= link_to t("layout.build_lists.current"), project_path(@build_list.project) + "#build_lists"
%li= link_to t("layout.build_lists.all"), project_build_lists_path(@project) %li= link_to t("layout.build_lists.all"), project_build_lists_path(@build_list.project)
%li.active= link_to t("layout.build_lists.show"), project_build_list_path(@project, @build_list) %li.active= link_to t("layout.build_lists.show"), @build_list
.content .content
.inner .inner
@ -34,6 +34,11 @@
= t("activerecord.attributes.build_list.pl") = t("activerecord.attributes.build_list.pl")
\: \:
= @build_list.pl.name = @build_list.pl.name
%p
%b
= t("activerecord.attributes.build_list.include_repos")
\:
= (@build_list.include_repos||[]).map{|r| Repository.find(r).name}.join(', ')
%p %p
%b %b
= t("activerecord.attributes.build_list.update_type") = t("activerecord.attributes.build_list.update_type")
@ -64,6 +69,11 @@
= t("activerecord.attributes.build_list.arch") = t("activerecord.attributes.build_list.arch")
\: \:
= @build_list.arch.name = @build_list.arch.name
%p
%b
= t("activerecord.attributes.build_list.user")
\:
= @build_list.user.try(:fullname)
%p %p
%b %b
= t("activerecord.attributes.build_list.notified_at") = t("activerecord.attributes.build_list.notified_at")
@ -75,9 +85,9 @@
\: \:
= t("layout.#{@build_list.is_circle?}_") = t("layout.#{@build_list.is_circle?}_")
- if @build_list.can_published? - if @build_list.can_publish?
.wat-cf .wat-cf
= link_to image_tag("web-app-theme/icons/tick.png", :alt => t("layout.publish")) + " " + t("layout.publish"), publish_project_build_list_path(@project, @build_list), :method => "post", :class => "button", :confirm => t("layout.build_lists.confirm_publish") = link_to image_tag("web-app-theme/icons/tick.png", :alt => t("layout.publish")) + " " + t("layout.publish"), publish_build_list_path(@build_list), :method => "put", :class => "button", :confirm => t("layout.confirm")
.block .block
.content .content
@ -101,4 +111,4 @@
%td= item.version %td= item.version
%td.last= item.human_status %td.last= item.human_status
- content_for :sidebar, render(:partial => 'sidebar') - content_for :sidebar, render('sidebar', :project => @build_list.project)

View File

@ -4,7 +4,7 @@
%li= link_to t("layout.projects.new"), new_project_path %li= link_to t("layout.projects.new"), new_project_path
%li= link_to t("layout.projects.show"), project_path(@project) %li= link_to t("layout.projects.show"), project_path(@project)
%li.active= link_to t("layout.git.repositories.source"), project_repo_path(@project) %li.active= link_to t("layout.git.repositories.source"), project_repo_path(@project)
%li= link_to t("layout.projects.build"), build_project_path(@project) %li= link_to t("layout.projects.build"), new_project_build_list_path(@project)
%ul#git_submenu.sub-wat-cf.wat-cf %ul#git_submenu.sub-wat-cf.wat-cf
%li= link_to t("layout.git.repositories.commits"), commits_path(@project, :treeish => @treeish) %li= link_to t("layout.git.repositories.commits"), commits_path(@project, :treeish => @treeish)

View File

@ -36,7 +36,7 @@
%a{:href => event_logs_path}= t("layout.menu.event_logs") %a{:href => event_logs_path}= t("layout.menu.event_logs")
-if can? :index, BuildList -if can? :index, BuildList
%li{:class => controller.controller_path == 'build_lists' ? 'active' : '' } %li{:class => controller.controller_path == 'build_lists' ? 'active' : '' }
%a{:href => all_build_lists_path}= t("layout.menu.build_lists") %a{:href => build_lists_path}= t("layout.menu.build_lists")
-if can? :platforms, Category -if can? :platforms, Category
%li{:class => controller.controller_path == 'categories' ? 'active' : '' } %li{:class => controller.controller_path == 'categories' ? 'active' : '' }
%a{:href => catalogs_path}= t("layout.menu.categories") %a{:href => catalogs_path}= t("layout.menu.categories")

View File

@ -5,7 +5,7 @@
%li= link_to t("layout.projects.new"), new_project_path %li= link_to t("layout.projects.new"), new_project_path
%li.active= link_to t("layout.projects.show"), project_path(@project) %li.active= link_to t("layout.projects.show"), project_path(@project)
%li= link_to t("layout.git.repositories.source"), project_repo_path(@project) %li= link_to t("layout.git.repositories.source"), project_repo_path(@project)
%li= link_to t("layout.projects.build"), build_project_path(@project) %li= link_to t("layout.projects.build"), new_project_build_list_path(@project)
%li= link_to t("layout.projects.issues"), project_issues_path(@project) %li= link_to t("layout.projects.issues"), project_issues_path(@project)
.content .content

View File

@ -23,8 +23,8 @@ ru:
open_id: 'вход через OpenID' open_id: 'вход через OpenID'
projects_controller: projects_controller:
auto_build: 'отправлен на автоматическую сборку' auto_build: 'отправлен на автоматическую сборку'
process_build: 'отправлен на сборку'
build_lists_controller: build_lists_controller:
create: 'отправлен на сборку'
cancel: 'сборка отменена' cancel: 'сборка отменена'
publish: 'сборка опубликована' publish: 'сборка опубликована'
auto_build_lists_controller: auto_build_lists_controller:

View File

@ -299,7 +299,6 @@ ru:
build_lists: build_lists:
filter_header: Фильтр filter_header: Фильтр
current: Текущие current: Текущие
all: Все
created_at_start: "Время постановки на сборку с:" created_at_start: "Время постановки на сборку с:"
created_at_end: "Время постановки на сборку по:" created_at_end: "Время постановки на сборку по:"
notified_at_start: "Время последнего обновления от BS с:" notified_at_start: "Время последнего обновления от BS с:"
@ -310,11 +309,12 @@ ru:
items_header: Элементы сборки items_header: Элементы сборки
no_items_data: Данных нет no_items_data: Данных нет
show: Просмотр show: Просмотр
confirm_publish: Вы уверены, что хотите опубликовать контейнер?
cancel_button_header: Действие cancel_button_header: Действие
cancel_button: Отмена cancel_button: Отмена
cancel_successed: 'Сборка отменена.' cancel_success: 'Сборка отменена.'
cancel_failed: 'При отмене сборки произошла ошибка!' cancel_fail: 'При отмене сборки произошла ошибка!'
publish_success: 'Сборка поставлена в очередь на публикацию.'
publish_fail: 'При публикации сборки произошла ошибка!'
build_server_status: build_server_status:
header: Статус сборочного сервера header: Статус сборочного сервера
@ -333,6 +333,8 @@ ru:
statuses: statuses:
build_error: ошибка сборки build_error: ошибка сборки
build_published: опубликован build_published: опубликован
build_publish: публикуется
failed_publish: ошибка публикации
dependencies_fail: зависимости не найдены dependencies_fail: зависимости не найдены
waiting_for_response: ожидает ответа waiting_for_response: ожидает ответа
build_pending: ожидает сборку build_pending: ожидает сборку
@ -438,8 +440,7 @@ ru:
save_error: Не удалось сохранить билд лист для версии '%{project_version}', платформы '%{bpl}' и архитектуры '%{arch}' save_error: Не удалось сохранить билд лист для версии '%{project_version}', платформы '%{bpl}' и архитектуры '%{arch}'
no_project_version_selected: Выберите какую-нибудь версию no_project_version_selected: Выберите какую-нибудь версию
no_project_version_found: Выбранная версия '%{project_version}' не найдена no_project_version_found: Выбранная версия '%{project_version}' не найдена
no_arch_selected: Выберите хотя бы одну ахритектуру no_arch_or_platform_selected: Выберите хотя бы одну ахритектуру и платформу
no_arch_found: Выбранные ахритектуры не найдены
wrong_platform: Для основного репозитория (main) может быть выбран только его же основная платформа! wrong_platform: Для основного репозитория (main) может быть выбран только его же основная платформа!
can_not_published: Опубликовать сборку можно только со статусом "Собран" can_not_published: Опубликовать сборку можно только со статусом "Собран"
@ -628,6 +629,7 @@ ru:
is_circle: Циклическая сборка is_circle: Циклическая сборка
notified_at: Информация получена notified_at: Информация получена
additional_repos: Дополнительные репозитории additional_repos: Дополнительные репозитории
include_repos: Подключаемые репозитории
updated_at: Обновлен updated_at: Обновлен
created_at: Создан created_at: Создан
pl: Репозиторий для сохранения пакетов pl: Репозиторий для сохранения пакетов
@ -637,6 +639,7 @@ ru:
update_type: Критичность обновления update_type: Критичность обновления
build_requires: Пересборка с зависимостями build_requires: Пересборка с зависимостями
project_version: Версия project_version: Версия
user: Пользователь
build_list/item: build_list/item:
name: Название name: Название

View File

@ -24,8 +24,19 @@ Rosa::Application.routes.draw do
match '/private/:platform_name/*file_path' => 'privates#show' match '/private/:platform_name/*file_path' => 'privates#show'
match 'build_lists/' => 'build_lists#all', :as => :all_build_lists match 'build_lists/publish_build', :to => "build_lists#publish_build"
match 'build_lists/:id/cancel/' => 'build_lists#cancel', :as => :build_list_cancel match 'build_lists/status_build', :to => "build_lists#status_build"
match 'build_lists/post_build', :to => "build_lists#post_build"
match 'build_lists/pre_build', :to => "build_lists#pre_build"
match 'build_lists/circle_build', :to => "build_lists#circle_build"
match 'build_lists/new_bbdt', :to => "build_lists#new_bbdt"
resources :build_lists, :only => [:index, :show] do
member do
put :cancel
put :publish
end
end
resources :auto_build_lists, :only => [:index, :create, :destroy] resources :auto_build_lists, :only => [:index, :create, :destroy]
@ -74,15 +85,7 @@ Rosa::Application.routes.draw do
resources :comments, :only => [:edit, :create, :update, :destroy] resources :comments, :only => [:edit, :create, :update, :destroy]
end end
resource :repo, :controller => "git/repositories", :only => [:show] resource :repo, :controller => "git/repositories", :only => [:show]
resources :build_lists, :only => [:index, :show] do resources :build_lists, :only => [:index, :new, :create]
collection do
get :recent
post :filter
end
member do
post :publish
end
end
resources :collaborators, :only => [:index, :edit, :update, :add] do resources :collaborators, :only => [:index, :edit, :update, :add] do
collection do collection do
@ -98,8 +101,6 @@ Rosa::Application.routes.draw do
# end # end
member do member do
get :build
post :process_build
post :fork post :fork
end end
collection do collection do
@ -138,12 +139,6 @@ Rosa::Application.routes.draw do
match '/catalogs', :to => 'categories#platforms', :as => :catalogs match '/catalogs', :to => 'categories#platforms', :as => :catalogs
match 'build_lists/status_build', :to => "build_lists#status_build"
match 'build_lists/post_build', :to => "build_lists#post_build"
match 'build_lists/pre_build', :to => "build_lists#pre_build"
match 'build_lists/circle_build', :to => "build_lists#circle_build"
match 'build_lists/new_bbdt', :to => "build_lists#new_bbdt"
match 'product_status', :to => 'product_build_lists#status_build' match 'product_status', :to => 'product_build_lists#status_build'
# Tree # Tree

View File

@ -0,0 +1,9 @@
class AddIncludeReposToBuildLists < ActiveRecord::Migration
def self.up
add_column :build_lists, :include_repos, :text
end
def self.down
remove_column :build_lists, :include_repos
end
end

View File

@ -0,0 +1,9 @@
class AddUserIdToBuildLists < ActiveRecord::Migration
def self.up
add_column :build_lists, :user_id, :integer
end
def self.down
remove_column :build_lists, :user_id
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20111219073859) do ActiveRecord::Schema.define(:version => 20111221194422) do
create_table "arches", :force => true do |t| create_table "arches", :force => true do |t|
t.string "name", :null => false t.string "name", :null => false
@ -69,6 +69,8 @@ ActiveRecord::Schema.define(:version => 20111219073859) do
t.string "update_type" t.string "update_type"
t.integer "bpl_id" t.integer "bpl_id"
t.integer "pl_id" t.integer "pl_id"
t.text "include_repos"
t.integer "user_id"
end end
add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id" add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id"

View File

@ -72,8 +72,15 @@ class BuildServer
self.client.call('add_to_repo', name, repo_name) self.client.call('add_to_repo', name, repo_name)
end end
def self.add_build_list project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web def self.add_build_list project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos
self.client.call('add_build_list', project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web) include_repos_hash = {}.tap do |h|
include_repos.each do |r|
repo = Repository.find r
h[repo.name] = repo.platform.public_downloads_url(nil, arch, repo.name)
end
end
# raise include_repos_hash.inspect
self.client.call('add_build_list', project_name, project_version, plname, arch, bplname, update_type, build_requires, id_web, include_repos_hash)
end end
def self.delete_build_list idlist def self.delete_build_list idlist

View File

@ -1,42 +1,25 @@
function check_by_ids(ids) {
for(var i = 0; i < ids.length; i++){
$('#'+ids[i]).attr('checked', true);
}
return false;
}
function uncheck_by_ids(ids) {
for(var i = 0; i < ids.length; i++){
$('#'+ids[i]).attr('checked', false);
}
return false;
}
$(document).ready(function() { $(document).ready(function() {
$('.pl_ids_container input[type="hidden"]').remove(); $('select#build_list_pl_id').change(function() {
var platform_id = $(this).val();
var base_platforms = $('.base_platforms input[type=checkbox]');
$('select#build_pl').change(function() { $('#include_repos').html($('.preloaded_include_repos .include_repos_' + platform_id).html());
var is_pl_main = false;
var granted_bpl_id = '';
var pl_id = $('select#build_pl').val();
$('input.build_bpl_ids').each(function(i,el) { base_platforms.each(function(){
var bpl_id = $(el).attr('bpl_id'); if ($.inArray(platform_id, base_platforms.map(function(){ return $(this).val() }).get()) >= 0) {
if (pl_id == bpl_id) { if ($(this).val() == platform_id) {
is_pl_main = true; $(this).attr('checked', 'checked');
//granted_bpl_id = $(el).attr('bpl_id'); $(this).removeAttr('disabled');
}
});
if (is_pl_main) {
$('input.build_bpl_ids').attr('disabled', 'disabled');
$('input.build_bpl_ids[bpl_id="'+pl_id+'"]').removeAttr('disabled');
} else { } else {
$('input.build_bpl_ids').removeAttr('disabled'); $(this).removeAttr('checked');
$(this).attr('disabled', 'disabled');
}
} else {
$(this).removeAttr('disabled');
} }
}); });
});
$('select#build_pl').trigger('change'); $('select#build_list_pl_id').trigger('change');
$('input.user_role_chbx').click(function() { $('input.user_role_chbx').click(function() {
var current = $(this); var current = $(this);

View File

@ -7,6 +7,11 @@ describe BuildListsController do
get :show, @show_params get :show, @show_params
response.should be_success response.should be_success
end end
it 'should be able to perform index action in project scope' do
get :index, :project_id => @project.id
response.should be_success
end
end end
shared_examples_for 'not show build list' do shared_examples_for 'not show build list' do
@ -14,12 +19,17 @@ describe BuildListsController do
get :show, @show_params get :show, @show_params
response.should redirect_to(forbidden_url) response.should redirect_to(forbidden_url)
end end
it 'should not be able to perform index action in project scope' do
get :index, :project_id => @project.id
response.should redirect_to(forbidden_url)
end
end end
context 'crud' do context 'crud' do
context 'for guest' do context 'for guest' do
it 'should not be able to perform all action' do it 'should not be able to perform index action' do
get :all get :index
response.should redirect_to(new_user_session_path) response.should redirect_to(new_user_session_path)
end end
end end
@ -37,11 +47,31 @@ describe BuildListsController do
@user = Factory(:user) @user = Factory(:user)
set_session_for(@user) set_session_for(@user)
@show_params = {:project_id => @project.id, :id => @build_list.id} @show_params = {:project_id => @project.id, :id => @build_list.id}
end end
it 'should not be able to perform all action' do context 'for all build lists' do
get :all before(:each) do
response.should redirect_to(forbidden_url) @build_list1 = Factory(:build_list_core)
@build_list2 = Factory(:build_list_core, :project => Factory(:project, :visibility => 'hidden'))
@build_list3 = Factory(:build_list_core, :project => Factory(:project, :owner => @user, :visibility => 'hidden'))
b = Factory(:build_list_core, :project => Factory(:project, :visibility => 'hidden'))
b.project.relations.create :role => 'reader', :object_id => @user.id, :object_type => 'User'
@build_list4 = b
end
it 'should be able to perform index action' do
get :index
response.should be_success
end
it 'should show only accessible build_lists' do
get :index
assigns(:build_lists).should include(@build_list1)
assigns(:build_lists).should_not include(@build_list2)
assigns(:build_lists).should include(@build_list3)
assigns(:build_lists).should include(@build_list4)
end
end end
context 'for open project' do context 'for open project' do
@ -52,7 +82,7 @@ describe BuildListsController do
it_should_behave_like 'show build list' it_should_behave_like 'show build list'
end end
context 'if user is project owner' do context 'if user is project member' do
before(:each) {set_session_for(@member_user)} before(:each) {set_session_for(@member_user)}
it_should_behave_like 'show build list' it_should_behave_like 'show build list'
end end
@ -71,7 +101,89 @@ describe BuildListsController do
it_should_behave_like 'show build list' it_should_behave_like 'show build list'
end end
context 'if user is project owner' do context 'if user is project member' do
before(:each) {set_session_for(@member_user)}
it_should_behave_like 'show build list'
end
end
end
context 'for group' do
before(:each) do
stub_rsync_methods
@owner_group = Factory(:group)
@owner_user = Factory(:user)
@owner_group.objects.create :role => 'reader', :object_id => @owner_user.id, :object_type => 'User'
@member_group = Factory(:group)
@member_user = Factory(:user)
@member_group.objects.create :role => 'reader', :object_id => @member_user.id, :object_type => 'User'
@group = Factory(:group)
@user = Factory(:user)
@group.objects.create :role => 'reader', :object_id => @user.id, :object_type => 'User'
@project = Factory(:project, :owner => @owner_group)
@project.relations.create :role => 'reader', :object_id => @member_group.id, :object_type => 'Group'
@build_list = Factory(:build_list_core, :project => @project)
set_session_for(@user)
@show_params = {:project_id => @project.id, :id => @build_list.id}
end
context 'for all build lists' do
before(:each) do
@build_list1 = Factory(:build_list_core)
@build_list2 = Factory(:build_list_core, :project => Factory(:project, :visibility => 'hidden'))
@build_list3 = Factory(:build_list_core, :project => Factory(:project, :owner => @group, :visibility => 'hidden'))
b = Factory(:build_list_core, :project => Factory(:project, :visibility => 'hidden'))
b.project.relations.create :role => 'reader', :object_id => @group.id, :object_type => 'Group'
@build_list4 = b
end
it 'should be able to perform index action' do
get :index
response.should be_success
end
it 'should show only accessible build_lists' do
get :index
assigns(:build_lists).should include(@build_list1)
assigns(:build_lists).should_not include(@build_list2)
assigns(:build_lists).should include(@build_list3)
assigns(:build_lists).should include(@build_list4)
end
end
context 'for open project' do
it_should_behave_like 'show build list'
context 'if user is group owner' do
before(:each) {set_session_for(@owner_user)}
it_should_behave_like 'show build list'
end
context 'if user is group member' do
before(:each) {set_session_for(@member_user)}
it_should_behave_like 'show build list'
end
end
context 'for hidden project' do
before(:each) do
@project.visibility = 'hidden'
@project.save
end
it_should_behave_like 'not show build list'
context 'if user is group owner' do
before(:each) {set_session_for(@owner_user)}
it_should_behave_like 'show build list'
end
context 'if user is group member' do
before(:each) {set_session_for(@member_user)} before(:each) {set_session_for(@member_user)}
it_should_behave_like 'show build list' it_should_behave_like 'show build list'
end end
@ -82,13 +194,13 @@ describe BuildListsController do
context 'for admin' do context 'for admin' do
before(:each) { set_session_for Factory(:admin) } before(:each) { set_session_for Factory(:admin) }
it "should be able to perform all action without exception" do it "should be able to perform index action without exception" do
any_instance_of(XMLRPC::Client) do |xml_rpc| any_instance_of(XMLRPC::Client) do |xml_rpc|
stub(xml_rpc).call do |args| stub(xml_rpc).call do |args|
raise Timeout::Error raise Timeout::Error
end end
end end
get :all get :index
assigns[:build_server_status].should == {} assigns[:build_server_status].should == {}
response.should be_success response.should be_success
end end
@ -100,46 +212,39 @@ describe BuildListsController do
before(:each) do before(:each) do
stub_rsync_methods stub_rsync_methods
set_session_for Factory(:admin) set_session_for Factory(:admin)
end
let(:build_list1) { Factory(:build_list_core) } @build_list1 = Factory(:build_list_core)
let(:build_list2) { Factory(:build_list_core) } @build_list2 = Factory(:build_list_core)
let(:build_list3) { Factory(:build_list_core) } @build_list3 = Factory(:build_list_core)
let(:build_list4) do @build_list4 = Factory(:build_list_core, :created_at => (Time.now - 1.day),
b = Factory(:build_list_core) :project => @build_list3.project, :pl => @build_list3.pl,
b.created_at = b.created_at - 1.day :arch => @build_list3.arch)
b.project = build_list3.project
b.pl = build_list3.pl
b.arch = build_list3.arch
b.save
b
end end
before(:each) { set_session_for Factory(:admin); stub_rsync_methods; }
it 'should filter by bs_id' do it 'should filter by bs_id' do
get :all, :filter => {:bs_id => build_list1.bs_id, :project_name => 'fdsfdf', :any_other_field => 'do not matter'} get :index, :filter => {:bs_id => @build_list1.bs_id, :project_name => 'fdsfdf', :any_other_field => 'do not matter'}
assigns[:build_lists].should include(build_list1) assigns[:build_lists].should include(@build_list1)
assigns[:build_lists].should_not include(build_list2) assigns[:build_lists].should_not include(@build_list2)
assigns[:build_lists].should_not include(build_list3) assigns[:build_lists].should_not include(@build_list3)
end end
it 'should filter by project_name' do it 'should filter by project_name' do
# Project.where(:id => build_list2.project.id).update_all(:name => 'project_name') # Project.where(:id => build_list2.project.id).update_all(:name => 'project_name')
get :all, :filter => {:project_name => build_list2.project.name} get :index, :filter => {:project_name => @build_list2.project.name}
assigns[:build_lists].should_not include(build_list1) assigns[:build_lists].should_not include(@build_list1)
assigns[:build_lists].should include(build_list2) assigns[:build_lists].should include(@build_list2)
assigns[:build_lists].should_not include(build_list3) assigns[:build_lists].should_not include(@build_list3)
end end
it 'should filter by project_name and start_date' do it 'should filter by project_name and start_date' do
get :all, :filter => {:project_name => build_list3.project.name, get :index, :filter => {:project_name => @build_list3.project.name,
"created_at_start(1i)"=>build_list3.created_at.year.to_s, "created_at_start(1i)" => @build_list3.created_at.year.to_s,
"created_at_start(2i)"=>build_list3.created_at.month.to_s, "created_at_start(2i)" => @build_list3.created_at.month.to_s,
"created_at_start(3i)"=>build_list3.created_at.day.to_s} "created_at_start(3i)" => @build_list3.created_at.day.to_s}
assigns[:build_lists].should_not include(build_list1) assigns[:build_lists].should_not include(@build_list1)
assigns[:build_lists].should_not include(build_list2) assigns[:build_lists].should_not include(@build_list2)
assigns[:build_lists].should include(build_list3) assigns[:build_lists].should include(@build_list3)
assigns[:build_lists].should_not include(build_list4) assigns[:build_lists].should_not include(@build_list4)
# response.should be_success # response.should be_success
end end
end end

View File

@ -1,5 +1,18 @@
require 'spec_helper' require 'spec_helper'
describe ProjectToRepository do describe ProjectToRepository do
pending "add some examples to (or delete) #{__FILE__}" before(:each) do
stub_rsync_methods
@platform = Factory(:platform)
@first_repo = Factory(:repository, :platform_id => @platform.id)
@second_repo = Factory(:repository, :platform_id => @platform.id)
@project = Factory(:project)
@first_repo.projects << @project
@first_repo.save
end
it 'should not add the same project in different repositories of same platform' do
p2r = @second_repo.project_to_repositories.build :project_id => @project.id
p2r.should_not be_valid
end
end end