Commit 267839c8 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add separate permission to delete packages

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent adf209e6
......@@ -3,7 +3,7 @@ module Projects
class PackagesController < ApplicationController
before_action :verify_packages_enabled!
before_action :authorize_read_package!
before_action :authorize_admin_package!, only: [:destroy]
before_action :authorize_destroy_package!, only: [:destroy]
def index
@packages = project.packages.all.page(params[:page])
......
......@@ -6,6 +6,8 @@ class Packages::PackageFile < ActiveRecord::Base
validates :file, presence: true
validates :file_name, presence: true
scope :recent, -> { order(id: :desc) }
mount_uploader :file, Packages::PackageFileUploader
after_save :update_file_store, if: :file_changed?
......
......@@ -114,6 +114,7 @@ module EE
enable :push_code_to_protected_branches
enable :admin_path_locks
enable :update_approvers
enable :destroy_package
end
rule { license_management_enabled & can?(:maintainer_access) }.enable :admin_software_license_policy
......
- page_title "Packages"
- can_admin_package = can?(current_user, :admin_package, @project)
- can_destroy_package = can?(current_user, :destroy_package, @project)
- if @packages.any?
%table.table
......@@ -23,7 +23,7 @@
%td
= time_ago_with_tooltip(package.created_at)
%td
- if can_admin_package
- if can_destroy_package
= link_to project_package_path(@project, package), method: :delete, data: { confirm: _("Are you sure?") }, class: "btn btn-grouped btn-inverted btn-remove", title: _('Delete Package') do
= icon('trash')
......
......@@ -8,7 +8,7 @@
%strong
= @package.version
.detail-page-header-actions
- if can?(current_user, :admin_package, @project)
- if can?(current_user, :destroy_package, @project)
= link_to project_package_path(@project, @package), method: :delete, data: { confirm: _("Are you sure?") }, class: "btn btn-grouped btn-inverted btn-remove", title: _('Delete Package') do
= _('Delete')
.row.prepend-top-default
......
......@@ -7,7 +7,7 @@ describe 'Packages' do
before do
sign_in(user)
project.add_developer(user)
project.add_master(user)
end
context 'when there are no packages' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment