diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-05-27 17:42:04 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-05-27 17:42:04 +0000 |
commit | 413247ee5b1643dff7923687711c77a5d90d41f5 (patch) | |
tree | 3ab2e5d182fee99cbb145f1783732db5bb46e7bc /app/controllers/projects_controller.rb | |
parent | 70374d084e19dba21e83e8a360a62ff0168ff207 (diff) | |
download | redmine-413247ee5b1643dff7923687711c77a5d90d41f5.tar.gz redmine-413247ee5b1643dff7923687711c77a5d90d41f5.zip |
Added the ability to archive projects:
* Only administrators can archive/unarchive projects.
* Once archived, the project is visible on the admin project listing only. It doesn't show up anywhere else in the app. Subprojects are also archived.
* Archive/unarchive preserve everything on the project (issues, members, ...).
* A subproject can not be unarchived if its parent project is archived.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@549 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/projects_controller.rb')
-rw-r--r-- | app/controllers/projects_controller.rb | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index debb0a00a..1de3788ac 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -19,9 +19,11 @@ require 'csv' class ProjectsController < ApplicationController layout 'base' - before_filter :find_project, :authorize, :except => [ :index, :list, :add ] - before_filter :require_admin, :only => [ :add, :destroy ] + before_filter :find_project, :except => [ :index, :list, :add ] + before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy ] + before_filter :require_admin, :only => [ :add, :archive, :unarchive, :destroy ] + cache_sweeper :project_sweeper, :only => [ :add, :edit, :archive, :unarchive, :destroy ] cache_sweeper :issue_sweeper, :only => [ :add_issue ] helper :sort @@ -86,7 +88,7 @@ class ProjectsController < ApplicationController def show @custom_values = @project.custom_values.find(:all, :include => :custom_field) @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role} - @subprojects = @project.children if @project.children.size > 0 + @subprojects = @project.active_children @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") @trackers = Tracker.find(:all, :order => 'position') @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{Issue.table_name}.status_id", :conditions => ["project_id=? and #{IssueStatus.table_name}.is_closed=?", @project.id, false]) @@ -138,12 +140,25 @@ class ProjectsController < ApplicationController end end + def archive + @project.archive if request.post? && @project.active? + redirect_to :controller => 'admin', :action => 'projects' + end + + def unarchive + @project.unarchive if request.post? && !@project.active? + redirect_to :controller => 'admin', :action => 'projects' + end + # Delete @project def destroy + @project_to_destroy = @project if request.post? and params[:confirm] - @project.destroy + @project_to_destroy.destroy redirect_to :controller => 'admin', :action => 'projects' end + # hide project in layout + @project = nil end # Add a new issue category to @project |