Add events logging for platform change_visibility action. Improve autobuild events logging. Add events log for private access to hidden repositories. Change owner assign for platform and repository. Improve gitolite doc. Refactor. Refs #2162
This commit is contained in:
parent
4b0f23cfa3
commit
afc1d492a8
|
@ -3,9 +3,8 @@ class ApplicationController < ActionController::Base
|
|||
protect_from_forgery
|
||||
layout :layout_by_resource
|
||||
|
||||
|
||||
before_filter lambda { EventLog.current_controller = self },
|
||||
:only => [:create, :destroy, :open_id, :auto_build, :process_build, :cancel, :publish] # :update
|
||||
:only => [:create, :destroy, :open_id, :auto_build, :process_build, :cancel, :publish, :change_visibility] # :update
|
||||
after_filter lambda { EventLog.current_controller = nil }
|
||||
|
||||
helper_method :get_owner
|
||||
|
|
|
@ -50,14 +50,14 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def auto_build
|
||||
p = params.delete_if{|k,v| k == 'controller' or k == 'action'}
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :message => p.inspect) # TODO find :object ?
|
||||
# logger.info "Git hook recieved from #{params[:git_user]} to #{params[:git_repo]}"
|
||||
|
||||
unixname = params[:git_repo].split('/')[1]
|
||||
project = Project.find_by_unixname(unixname)
|
||||
auto_build_list = AutoBuildList.find_by_project_id(project.id)
|
||||
|
||||
p = params.delete_if{|k,v| k == 'controller' or k == 'action'}
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => project, :message => p.inspect)
|
||||
# logger.info "Git hook recieved from #{params[:git_user]} to #{params[:git_repo]}"
|
||||
|
||||
BuildList.create!(
|
||||
:project_id => project.id,
|
||||
:pl_id => auto_build_list.pl_id,
|
||||
|
|
|
@ -123,7 +123,7 @@ class BuildList < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def event_log_message
|
||||
{:project => project.name, :version => project_version, :arch => arch.name}.inspect
|
||||
{:project => project.unixname, :version => project_version, :arch => arch.name}.inspect
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class EventLogObserver < ActiveRecord::Observer
|
||||
observe :user, :platform, :repository, :project, :product, :build_list, :auto_build_list
|
||||
observe :user, :private_user, :platform, :repository, :project, :product, :build_list, :auto_build_list
|
||||
|
||||
def after_create(record)
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => record)
|
||||
|
@ -11,6 +11,11 @@ class EventLogObserver < ActiveRecord::Observer
|
|||
if record.status_changed? and record.status == BUILD_CANCELED
|
||||
ActiveSupport::Notifications.instrument("event_log.observer", :object => record)
|
||||
end
|
||||
# when Platform
|
||||
# if record.visibility_changed?
|
||||
# ActiveSupport::Notifications.instrument "event_log.observer", :object => record,
|
||||
# :message => I18n.t("activerecord.attributes.platform.visibility_types.#{record.visibility}")
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,12 +20,13 @@ class Platform < ActiveRecord::Base
|
|||
validates :distrib_type, :presence => true, :allow_nil => :false, :allow_blank => false, :inclusion => {:in => APP_CONFIG['distr_types']}
|
||||
|
||||
after_create :make_owner_rel
|
||||
# before_save :create_directory
|
||||
before_save :check_owner_rel
|
||||
# before_save :create_directory
|
||||
# after_destroy :remove_directory
|
||||
before_create :xml_rpc_create
|
||||
before_destroy :xml_rpc_destroy
|
||||
# before_update :check_freezing
|
||||
after_create lambda { add_downloads_symlink unless self.hidden? }
|
||||
|
||||
scope :by_visibilities, lambda {|v| {:conditions => ['visibility in (?)', v.join(',')]}}
|
||||
scope :main, where(:platform_type => 'main')
|
||||
|
@ -33,10 +34,6 @@ class Platform < ActiveRecord::Base
|
|||
|
||||
#attr_accessible :visibility
|
||||
|
||||
after_create lambda {
|
||||
add_downloads_symlink unless self.hidden?
|
||||
}
|
||||
|
||||
def path
|
||||
build_path(unixname)
|
||||
end
|
||||
|
@ -85,6 +82,9 @@ class Platform < ActiveRecord::Base
|
|||
self.update_attribute(:visibility, 'open')
|
||||
add_downloads_symlink
|
||||
end
|
||||
# Because observer is not invoked...
|
||||
ActiveSupport::Notifications.instrument "event_log.observer", :object => self,
|
||||
:message => I18n.t("activerecord.attributes.platform.visibility_types.#{visibility}")
|
||||
end
|
||||
|
||||
protected
|
||||
|
@ -113,16 +113,6 @@ class Platform < ActiveRecord::Base
|
|||
FileUtils.rm_rf(path)
|
||||
end
|
||||
|
||||
def add_owner_rel
|
||||
if new_record? and owner
|
||||
add_owner owner
|
||||
elsif owner_id_changed?
|
||||
remove_owner owner_type_was.classify.find(owner_id_was)
|
||||
add_owner owner
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def xml_rpc_create
|
||||
# return true
|
||||
result = BuildServer.add_platform unixname, APP_CONFIG['root_path'] + '/platforms' , distrib_type
|
||||
|
|
|
@ -7,6 +7,10 @@ class PrivateUser < ActiveRecord::Base
|
|||
|
||||
validate :login, :uniqueness => true
|
||||
|
||||
def event_log_message
|
||||
{:platform => platform.unixname, :user => user.uname}.inspect
|
||||
end
|
||||
|
||||
class << self
|
||||
def can_generate_more?(user_id)
|
||||
!PrivateUser.exists?(:user_id => user_id)
|
||||
|
|
|
@ -17,10 +17,10 @@ class Repository < ActiveRecord::Base
|
|||
|
||||
scope :recent, order("name ASC")
|
||||
|
||||
after_create :make_owner_rel
|
||||
before_save :check_owner_rel
|
||||
#before_save :create_directory
|
||||
before_save :add_owner_rel
|
||||
#after_destroy :remove_directory
|
||||
|
||||
before_create :xml_rpc_create
|
||||
before_destroy :xml_rpc_destroy
|
||||
|
||||
|
@ -79,13 +79,15 @@ class Repository < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def add_owner_rel
|
||||
if new_record? and owner
|
||||
add_owner owner
|
||||
elsif owner_id_changed?
|
||||
remove_owner owner_type_was.classify.find(owner_id_was)
|
||||
def make_owner_rel
|
||||
add_owner owner
|
||||
end
|
||||
|
||||
def check_owner_rel
|
||||
if !new_record? and owner_id_changed?
|
||||
remove_owner owner_type_was.classify.find(owner_id_was) if owner_type_was
|
||||
add_owner owner if owner
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -10,7 +10,9 @@ ru:
|
|||
'devise/sessions_controller': 'Аутентификация пользователей'
|
||||
'devise/passwords_controller': 'Восстановление пароля'
|
||||
'users/omniauth_callbacks_controller': 'Внешняя аутентификация пользователей'
|
||||
rpc_controller: XML RPC
|
||||
rpc_controller: 'XML RPC'
|
||||
private_users_controller: 'Доступ к приватным репозиториям'
|
||||
personal_repositories_controller: 'Управление персональными репозиториями'
|
||||
actions:
|
||||
'devise/sessions_controller':
|
||||
create: 'вход'
|
||||
|
@ -25,6 +27,11 @@ ru:
|
|||
publish: 'сборка опубликована'
|
||||
rpc_controller:
|
||||
xe_index: запрос
|
||||
private_users_controller:
|
||||
create: 'предоставлен'
|
||||
destroy: 'удален'
|
||||
personal_repositories_controller:
|
||||
change_visibility: 'смена статуса'
|
||||
create: 'создано'
|
||||
update: 'обновлено'
|
||||
destroy: 'удалено'
|
||||
|
|
|
@ -377,6 +377,7 @@ ru:
|
|||
project: Проект
|
||||
rpm: RPM
|
||||
user: Пользователь
|
||||
private_user: Приватный пользователь
|
||||
product: Продукт
|
||||
build_list: Сборочный лист
|
||||
build_list_item: Элемент сборочного листа
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
* mkdir update.secondary.d
|
||||
* touch update.secondary.d/update.auto-build
|
||||
* chmod +x update.secondary update.secondary.d/update.auto-build
|
||||
* gl-setup
|
||||
|
||||
--------------- Code for update.auto-build
|
||||
|
||||
|
|
Loading…
Reference in New Issue