| 
									
										
										
										
											2019-03-16 09:37:35 +00:00
										 |  |  | # frozen_string_literal: true | 
					
						
							| 
									
										
										
										
											2019-03-15 01:32:57 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-25 11:10:35 +00:00
										 |  |  | # Redmine - project management software | 
					
						
							| 
									
										
										
										
											2020-03-03 00:24:10 +00:00
										 |  |  | # Copyright (C) 2006-2020  Jean-Philippe Lang | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  | # | 
					
						
							|  |  |  | # This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  | # modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  | # as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  | # of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  | # This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  | # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  | # GNU General Public License for more details. | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  | # You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  | # along with this program; if not, write to the Free Software | 
					
						
							|  |  |  | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ProjectsController < ApplicationController | 
					
						
							| 
									
										
										
										
											2008-01-19 11:53:43 +00:00
										 |  |  |   menu_item :overview | 
					
						
							|  |  |  |   menu_item :settings, :only => :settings | 
					
						
							| 
									
										
										
										
											2016-12-16 07:51:56 +00:00
										 |  |  |   menu_item :projects, :only => [:index, :new, :copy, :create] | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-13 09:20:29 +00:00
										 |  |  |   before_action :find_project, :except => [ :index, :autocomplete, :list, :new, :create, :copy ] | 
					
						
							| 
									
										
										
										
											2020-09-15 04:15:13 +00:00
										 |  |  |   before_action :authorize, :except => [ :index, :autocomplete, :list, :new, :create, :copy, :archive, :unarchive] | 
					
						
							| 
									
										
										
										
											2016-07-14 07:27:31 +00:00
										 |  |  |   before_action :authorize_global, :only => [:new, :create] | 
					
						
							| 
									
										
										
										
											2020-09-15 04:15:13 +00:00
										 |  |  |   before_action :require_admin, :only => [ :copy, :archive, :unarchive ] | 
					
						
							| 
									
										
										
										
											2011-07-09 08:56:07 +00:00
										 |  |  |   accept_rss_auth :index | 
					
						
							|  |  |  |   accept_api_auth :index, :show, :create, :update, :destroy | 
					
						
							| 
									
										
										
										
											2015-06-19 18:41:10 +00:00
										 |  |  |   require_sudo_mode :destroy | 
					
						
							| 
									
										
										
										
											2010-09-08 16:01:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   helper :custom_fields | 
					
						
							| 
									
										
										
										
											2007-10-03 17:20:04 +00:00
										 |  |  |   helper :issues | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   helper :queries | 
					
						
							| 
									
										
										
										
											2019-10-19 11:36:13 +00:00
										 |  |  |   include QueriesHelper | 
					
						
							| 
									
										
										
										
											2019-10-19 11:42:20 +00:00
										 |  |  |   helper :projects_queries | 
					
						
							|  |  |  |   include ProjectsQueriesHelper | 
					
						
							| 
									
										
										
										
											2007-06-12 20:12:05 +00:00
										 |  |  |   helper :repositories | 
					
						
							| 
									
										
										
										
											2013-01-18 17:57:16 +00:00
										 |  |  |   helper :members | 
					
						
							| 
									
										
										
										
											2019-03-15 10:38:56 +00:00
										 |  |  |   helper :trackers | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-14 19:55:51 +00:00
										 |  |  |   # Lists visible projects | 
					
						
							| 
									
										
										
										
											2008-05-26 20:10:32 +00:00
										 |  |  |   def index | 
					
						
							| 
									
										
										
										
											2017-01-10 18:33:36 +00:00
										 |  |  |     # try to redirect to the requested menu item | 
					
						
							|  |  |  |     if params[:jump] && redirect_to_menu_item(params[:jump]) | 
					
						
							|  |  |  |       return | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-19 11:36:13 +00:00
										 |  |  |     retrieve_project_query | 
					
						
							|  |  |  |     scope = project_scope | 
					
						
							| 
									
										
										
										
											2014-11-02 20:44:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-27 16:49:18 +00:00
										 |  |  |     respond_to do |format| | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  |       format.html { | 
					
						
							| 
									
										
										
										
											2019-10-26 07:09:52 +00:00
										 |  |  |         # TODO: see what to do with the board view and pagination | 
					
						
							|  |  |  |         if @query.display_type == 'board' | 
					
						
							|  |  |  |           @entries = scope.to_a | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |           @entry_count = scope.count | 
					
						
							|  |  |  |           @entry_pages = Paginator.new @entry_count, per_page_option, params['page'] | 
					
						
							|  |  |  |           @entries = scope.offset(@entry_pages.offset).limit(@entry_pages.per_page).to_a | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2008-05-27 16:49:18 +00:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2010-12-03 12:06:14 +00:00
										 |  |  |       format.api  { | 
					
						
							| 
									
										
										
										
											2010-12-23 13:34:44 +00:00
										 |  |  |         @offset, @limit = api_offset_and_limit | 
					
						
							| 
									
										
										
										
											2014-11-02 20:44:11 +00:00
										 |  |  |         @project_count = scope.count | 
					
						
							|  |  |  |         @projects = scope.offset(@offset).limit(@limit).to_a | 
					
						
							| 
									
										
										
										
											2010-01-14 20:00:17 +00:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2008-05-27 16:49:18 +00:00
										 |  |  |       format.atom { | 
					
						
							| 
									
										
										
										
											2014-11-02 20:44:11 +00:00
										 |  |  |         projects = scope.reorder(:created_on => :desc).limit(Setting.feeds_limit.to_i).to_a | 
					
						
							| 
									
										
										
										
											2009-01-24 11:31:15 +00:00
										 |  |  |         render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}") | 
					
						
							| 
									
										
										
										
											2008-05-27 16:49:18 +00:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2019-10-19 11:42:20 +00:00
										 |  |  |       format.csv { | 
					
						
							|  |  |  |         # Export all entries | 
					
						
							|  |  |  |         @entries = scope.to_a | 
					
						
							|  |  |  |         send_data(query_to_csv(@entries, @query, params), :type => 'text/csv; header=present', :filename => 'projects.csv') | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2008-05-27 16:49:18 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-13 09:20:29 +00:00
										 |  |  |   def autocomplete | 
					
						
							|  |  |  |     respond_to do |format| | 
					
						
							|  |  |  |       format.js { | 
					
						
							|  |  |  |         if params[:q].present? | 
					
						
							|  |  |  |           @projects = Project.visible.like(params[:q]).to_a | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |           @projects = User.current.projects.to_a | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-07 15:00:27 +00:00
										 |  |  |   def new | 
					
						
							| 
									
										
										
										
											2014-10-22 17:37:16 +00:00
										 |  |  |     @issue_custom_fields = IssueCustomField.sorted.to_a | 
					
						
							|  |  |  |     @trackers = Tracker.sorted.to_a | 
					
						
							| 
									
										
										
										
											2012-03-06 19:52:10 +00:00
										 |  |  |     @project = Project.new | 
					
						
							|  |  |  |     @project.safe_attributes = params[:project] | 
					
						
							| 
									
										
										
										
											2010-09-06 14:53:08 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def create | 
					
						
							| 
									
										
										
										
											2014-10-22 17:37:16 +00:00
										 |  |  |     @issue_custom_fields = IssueCustomField.sorted.to_a | 
					
						
							|  |  |  |     @trackers = Tracker.sorted.to_a | 
					
						
							| 
									
										
										
										
											2010-12-12 13:19:07 +00:00
										 |  |  |     @project = Project.new | 
					
						
							|  |  |  |     @project.safe_attributes = params[:project] | 
					
						
							| 
									
										
										
										
											2010-09-06 14:53:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-07 22:19:57 +00:00
										 |  |  |     if @project.save | 
					
						
							| 
									
										
										
										
											2010-09-06 14:53:08 +00:00
										 |  |  |       unless User.current.admin? | 
					
						
							| 
									
										
										
										
											2014-11-02 20:55:02 +00:00
										 |  |  |         @project.add_default_member(User.current) | 
					
						
							| 
									
										
										
										
											2010-09-06 14:53:08 +00:00
										 |  |  |       end | 
					
						
							|  |  |  |       respond_to do |format| | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  |         format.html { | 
					
						
							| 
									
										
										
										
											2010-09-06 14:53:08 +00:00
										 |  |  |           flash[:notice] = l(:notice_successful_create) | 
					
						
							| 
									
										
										
										
											2012-12-11 19:39:47 +00:00
										 |  |  |           if params[:continue] | 
					
						
							|  |  |  |             attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?} | 
					
						
							|  |  |  |             redirect_to new_project_path(attrs) | 
					
						
							|  |  |  |           else | 
					
						
							|  |  |  |             redirect_to settings_project_path(@project) | 
					
						
							|  |  |  |           end | 
					
						
							| 
									
										
										
										
											2010-09-06 14:53:08 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2010-12-04 17:43:39 +00:00
										 |  |  |         format.api  { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) } | 
					
						
							| 
									
										
										
										
											2010-09-06 14:53:08 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2010-09-06 14:53:08 +00:00
										 |  |  |       respond_to do |format| | 
					
						
							| 
									
										
										
										
											2010-09-07 15:00:27 +00:00
										 |  |  |         format.html { render :action => 'new' } | 
					
						
							| 
									
										
										
										
											2010-12-03 12:06:14 +00:00
										 |  |  |         format.api  { render_validation_errors(@project) } | 
					
						
							| 
									
										
										
										
											2009-05-17 12:59:14 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2010-09-06 14:53:08 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-03 21:25:37 +00:00
										 |  |  |   def copy | 
					
						
							| 
									
										
										
										
											2014-10-22 17:37:16 +00:00
										 |  |  |     @issue_custom_fields = IssueCustomField.sorted.to_a | 
					
						
							|  |  |  |     @trackers = Tracker.sorted.to_a | 
					
						
							| 
									
										
										
										
											2009-10-25 11:10:35 +00:00
										 |  |  |     @source_project = Project.find(params[:id]) | 
					
						
							| 
									
										
										
										
											2009-05-03 21:25:37 +00:00
										 |  |  |     if request.get? | 
					
						
							| 
									
										
										
										
											2009-10-25 11:10:35 +00:00
										 |  |  |       @project = Project.copy_from(@source_project) | 
					
						
							| 
									
										
										
										
											2012-12-01 17:57:30 +00:00
										 |  |  |       @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? | 
					
						
							| 
									
										
										
										
											2009-05-03 21:25:37 +00:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2010-03-21 11:17:29 +00:00
										 |  |  |       Mailer.with_deliveries(params[:notifications] == '1') do | 
					
						
							| 
									
										
										
										
											2010-12-12 13:19:07 +00:00
										 |  |  |         @project = Project.new | 
					
						
							|  |  |  |         @project.safe_attributes = params[:project] | 
					
						
							| 
									
										
										
										
											2015-01-07 22:19:57 +00:00
										 |  |  |         if @project.copy(@source_project, :only => params[:only]) | 
					
						
							| 
									
										
										
										
											2010-03-21 11:17:29 +00:00
										 |  |  |           flash[:notice] = l(:notice_successful_create) | 
					
						
							| 
									
										
										
										
											2012-12-11 19:39:47 +00:00
										 |  |  |           redirect_to settings_project_path(@project) | 
					
						
							| 
									
										
										
										
											2010-03-21 11:17:29 +00:00
										 |  |  |         elsif !@project.new_record? | 
					
						
							|  |  |  |           # Project was created | 
					
						
							|  |  |  |           # But some objects were not copied due to validation failures | 
					
						
							|  |  |  |           # (eg. issues from disabled trackers) | 
					
						
							|  |  |  |           # TODO: inform about that | 
					
						
							| 
									
										
										
										
											2012-12-11 19:39:47 +00:00
										 |  |  |           redirect_to settings_project_path(@project) | 
					
						
							| 
									
										
										
										
											2010-03-21 11:17:29 +00:00
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2009-12-26 10:18:28 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2009-10-29 18:51:10 +00:00
										 |  |  |     end | 
					
						
							|  |  |  |   rescue ActiveRecord::RecordNotFound | 
					
						
							| 
									
										
										
										
											2012-12-01 17:57:30 +00:00
										 |  |  |     # source_project not found | 
					
						
							|  |  |  |     render_404 | 
					
						
							| 
									
										
										
										
											2009-05-03 21:25:37 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2013-02-17 10:15:10 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   # Show @project | 
					
						
							|  |  |  |   def show | 
					
						
							| 
									
										
										
										
											2013-01-20 15:09:57 +00:00
										 |  |  |     # try to redirect to the requested menu item | 
					
						
							|  |  |  |     if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) | 
					
						
							| 
									
										
										
										
											2013-01-20 13:54:42 +00:00
										 |  |  |       return | 
					
						
							| 
									
										
										
										
											2008-12-30 14:24:51 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-22 14:52:58 +00:00
										 |  |  |     @principals_by_role = @project.principals_by_role | 
					
						
							| 
									
										
										
										
											2017-07-08 12:16:36 +00:00
										 |  |  |     @subprojects = @project.children.visible.to_a | 
					
						
							| 
									
										
										
										
											2014-10-22 17:37:16 +00:00
										 |  |  |     @news = @project.news.limit(5).includes(:author, :project).reorder("#{News.table_name}.created_on DESC").to_a | 
					
						
							| 
									
										
										
										
											2016-06-18 06:42:25 +00:00
										 |  |  |     @trackers = @project.rolled_up_trackers.visible | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-03-27 18:22:12 +00:00
										 |  |  |     cond = @project.project_condition(Setting.display_subprojects_issues?) | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-10 07:46:53 +00:00
										 |  |  |     @open_issues_by_tracker = Issue.visible.open.where(cond).group(:tracker).count | 
					
						
							|  |  |  |     @total_issues_by_tracker = Issue.visible.where(cond).group(:tracker).count | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-30 07:40:57 +00:00
										 |  |  |     if User.current.allowed_to_view_all_time_entries?(@project) | 
					
						
							| 
									
										
										
										
											2013-06-12 19:13:25 +00:00
										 |  |  |       @total_hours = TimeEntry.visible.where(cond).sum(:hours).to_f | 
					
						
							| 
									
										
										
										
											2019-01-22 23:34:57 +00:00
										 |  |  |       @total_estimated_hours = Issue.visible.where(cond).sum(:estimated_hours).to_f | 
					
						
							| 
									
										
										
										
											2008-02-27 20:50:19 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-08-29 16:52:35 +00:00
										 |  |  |     @key = User.current.rss_key | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-14 20:00:17 +00:00
										 |  |  |     respond_to do |format| | 
					
						
							|  |  |  |       format.html | 
					
						
							| 
									
										
										
										
											2010-12-04 17:43:39 +00:00
										 |  |  |       format.api | 
					
						
							| 
									
										
										
										
											2010-01-14 20:00:17 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2006-07-09 16:30:01 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   def settings | 
					
						
							| 
									
										
										
										
											2014-10-22 17:37:16 +00:00
										 |  |  |     @issue_custom_fields = IssueCustomField.sorted.to_a | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |     @issue_category ||= IssueCategory.new | 
					
						
							|  |  |  |     @member ||= @project.members.new | 
					
						
							| 
									
										
										
										
											2014-10-22 17:37:16 +00:00
										 |  |  |     @trackers = Tracker.sorted.to_a | 
					
						
							| 
									
										
										
										
											2016-08-30 21:05:22 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     @version_status = params[:version_status] || 'open' | 
					
						
							|  |  |  |     @version_name = params[:version_name] | 
					
						
							| 
									
										
										
										
											2018-12-02 22:31:44 +00:00
										 |  |  |     @versions = @project.shared_versions.status(@version_status).like(@version_name).sorted | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   def edit | 
					
						
							| 
									
										
										
										
											2010-09-08 16:01:51 +00:00
										 |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def update | 
					
						
							| 
									
										
										
										
											2010-12-12 13:19:07 +00:00
										 |  |  |     @project.safe_attributes = params[:project] | 
					
						
							| 
									
										
										
										
											2015-01-07 22:19:57 +00:00
										 |  |  |     if @project.save | 
					
						
							| 
									
										
										
										
											2010-09-08 16:01:51 +00:00
										 |  |  |       respond_to do |format| | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  |         format.html { | 
					
						
							| 
									
										
										
										
											2010-09-08 16:01:51 +00:00
										 |  |  |           flash[:notice] = l(:notice_successful_update) | 
					
						
							| 
									
										
										
										
											2017-07-27 16:42:50 +00:00
										 |  |  |           redirect_to settings_project_path(@project, params[:tab]) | 
					
						
							| 
									
										
										
										
											2010-09-08 16:01:51 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-07-14 08:13:55 +00:00
										 |  |  |         format.api  { render_api_ok } | 
					
						
							| 
									
										
										
										
											2010-09-08 16:01:51 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2010-01-14 20:00:17 +00:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2010-09-08 16:01:51 +00:00
										 |  |  |       respond_to do |format| | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  |         format.html { | 
					
						
							| 
									
										
										
										
											2010-09-08 16:01:51 +00:00
										 |  |  |           settings | 
					
						
							|  |  |  |           render :action => 'settings' | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2010-12-03 12:06:14 +00:00
										 |  |  |         format.api  { render_validation_errors(@project) } | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2006-07-09 16:30:01 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-01-06 20:57:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-27 17:42:04 +00:00
										 |  |  |   def archive | 
					
						
							| 
									
										
										
										
											2014-11-02 20:32:11 +00:00
										 |  |  |     unless @project.archive | 
					
						
							|  |  |  |       flash[:error] = l(:error_can_not_archive_project) | 
					
						
							| 
									
										
										
										
											2009-12-06 10:28:20 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-08-30 20:10:56 +00:00
										 |  |  |     redirect_to_referer_or admin_projects_path(:status => params[:status]) | 
					
						
							| 
									
										
										
										
											2007-05-27 17:42:04 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-27 17:42:04 +00:00
										 |  |  |   def unarchive | 
					
						
							| 
									
										
										
										
											2014-11-02 20:32:11 +00:00
										 |  |  |     unless @project.active? | 
					
						
							|  |  |  |       @project.unarchive | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2016-08-30 20:10:56 +00:00
										 |  |  |     redirect_to_referer_or admin_projects_path(:status => params[:status]) | 
					
						
							| 
									
										
										
										
											2007-05-27 17:42:04 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2011-08-31 12:02:48 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-20 22:26:30 +00:00
										 |  |  |   def bookmark | 
					
						
							|  |  |  |     jump_box = Redmine::ProjectJumpBox.new User.current | 
					
						
							|  |  |  |     if request.delete? | 
					
						
							|  |  |  |       jump_box.delete_project_bookmark @project | 
					
						
							|  |  |  |     elsif request.post? | 
					
						
							|  |  |  |       jump_box.bookmark_project @project | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |     respond_to do |format| | 
					
						
							|  |  |  |       format.js | 
					
						
							|  |  |  |       format.html { redirect_to project_path(@project) } | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-25 17:49:35 +00:00
										 |  |  |   def close | 
					
						
							|  |  |  |     @project.close | 
					
						
							|  |  |  |     redirect_to project_path(@project) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def reopen | 
					
						
							|  |  |  |     @project.reopen | 
					
						
							|  |  |  |     redirect_to project_path(@project) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-07-29 09:32:58 +00:00
										 |  |  |   # Delete @project | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   def destroy | 
					
						
							| 
									
										
										
										
											2020-09-15 04:15:13 +00:00
										 |  |  |     unless @project.deletable? | 
					
						
							|  |  |  |       deny_access | 
					
						
							|  |  |  |       return | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-05-27 17:42:04 +00:00
										 |  |  |     @project_to_destroy = @project | 
					
						
							| 
									
										
										
										
											2011-12-10 09:32:41 +00:00
										 |  |  |     if api_request? || params[:confirm] | 
					
						
							|  |  |  |       @project_to_destroy.destroy | 
					
						
							|  |  |  |       respond_to do |format| | 
					
						
							| 
									
										
										
										
											2020-09-15 04:15:13 +00:00
										 |  |  |         format.html { redirect_to User.current.admin? ? admin_projects_path : projects_path } | 
					
						
							| 
									
										
										
										
											2012-07-14 08:13:55 +00:00
										 |  |  |         format.api  { render_api_ok } | 
					
						
							| 
									
										
										
										
											2010-01-14 20:00:17 +00:00
										 |  |  |       end | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2007-05-27 17:42:04 +00:00
										 |  |  |     # hide project in layout | 
					
						
							|  |  |  |     @project = nil | 
					
						
							| 
									
										
										
										
											2007-03-12 17:59:02 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2019-10-19 11:36:13 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   private | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   # Returns the ProjectEntry scope for index | 
					
						
							|  |  |  |   def project_scope(options={}) | 
					
						
							|  |  |  |     @query.results_scope(options) | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   def retrieve_project_query | 
					
						
							| 
									
										
										
										
											2019-10-19 11:43:23 +00:00
										 |  |  |     retrieve_query(ProjectQuery, false, :defaults => @default_columns_names) | 
					
						
							| 
									
										
										
										
											2019-10-19 11:36:13 +00:00
										 |  |  |   end | 
					
						
							| 
									
										
										
										
											2006-06-28 18:11:03 +00:00
										 |  |  | end |