]> source.dussan.org Git - redmine.git/commitdiff
Let admins unarchive the project when trying to access an archived project (#29993).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 2 Dec 2018 11:23:10 +0000 (11:23 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 2 Dec 2018 11:23:10 +0000 (11:23 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@17682 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/application_controller.rb
app/views/common/error.html.erb
test/functional/projects_controller_test.rb

index a71103a89636dbe5273b379c63a8dd2b61327b6a..94f4359481b630648aa7130fcff3edd2786fdddc 100644 (file)
@@ -259,6 +259,7 @@ class ApplicationController < ActionController::Base
       true
     else
       if @project && @project.archived?
+        @archived_project = @project
         render_403 :message => :notice_not_authorized_archived_project
       elsif @project && !@project.allows_to?(:controller => ctrl, :action => action)
         # Project module is disabled
index a5ec39c3a2f0690ddc96ce2f67ddfc4409d6e6a0..04b4b0377302c1add0f4fa8bc5313e4c81b05f03 100644 (file)
@@ -3,6 +3,11 @@
 <% if @message.present? %>
   <p id="errorExplanation"><%= @message %></p>
 <% end %>
+
+<% if @archived_project && User.current.admin? %>
+  <p><%= link_to l(:button_unarchive), unarchive_project_path(@archived_project), :method => :post, :class => 'icon icon-unlock' %></p>
+<% end %>
+
 <p><a href="javascript:history.back()"><%= l(:button_back) %></a></p>
 
 <% html_title @status %>
index df1da4a280e989d50cbbcc400bbee1ae09cb918a..e5b5eaaf425c3b36f310b4bba06fca5a92a84a87 100644 (file)
@@ -524,9 +524,9 @@ class ProjectsControllerTest < Redmine::ControllerTest
     assert_response :success
   end
 
-  def show_archived_project_should_be_denied
+  def test_show_archived_project_should_be_denied
     project = Project.find_by_identifier('ecookbook')
-    project.archive!
+    project.archive
 
     get :show, :params => {
         :id => 'ecookbook'
@@ -536,6 +536,18 @@ class ProjectsControllerTest < Redmine::ControllerTest
     assert_not_include project.name, response.body
   end
 
+  def test_show_archived_project_should_show_unarchive_link_to_admins
+    @request.session[:user_id] = 1
+    project = Project.find_by_identifier('ecookbook')
+    project.archive
+  
+    get :show, :params => {
+        :id => 'ecookbook'
+      }
+    assert_response 403
+    assert_select 'a', :text => "Unarchive"
+  end
+
   def test_show_should_not_show_private_subprojects_that_are_not_visible
     get :show, :params => {
         :id => 'ecookbook'