#83: added ability to lock repository
This commit is contained in:
parent
9f7c2fcbd9
commit
8e879ef0c7
|
@ -149,6 +149,18 @@ class Platforms::RepositoriesController < Platforms::BaseController
|
|||
redirect_to platform_repository_path(@platform, @repository)
|
||||
end
|
||||
|
||||
def lock_sync
|
||||
@repository.lock_sync
|
||||
flash[:notice] = t('flash.repository.sync_locked')
|
||||
redirect_to edit_platform_repository_path(@platform, @repository)
|
||||
end
|
||||
|
||||
def unlock_sync
|
||||
@repository.unlock_sync
|
||||
flash[:notice] = t('flash.repository.sync_unlocked')
|
||||
redirect_to edit_platform_repository_path(@platform, @repository)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_members
|
||||
|
|
|
@ -119,7 +119,7 @@ class Ability
|
|||
can [:read, :projects_list, :projects], Repository, :platform => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||
can([:read, :projects_list, :projects], Repository, read_relations_for('repositories')) {|repository| can? :show, repository.platform}
|
||||
can([:read, :projects_list, :projects], Repository, read_relations_for('repositories', 'platforms')) {|repository| local_reader? repository.platform}
|
||||
can([:create, :edit, :update, :destroy, :projects_list, :projects, :add_project, :remove_project, :regenerate_metadata], Repository) {|repository| local_admin? repository.platform}
|
||||
can([:create, :edit, :update, :destroy, :projects_list, :projects, :add_project, :remove_project, :regenerate_metadata, :lock_sync, :unlock_sync], Repository) {|repository| local_admin? repository.platform}
|
||||
can([:remove_members, :remove_member, :add_member, :signatures], Repository) {|repository| owner?(repository.platform) || local_admin?(repository.platform)}
|
||||
can([:add_project, :remove_project], Repository) {|repository| repository.members.exists?(:id => user.id)}
|
||||
can(:clear, Platform) {|platform| owner?(platform) && platform.personal?}
|
||||
|
@ -164,7 +164,8 @@ class Ability
|
|||
# Shared cannot rights for all users (registered, admin)
|
||||
cannot :destroy, Platform, :platform_type => 'personal'
|
||||
cannot [:create, :destroy], Repository, :platform => {:platform_type => 'personal'}, :name => 'main'
|
||||
cannot [:remove_members, :remove_member, :add_member], Repository, :platform => {:platform_type => 'personal'}
|
||||
cannot [:remove_members, :remove_member, :add_member, :lock_sync, :unlock_sync], Repository, :platform => {:platform_type => 'personal'}
|
||||
|
||||
cannot :clear, Platform, :platform_type => 'main'
|
||||
cannot :destroy, Issue
|
||||
|
||||
|
|
|
@ -45,6 +45,18 @@ class Repository < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def sync_locked?
|
||||
sync_actions :check
|
||||
end
|
||||
|
||||
def lock_sync
|
||||
sync_actions :lock
|
||||
end
|
||||
|
||||
def unlock_sync
|
||||
sync_actions :unlock
|
||||
end
|
||||
|
||||
def add_member(member, role = 'admin')
|
||||
Relation.add_member(member, self, role)
|
||||
end
|
||||
|
@ -72,6 +84,22 @@ class Repository < ActiveRecord::Base
|
|||
|
||||
protected
|
||||
|
||||
def sync_actions(action)
|
||||
result = false
|
||||
(['SRPMS'] << Arch.pluck(:name)).each do |arch|
|
||||
path = "#{platform.path}/repository/#{arch}/#{name}/.sync.lock"
|
||||
case action
|
||||
when :lock
|
||||
result ||= system 'touch', path
|
||||
when :unlock
|
||||
result ||= system 'rm', '-rf', path
|
||||
when :check
|
||||
return true if File.exist?(path)
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
def detele_directory
|
||||
return unless platform
|
||||
repository_path = platform.path << '/repository'
|
||||
|
|
|
@ -8,7 +8,30 @@
|
|||
= render "form", :f => f
|
||||
%br
|
||||
|
||||
= render 'regenerate_metadata' if can?(:regenerate_metadata, @repository)
|
||||
=# render 'regenerate_metadata' if can?(:regenerate_metadata, @repository)
|
||||
|
||||
|
||||
- if can?(:update, @repository)
|
||||
.hr
|
||||
%h3= t('layout.repositories.extra_actions')
|
||||
|
||||
= link_to t('layout.repositories.regenerate_metadata'),
|
||||
regenerate_metadata_platform_repository_path(@platform, @repository),
|
||||
:method => :put, :confirm => t('layout.confirm'), :class => 'button'
|
||||
|
||||
- if @platform.main?
|
||||
- if @repository.sync_locked?
|
||||
- label = t('layout.repositories.unlock_sync')
|
||||
- path = unlock_sync_platform_repository_path(@platform, @repository)
|
||||
- else
|
||||
- label = t('layout.repositories.lock_sync')
|
||||
- path = lock_sync_platform_repository_path(@platform, @repository)
|
||||
|
||||
= link_to label, path, :method => :put, :confirm => t('layout.confirm'), :class => 'button'
|
||||
.both
|
||||
.hr
|
||||
|
||||
|
||||
|
||||
- if @platform.main?
|
||||
= render "shared/members_table",
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
en:
|
||||
layout:
|
||||
repositories:
|
||||
extra_actions: Extra actions
|
||||
lock_sync: Lock sync with mirrors
|
||||
unlock_sync: Unlock sync with mirrors
|
||||
add_project_to: Add project to repository
|
||||
edit: Settings
|
||||
list: List
|
||||
|
@ -28,6 +31,10 @@ en:
|
|||
|
||||
flash:
|
||||
repository:
|
||||
sync_locked: Sync of repository with mirrors has been locked
|
||||
sync_unlocked: Sync of repository with mirrors has been unlocked
|
||||
|
||||
|
||||
saved: Repository added
|
||||
updated: Repository updated
|
||||
save_error: Unable to add repository
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
ru:
|
||||
layout:
|
||||
repositories:
|
||||
extra_actions: Дополнительные действия
|
||||
lock_sync: Заблокировать синхронизацию с зеркалами
|
||||
unlock_sync: Разблокировать синхронизацию с зеркалами
|
||||
add_project_to: Добавить проект к репозиторию
|
||||
edit: Настройки
|
||||
list: Список
|
||||
|
@ -28,6 +31,9 @@ ru:
|
|||
|
||||
flash:
|
||||
repository:
|
||||
sync_locked: Синхронизация репозитория c зеркалами заблокирована
|
||||
sync_unlocked: Синхронизация репозитория c зеркалами разблокирована
|
||||
|
||||
saved: Репозиторий успешно добавлен
|
||||
updated: Репозиторий успешно обновлен
|
||||
save_error: Не удалось добавить репозиторий
|
||||
|
|
|
@ -174,13 +174,15 @@ Rosa::Application.routes.draw do
|
|||
|
||||
resources :repositories do
|
||||
member do
|
||||
get :add_project
|
||||
delete :remove_project
|
||||
get :projects_list
|
||||
post :remove_members # fixme: change post to delete
|
||||
delete :remove_member
|
||||
post :add_member
|
||||
put :regenerate_metadata
|
||||
get :add_project
|
||||
delete :remove_project
|
||||
get :projects_list
|
||||
post :remove_members # fixme: change post to delete
|
||||
delete :remove_member
|
||||
post :add_member
|
||||
put :regenerate_metadata
|
||||
put :lock_sync
|
||||
put :unlock_sync
|
||||
end
|
||||
end
|
||||
resources :key_pairs, :only => [:create, :index, :destroy]
|
||||
|
|
Loading…
Reference in New Issue