[refs #525] Add erase repository functional
This commit is contained in:
parent
fca1218902
commit
270dbf2e9b
|
@ -54,6 +54,12 @@ class Platforms::RepositoriesController < Platforms::BaseController
|
|||
end
|
||||
end
|
||||
|
||||
def erase
|
||||
@repository.erase
|
||||
flash[:success] = t('flash.repository.erase')
|
||||
redirect_to platform_repository_path(@platform, @repository)
|
||||
end
|
||||
|
||||
def projects_list
|
||||
|
||||
owner_subquery = "
|
||||
|
|
|
@ -90,7 +90,7 @@ class Ability
|
|||
can [:read, :projects_list], Repository, :platform => {:owner_type => 'User', :owner_id => user.id}
|
||||
can [:read, :projects_list], Repository, :platform => {:owner_type => 'Group', :owner_id => user.group_ids}
|
||||
can([:read, :projects_list], Repository, read_relations_for('repositories', 'platforms')) {|repository| local_reader? repository.platform}
|
||||
can([:create, :update, :projects_list, :add_project, :remove_project], Repository) {|repository| local_admin? repository.platform}
|
||||
can([:create, :update, :projects_list, :add_project, :remove_project, :erase], Repository) {|repository| local_admin? repository.platform}
|
||||
can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository.platform}
|
||||
|
||||
can :read, Product, :platform => {:visibility => 'open'}
|
||||
|
@ -119,7 +119,7 @@ class Ability
|
|||
|
||||
# Shared cannot rights for all users (registered, admin)
|
||||
cannot :destroy, Platform, :platform_type => 'personal'
|
||||
cannot [:create, :destroy, :add_project, :remove_project], Repository, :platform => {:platform_type => 'personal'}
|
||||
cannot [:create, :destroy, :add_project, :remove_project, :erase], Repository, :platform => {:platform_type => 'personal'}
|
||||
cannot :destroy, Issue
|
||||
|
||||
cannot [:members, :add_member, :remove_member, :remove_members], Platform, :platform_type => 'personal'
|
||||
|
|
|
@ -16,6 +16,10 @@ class Repository < ActiveRecord::Base
|
|||
attr_accessible :name, :description
|
||||
attr_readonly :name, :platform_id
|
||||
|
||||
def erase
|
||||
system("rm -Rf #{ APP_CONFIG['root_path'] }/platforms/#{ self.platform.name }/repository/*")
|
||||
end
|
||||
|
||||
def base_clone(attrs = {})
|
||||
dup.tap do |c|
|
||||
c.platform_id = nil
|
||||
|
|
|
@ -11,5 +11,7 @@
|
|||
%h3.fix= t("layout.projects.list_header")
|
||||
- if can? :add_project, @repository
|
||||
= link_to t("layout.projects.add"), add_project_platform_repository_path(@platform, @repository), :class => 'button'
|
||||
- if can? :erase, @repository
|
||||
= link_to t("layout.repositories.erase"), erase_platform_repository_path(@platform, @repository), :class => 'button', :confirm => t('layout.repositories.erase_confirm')
|
||||
|
||||
= render 'proj_list'
|
|
@ -14,6 +14,8 @@ en:
|
|||
back_to_the_list: ⇐ List of repositories
|
||||
confirm_delete: Are you sure you want to delete this repository?
|
||||
current_repository_header: Current repository
|
||||
erase: Erase
|
||||
erase_confirm: Are you sure you want to erase this repository?
|
||||
|
||||
personal_repositories:
|
||||
settings_header: Settings
|
||||
|
@ -32,6 +34,7 @@ en:
|
|||
project_not_added: Project adding error. A project with such name already exists in this repository. Remove the old project first
|
||||
project_removed: Project deleted
|
||||
project_not_removed: Unable to delete project from repository
|
||||
erase: Repository successfully erased!
|
||||
|
||||
activerecord:
|
||||
models:
|
||||
|
|
|
@ -14,6 +14,8 @@ ru:
|
|||
back_to_the_list: ⇐ К списку репозиториев
|
||||
confirm_delete: Вы уверены, что хотите удалить этот репозиторий?
|
||||
current_repository_header: Текущий репозиторий
|
||||
erase: Очистить
|
||||
erase_confirm: Уверены, что хотите очистить репозиторий?
|
||||
|
||||
personal_repositories:
|
||||
settings_header: Настройки
|
||||
|
@ -32,6 +34,7 @@ ru:
|
|||
project_not_added: Не удалось добавить проект. В этом репозитории уже есть проект с таким именем. Сначала нужно удалить старый проект
|
||||
project_removed: Проект удален из репозитория
|
||||
project_not_removed: Не удалось удалить проект из репозитория
|
||||
erase: Репозиторий успешно очищен!
|
||||
|
||||
activerecord:
|
||||
models:
|
||||
|
|
|
@ -58,6 +58,7 @@ Rosa::Application.routes.draw do
|
|||
resources :repositories do
|
||||
member do
|
||||
get :add_project
|
||||
get :erase
|
||||
delete :remove_project
|
||||
get :projects_list
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue