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 | |
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')
-rw-r--r-- | app/controllers/admin_controller.rb | 12 | ||||
-rw-r--r-- | app/controllers/application.rb | 10 | ||||
-rw-r--r-- | app/controllers/projects_controller.rb | 23 | ||||
-rw-r--r-- | app/controllers/reports_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/users_controller.rb | 2 |
5 files changed, 43 insertions, 12 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 1c10722de..19efb28cc 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -27,12 +27,18 @@ class AdminController < ApplicationController def projects sort_init 'name', 'asc' - sort_update - @project_count = Project.count + sort_update + + @status = params[:status] ? params[:status].to_i : 0 + conditions = nil + conditions = ["status=?", @status] unless @status == 0 + + @project_count = Project.count(:conditions => conditions) @project_pages = Paginator.new self, @project_count, - 15, + 25, params['page'] @projects = Project.find :all, :order => sort_clause, + :conditions => conditions, :limit => @project_pages.items_per_page, :offset => @project_pages.current.offset diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 54e4768b6..58193ba8f 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -86,6 +86,11 @@ class ApplicationController < ActionController::Base # authorizes the user for the requested action. def authorize(ctrl = params[:controller], action = params[:action]) + unless @project.active? + @project = nil + render_404 + return false + end # check if action is allowed on public projects if @project.is_public? and Permission.allowed_to_public "%s/%s" % [ ctrl, action ] return true @@ -105,6 +110,11 @@ class ApplicationController < ActionController::Base # make sure that the user is a member of the project (or admin) if project is private # used as a before_filter for actions that do not require any particular permission on the project def check_project_privacy + unless @project.active? + @project = nil + render_404 + return false + end return true if @project.is_public? return false unless logged_in_user return true if logged_in_user.admin? || logged_in_user_membership 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 diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 7c0b34773..59f13d7a5 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -55,7 +55,7 @@ class ReportsController < ApplicationController render :template => "reports/issue_report_details" when "subproject" @field = "project_id" - @rows = @project.children + @rows = @project.active_children @data = issues_by_subproject @report_title = l(:field_subproject) render :template => "reports/issue_report_details" @@ -66,7 +66,7 @@ class ReportsController < ApplicationController @priorities = Enumeration::get_values('IPRI') @categories = @project.issue_categories @authors = @project.members.collect { |m| m.user } - @subprojects = @project.children + @subprojects = @project.active_children issues_by_tracker issues_by_version issues_by_priority @@ -207,8 +207,8 @@ private #{Issue.table_name} i, #{IssueStatus.table_name} s where i.status_id=s.id - and i.project_id IN (#{@project.children.collect{|p| p.id}.join(',')}) - group by s.id, s.is_closed, i.project_id") if @project.children.any? + and i.project_id IN (#{@project.active_children.collect{|p| p.id}.join(',')}) + group by s.id, s.is_closed, i.project_id") if @project.active_children.any? @issues_by_subproject ||= [] end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 93b3a4d25..908001b1a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -88,7 +88,7 @@ class UsersController < ApplicationController end @auth_sources = AuthSource.find(:all) @roles = Role.find(:all, :order => 'position') - @projects = Project.find(:all) - @user.projects + @projects = Project.find(:all, :order => 'name', :conditions => "status=#{Project::STATUS_ACTIVE}") - @user.projects @membership ||= Member.new end |