Project

General

Profile

Patch #25154 » project_copy.patch

Charlie Savage, 2019-06-22 01:04

View differences:

app/controllers/projects_controller.rb
23 23
  before_action :find_project, :except => [ :index, :autocomplete, :list, :new, :create, :copy ]
24 24
  before_action :authorize, :except => [ :index, :autocomplete, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
25 25
  before_action :authorize_global, :only => [:new, :create]
26
  before_action :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
26
  before_action :require_admin, :only => [ :archive, :unarchive, :destroy ]
27
  before_action :require_edit_permission_to_copy, :only => [ :copy ]
28

  
27 29
  accept_rss_auth :index
28 30
  accept_api_auth :index, :show, :create, :update, :destroy
29 31
  require_sudo_mode :destroy
......
34 36
  helper :repositories
35 37
  helper :members
36 38

  
39
  def require_edit_permission_to_copy
40
    current_project = Project.find(params[:id])
41
    allowed = User.current.allowed_to?({:controller => 'projects', :action => 'edit'}, current_project, :global => false)
42
    unless allowed
43
      render_403
44
    end
45
  end
46

  
37 47
  # Lists visible projects
38 48
  def index
39 49
    # try to redirect to the requested menu item
app/views/projects/show.html.erb
2 2
  <% if User.current.allowed_to?(:add_subprojects, @project) %>
3 3
    <%= link_to l(:label_subproject_new), new_project_path(:parent_id => @project), :class => 'icon icon-add' %>
4 4
  <% end %>
5
  <% if User.current.allowed_to?({:controller => 'projects', :action => 'edit'}, @project) %>
6
    <%= link_to 'Copy project', copy_project_path(@project), :class => 'icon icon-add' %>
7
  <% end %>
5 8
  <% if User.current.allowed_to?(:close_project, @project) %>
6 9
    <% if @project.active? %>
7 10
      <%= link_to l(:button_close), close_project_path(@project), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock' %>
(3-3/3)