Remove project observer

This commit is contained in:
Dmitriy Zaporozhets 2014-06-17 21:53:26 +03:00
parent 66e068bbdf
commit a7f3672b75
5 changed files with 36 additions and 32 deletions

View file

@ -1,30 +0,0 @@
class ProjectObserver < BaseObserver
def after_create(project)
log_info("#{project.owner.name} created a new project \"#{project.name_with_namespace}\"")
end
def after_update(project)
project.send_move_instructions if project.namespace_id_changed?
project.rename_repo if project.path_changed?
end
def before_destroy(project)
project.repository.expire_cache unless project.empty_repo?
end
def after_destroy(project)
GitlabShellWorker.perform_async(
:remove_repository,
project.path_with_namespace
)
GitlabShellWorker.perform_async(
:remove_repository,
project.path_with_namespace + ".wiki"
)
project.satellite.destroy
log_info("Project \"#{project.name}\" was removed")
end
end

View file

@ -51,6 +51,8 @@ module Projects
@project.creator = current_user @project.creator = current_user
if @project.save if @project.save
log_info("#{@project.owner.name} created a new project \"#{@project.name_with_namespace}\"")
unless @project.group unless @project.group
@project.users_projects.create( @project.users_projects.create(
project_access: UsersProject::MASTER, project_access: UsersProject::MASTER,

View file

@ -0,0 +1,25 @@
module Projects
class UpdateService < BaseService
def execute(role = :default)
return false unless can?(current_user, :remove_project, project)
project.repository.expire_cache unless project.empty_repo?
if project.destroy
GitlabShellWorker.perform_async(
:remove_repository,
project.path_with_namespace
)
GitlabShellWorker.perform_async(
:remove_repository,
project.path_with_namespace + ".wiki"
)
project.satellite.destroy
log_info("Project \"#{project.name}\" was removed")
end
end
end
end

View file

@ -13,7 +13,15 @@ module Projects
project.change_head(new_branch) project.change_head(new_branch)
end end
project.update_attributes(params[:project], as: role) if project.update_attributes(params[:project], as: role)
if project.previous_changes.include?('namespace_id')
project.send_move_instructions
end
if project.previous_changes.include?('path')
project.rename_repo
end
end
end end
end end
end end

View file

@ -20,7 +20,6 @@ module Gitlab
# Activate observers that should always be running. # Activate observers that should always be running.
config.active_record.observers = :note_observer, config.active_record.observers = :note_observer,
:project_observer,
:system_hook_observer, :system_hook_observer,
:user_observer, :user_observer,
:users_project_observer :users_project_observer