OSDN Git Service

Improved error message when trying to access an archived project (#2995).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 23 Oct 2010 09:48:01 +0000 (09:48 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 23 Oct 2010 09:48:01 +0000 (09:48 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4285 e93f8b46-1217-0410-a6f0-8f06a7374b81

48 files changed:
app/controllers/application_controller.rb
app/models/project.rb
app/views/common/403.rhtml
config/locales/bg.yml
config/locales/bs.yml
config/locales/ca.yml
config/locales/cs.yml
config/locales/da.yml
config/locales/de.yml
config/locales/el.yml
config/locales/en-GB.yml
config/locales/en.yml
config/locales/es.yml
config/locales/eu.yml
config/locales/fi.yml
config/locales/fr.yml
config/locales/gl.yml
config/locales/he.yml
config/locales/hr.yml
config/locales/hu.yml
config/locales/id.yml
config/locales/it.yml
config/locales/ja.yml
config/locales/ko.yml
config/locales/lt.yml
config/locales/lv.yml
config/locales/mk.yml
config/locales/mn.yml
config/locales/nl.yml
config/locales/no.yml
config/locales/pl.yml
config/locales/pt-BR.yml
config/locales/pt.yml
config/locales/ro.yml
config/locales/ru.yml
config/locales/sk.yml
config/locales/sl.yml
config/locales/sr-YU.yml
config/locales/sr.yml
config/locales/sv.yml
config/locales/th.yml
config/locales/tr.yml
config/locales/uk.yml
config/locales/vi.yml
config/locales/zh-TW.yml
config/locales/zh.yml
test/functional/projects_controller_test.rb
test/unit/project_test.rb

index 1299dac..360d091 100644 (file)
@@ -154,7 +154,15 @@ class ApplicationController < ActionController::Base
   # Authorize the user for the requested action
   def authorize(ctrl = params[:controller], action = params[:action], global = false)
     allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
-    allowed ? true : deny_access
+    if allowed
+      true
+    else
+      if @project && @project.archived?
+        render_403 :message => :notice_not_authorized_archived_project
+      else
+        deny_access
+      end
+    end
   end
 
   # Authorize the user for the requested action outside a project
@@ -265,8 +273,10 @@ class ApplicationController < ActionController::Base
     redirect_to default
   end
   
-  def render_403
+  def render_403(options={})
     @project = nil
+    @message = options[:message] || :notice_not_authorized
+    @message = l(@message) if @message.is_a?(Symbol)
     respond_to do |format|
       format.html { render :template => "common/403", :layout => use_layout, :status => 403 }
       format.atom { head 403 }
index 16c9744..a6d7dc7 100644 (file)
@@ -220,6 +220,10 @@ class Project < ActiveRecord::Base
     self.status == STATUS_ACTIVE
   end
   
+  def archived?
+    self.status == STATUS_ARCHIVED
+  end
+  
   # Archives the project and its descendants
   def archive
     # Check that there is no issue of a non descendant project that is assigned
index d1173a1..43f487d 100644 (file)
@@ -1,6 +1,6 @@
 <h2>403</h2>
 
-<p><%= l(:notice_not_authorized) %></p>
+<p><%=h @message %></p>
 <p><a href="javascript:history.back()">Back</a></p>
 
 <% html_title '403' %>
index e6f92cc..a3f78f8 100644 (file)
@@ -916,3 +916,4 @@ bg:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index f637351..cebe14d 100644 (file)
@@ -936,3 +936,4 @@ bs:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 842ef62..9befe1d 100644 (file)
@@ -925,3 +925,4 @@ ca:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index d4449ce..5e90855 100644 (file)
@@ -922,3 +922,4 @@ cs:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index e557721..87e813b 100644 (file)
@@ -938,3 +938,4 @@ da:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 9c9a853..f2eb1e8 100644 (file)
@@ -941,3 +941,4 @@ de:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 963f30d..85f4bcc 100644 (file)
@@ -922,3 +922,4 @@ el:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index a6b2817..e14276a 100644 (file)
@@ -926,3 +926,4 @@ en-GB:
   setting_default_notification_option: Default notification option
   label_user_mail_option_only_my_events: Only for things I watch or I'm involved in
   label_user_mail_option_only_assigned: Only for things I am assigned to
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.\r
index bdf2e98..083d781 100644 (file)
@@ -150,6 +150,7 @@ en:
   notice_file_not_found: The page you were trying to access doesn't exist or has been removed.
   notice_locking_conflict: Data has been updated by another user.
   notice_not_authorized: You are not authorized to access this page.
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
   notice_email_sent: "An email was sent to {{value}}"
   notice_email_error: "An error occurred while sending mail ({{value}})"
   notice_feeds_access_key_reseted: Your RSS access key was reset.
index 2b08b1d..8f824d2 100644 (file)
@@ -962,3 +962,4 @@ es:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index b45bf0e..6072c3b 100644 (file)
@@ -926,3 +926,4 @@ eu:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.\r
index e4f107e..b1fdae7 100644 (file)
@@ -947,3 +947,4 @@ fi:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 6784893..92720ab 100644 (file)
@@ -169,6 +169,7 @@ fr:
   notice_file_not_found: "La page Ã  laquelle vous souhaitez accéder n'existe pas ou a Ã©té supprimée."
   notice_locking_conflict: Les données ont Ã©té mises Ã  jour par un autre utilisateur. Mise Ã  jour impossible.
   notice_not_authorized: "Vous n'êtes pas autorisés Ã  accéder Ã  cette page."
+  notice_not_authorized_archived_project: Le projet auquel vous tentez d'accéder a Ã©té archivé.
   notice_email_sent: "Un email a Ã©té envoyé Ã  {{value}}"
   notice_email_error: "Erreur lors de l'envoi de l'email ({{value}})"
   notice_feeds_access_key_reseted: "Votre clé d'accès aux flux RSS a Ã©té réinitialisée."
index 14f04ab..d3ee6de 100644 (file)
@@ -938,3 +938,4 @@ gl:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 1fc167e..72f5a6c 100644 (file)
@@ -927,3 +927,4 @@ he:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 725411c..a9f702e 100644 (file)
@@ -929,3 +929,4 @@ hr:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 767f2d6..b08e905 100644 (file)
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index b913670..e3e120f 100644 (file)
@@ -930,3 +930,4 @@ id:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index f39dfbb..2faa28b 100644 (file)
@@ -926,3 +926,4 @@ it:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 92bfd15..a9adc09 100644 (file)
@@ -947,3 +947,4 @@ ja:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 7cc8ad6..e74ad2a 100644 (file)
@@ -978,3 +978,4 @@ ko:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 186c61a..e091422 100644 (file)
@@ -986,3 +986,4 @@ lt:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 5c338cd..c0fd237 100644 (file)
@@ -917,3 +917,4 @@ lv:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.\r
index 6dd1fca..5d7124f 100644 (file)
@@ -922,3 +922,4 @@ mk:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.\r
index a0f4be9..b6032f9 100644 (file)
@@ -923,3 +923,4 @@ mn:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.\r
index ab9fdfa..b151657 100644 (file)
@@ -904,3 +904,4 @@ nl:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 592af9d..b21eba1 100644 (file)
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index d119310..25099c9 100644 (file)
@@ -943,3 +943,4 @@ pl:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index f860930..78448f7 100644 (file)
@@ -946,3 +946,4 @@ pt-BR:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index eb8917e..24ee868 100644 (file)
@@ -930,3 +930,4 @@ pt:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index b1e311f..7076ef8 100644 (file)
@@ -915,3 +915,4 @@ ro:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index ee6c704..b0ed5cb 100644 (file)
@@ -1039,3 +1039,4 @@ ru:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index e49a214..c26bca7 100644 (file)
@@ -917,3 +917,4 @@ sk:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 33eade5..417a19a 100644 (file)
@@ -918,3 +918,4 @@ sl:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 0aee7ec..53c8e5e 100644 (file)
@@ -922,3 +922,4 @@ sr-YU:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.\r
index b1686eb..dd49240 100644 (file)
@@ -923,3 +923,4 @@ sr:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 0b19956..8509a03 100644 (file)
@@ -967,3 +967,4 @@ sv:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index d0275af..7344a92 100644 (file)
@@ -919,3 +919,4 @@ th:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 32ae9cc..3fd0b74 100644 (file)
@@ -945,3 +945,4 @@ tr:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 28e6caa..f755641 100644 (file)
@@ -918,3 +918,4 @@ uk:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 84adc16..b1e1662 100644 (file)
@@ -977,3 +977,4 @@ vi:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 89ea488..82db927 100644 (file)
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 3439b31..ba93329 100644 (file)
@@ -940,3 +940,4 @@ zh:
   label_user_mail_option_none: No events
   field_member_of_group: Assignee's group
   field_assigned_to_role: Assignee's role
+  notice_not_authorized_archived_project: The project you're trying to access has been archived.
index 8a9bbe6..7122f89 100644 (file)
@@ -296,6 +296,16 @@ class ProjectsControllerTest < ActionController::TestCase
     assert_equal Project.find_by_identifier('ecookbook'), assigns(:project)
   end
   
+  def show_archived_project_should_be_denied
+    project = Project.find_by_identifier('ecookbook')
+    project.archive!
+    
+    get :show, :id => 'ecookbook'
+    assert_response 403
+    assert_nil assigns(:project)
+    assert_tag :tag => 'p', :content => /archived/
+  end
+  
   def test_private_subprojects_hidden
     get :show, :id => 'ecookbook'
     assert_response :success
index 08b0fb2..e4927eb 100644 (file)
@@ -102,6 +102,7 @@ class ProjectTest < ActiveSupport::TestCase
     @ecookbook.reload
     
     assert !@ecookbook.active?
+    assert @ecookbook.archived?
     assert !user.projects.include?(@ecookbook)
     # Subproject are also archived
     assert !@ecookbook.children.empty?
@@ -129,6 +130,7 @@ class ProjectTest < ActiveSupport::TestCase
     assert @ecookbook.unarchive
     @ecookbook.reload
     assert @ecookbook.active?
+    assert !@ecookbook.archived?
     assert user.projects.include?(@ecookbook)
     # Subproject can now be unarchived
     @ecookbook_sub1.reload