diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 17968bf79..645e8389b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -276,7 +276,7 @@ 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 - if @project && @project.active? + if @project && !@project.archived? if @project.visible? true else diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c89167aa3..492e31795 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -48,7 +48,11 @@ class ProjectsController < ApplicationController def index respond_to do |format| format.html { - @projects = Project.visible.find(:all, :order => 'lft') + scope = Project + unless params[:closed] + scope = scope.active + end + @projects = scope.visible.order('lft').all } format.api { @offset, @limit = api_offset_and_limit @@ -224,6 +228,16 @@ class ProjectsController < ApplicationController redirect_to(url_for(:controller => 'admin', :action => 'projects', :status => params[:status])) end + def close + @project.close + redirect_to project_path(@project) + end + + def reopen + @project.reopen + redirect_to project_path(@project) + end + # Delete @project def destroy @project_to_destroy = @project diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 01f394dd1..bacc7b8ea 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -20,6 +20,8 @@ module AdminHelper def project_status_options_for_select(selected) options_for_select([[l(:label_all), ''], - [l(:status_active), '1']], selected.to_s) + [l(:project_status_active), '1'], + [l(:project_status_closed), '5'], + [l(:project_status_archived), '9']], selected.to_s) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 794cc6f54..8c328326f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -145,11 +145,11 @@ module ApplicationHelper # link_to_project(project, {}, :class => "project") # => html options with default url (project overview) # def link_to_project(project, options={}, html_options = nil) - if project.active? + if project.archived? + h(project) + else url = {:controller => 'projects', :action => 'show', :id => project}.merge(options) link_to(h(project), url, html_options) - else - h(project) end end @@ -237,7 +237,7 @@ module ApplicationHelper # Renders the project quick-jump box def render_project_jump_box return unless User.current.logged? - projects = User.current.memberships.collect(&:project).compact.uniq + projects = User.current.memberships.collect(&:project).compact.select(&:active?).uniq if projects.any? s = '