[refs #525] Erase corrections and refactor
This commit is contained in:
parent
ecf4666a31
commit
3ebd36f6fe
|
@ -143,4 +143,11 @@ class Platforms::PlatformsController < Platforms::BaseController
|
|||
def advisories
|
||||
@advisories = @platform.advisories.paginate(:page => params[:page])
|
||||
end
|
||||
|
||||
def erase
|
||||
@platform.erase
|
||||
flash[:success] = t('flash.repository.erase')
|
||||
redirect_to edit_platform_path(@platform)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -54,12 +54,6 @@ 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,8 @@ 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, :erase], Repository) {|repository| local_admin? repository.platform}
|
||||
can([:create, :update, :projects_list, :add_project, :remove_project], Repository) {|repository| local_admin? repository.platform}
|
||||
can(:erase, Platform) {|platform| local_admin?(platform) && platform.platform_type == 'personal'}
|
||||
can([:change_visibility, :settings, :destroy], Repository) {|repository| owner? repository.platform}
|
||||
|
||||
can :read, Product, :platform => {:visibility => 'open'}
|
||||
|
@ -119,7 +120,8 @@ class Ability
|
|||
|
||||
# Shared cannot rights for all users (registered, admin)
|
||||
cannot :destroy, Platform, :platform_type => 'personal'
|
||||
cannot [:create, :destroy, :add_project, :remove_project, :erase], Repository, :platform => {:platform_type => 'personal'}
|
||||
cannot [:create, :destroy, :add_project, :remove_project], Repository, :platform => {:platform_type => 'personal'}
|
||||
cannot :erase, Platform, :platform_type => 'main'
|
||||
cannot :destroy, Issue
|
||||
|
||||
cannot [:members, :add_member, :remove_member, :remove_members], Platform, :platform_type => 'personal'
|
||||
|
|
|
@ -48,6 +48,10 @@ class Platform < ActiveRecord::Base
|
|||
|
||||
include Modules::Models::Owner
|
||||
|
||||
def erase
|
||||
system("rm -Rf #{ APP_CONFIG['root_path'] }/platforms/#{ self.name }/repository/*")
|
||||
end
|
||||
|
||||
def urpmi_list(host, pair = nil)
|
||||
blank_pair = {:login => 'login', :pass => 'password'}
|
||||
pair = blank_pair if pair.blank?
|
||||
|
|
|
@ -16,10 +16,6 @@ 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
|
||||
|
|
|
@ -9,3 +9,8 @@
|
|||
.hr
|
||||
.leftside= t("layout.platforms.delete_warning")
|
||||
.rightside= link_to t("layout.delete"), platform_path(@platform), :method => :delete, :confirm => t("layout.platforms.confirm_delete"), :class => 'button'
|
||||
- if can? :erase, @platform
|
||||
.hr
|
||||
.leftside= t("layout.repositories.erase_warning")
|
||||
.rightside= link_to t("layout.repositories.erase"), erase_platform_path(@platform), :class => 'button', :confirm => t('layout.repositories.erase_confirm'), :method => :post
|
||||
.both
|
||||
|
|
|
@ -11,7 +11,5 @@
|
|||
%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'), :method => :post
|
||||
|
||||
= render 'proj_list'
|
||||
|
|
|
@ -16,6 +16,7 @@ en:
|
|||
current_repository_header: Current repository
|
||||
erase: Erase
|
||||
erase_confirm: Are you sure you want to erase this repository?
|
||||
erase_warning: Warning! Erased repository can not be restored!
|
||||
|
||||
personal_repositories:
|
||||
settings_header: Settings
|
||||
|
|
|
@ -16,6 +16,7 @@ ru:
|
|||
current_repository_header: Текущий репозиторий
|
||||
erase: Очистить
|
||||
erase_confirm: Уверены, что хотите очистить репозиторий?
|
||||
erase_warning: Внимание! Очищеный репозиторий не может быть восстановлен!
|
||||
|
||||
personal_repositories:
|
||||
settings_header: Настройки
|
||||
|
|
|
@ -44,6 +44,7 @@ Rosa::Application.routes.draw do
|
|||
resources :platforms do
|
||||
resources :private_users, :except => [:show, :destroy, :update]
|
||||
member do
|
||||
post :erase
|
||||
get :clone
|
||||
get :members
|
||||
post :remove_members
|
||||
|
@ -58,7 +59,6 @@ Rosa::Application.routes.draw do
|
|||
resources :repositories do
|
||||
member do
|
||||
get :add_project
|
||||
post :erase
|
||||
delete :remove_project
|
||||
get :projects_list
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue