#83: added #start_sync and #stop_sync actions into Repository API
This commit is contained in:
parent
92bc796007
commit
ad46e25654
|
@ -33,6 +33,16 @@ class Api::V1::RepositoriesController < Api::V1::BaseController
|
|||
def key_pair
|
||||
end
|
||||
|
||||
def start_sync
|
||||
@repository.start_sync
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
def stop_sync
|
||||
@repository.stop_sync
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
def add_project
|
||||
project = Project.where(:id => params[:project_id]).first
|
||||
if project
|
||||
|
|
|
@ -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, :lock_sync, :unlock_sync], Repository) {|repository| local_admin? repository.platform}
|
||||
can([:create, :edit, :update, :destroy, :projects_list, :projects, :add_project, :remove_project, :regenerate_metadata, :lock_sync, :unlock_sync, :start_sync, :stop_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,7 @@ 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, :lock_sync, :unlock_sync], Repository, :platform => {:platform_type => 'personal'}
|
||||
cannot [:remove_members, :remove_member, :add_member, :lock_sync, :unlock_sync, :start_sync, :stop_sync], Repository, :platform => {:platform_type => 'personal'}
|
||||
|
||||
cannot :clear, Platform, :platform_type => 'main'
|
||||
cannot :destroy, Issue
|
||||
|
|
|
@ -57,6 +57,14 @@ class Repository < ActiveRecord::Base
|
|||
sync_actions :unlock
|
||||
end
|
||||
|
||||
def start_sync
|
||||
sync_actions :lock, '.repo.lock'
|
||||
end
|
||||
|
||||
def stop_sync
|
||||
sync_actions :unlock, '.repo.lock'
|
||||
end
|
||||
|
||||
def add_member(member, role = 'admin')
|
||||
Relation.add_member(member, self, role)
|
||||
end
|
||||
|
@ -84,10 +92,10 @@ class Repository < ActiveRecord::Base
|
|||
|
||||
protected
|
||||
|
||||
def sync_actions(action)
|
||||
def sync_actions(action, lock_file = '.sync.lock')
|
||||
result = false
|
||||
(['SRPMS'] << Arch.pluck(:name)).each do |arch|
|
||||
path = "#{platform.path}/repository/#{arch}/#{name}/.sync.lock"
|
||||
path = "#{platform.path}/repository/#{arch}/#{name}/#{lock_file}"
|
||||
case action
|
||||
when :lock
|
||||
result ||= system 'touch', path
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
.hr
|
||||
= form_for @repository, :url => regenerate_metadata_platform_repository_path(@platform, @repository), :html => { :class => :form, :method => :put } do |f|
|
||||
.leftside= t('layout.repositories.regenerate_metadata')
|
||||
.rightside
|
||||
= select_tag :build_for_platform_id, options_from_collection_for_select(Platform.main, :id, :name) if @platform.personal?
|
||||
= f.submit t('layout.repositories.regenerate_metadata'), :confirm => t('layout.confirm')
|
||||
.hr{:style => 'padding-bottom:20px;'}
|
||||
.both
|
|
@ -39,13 +39,15 @@ Rosa::Application.routes.draw do
|
|||
end
|
||||
resources :repositories, :only => [:show, :update, :destroy] do
|
||||
member {
|
||||
get :projects
|
||||
get :key_pair
|
||||
put :add_member
|
||||
delete :remove_member
|
||||
put :add_project
|
||||
delete :remove_project
|
||||
put :signatures
|
||||
get :projects
|
||||
get :key_pair
|
||||
put :add_member
|
||||
delete :remove_member
|
||||
put :add_project
|
||||
delete :remove_project
|
||||
put :signatures
|
||||
put :start_sync
|
||||
put :stop_sync
|
||||
}
|
||||
end
|
||||
resources :projects, :only => [:index, :show, :update, :create, :destroy] do
|
||||
|
|
Loading…
Reference in New Issue