Initial commit
This commit is contained in:
commit
d6fe167d2d
|
@ -0,0 +1,3 @@
|
|||
= supprime_projet
|
||||
|
||||
Description goes here
|
|
@ -0,0 +1,68 @@
|
|||
class DeleteProjectController < ApplicationController
|
||||
|
||||
# For the authorizations, applies filter and the function to define the current project (in the bottom of this file)
|
||||
before_filter :find_project, :authorize, :only => [:index, :valider]
|
||||
|
||||
|
||||
def index
|
||||
@dead_project = Project.find(params[:project_id])
|
||||
|
||||
res= Array.new
|
||||
|
||||
# The project ID
|
||||
project_id= @dead_project["id"]
|
||||
|
||||
# Check if there are sub-projects
|
||||
# (which have not been already marked as deleted - thanks to Luis Serrano Aranda for the feedback)
|
||||
status_number= Setting['plugin_redmine_delete_project']['status_number'].to_i
|
||||
res= Project.find_by_sql("SELECT * FROM projects WHERE ( parent_id=#{project_id} AND status!=#{status_number} )")
|
||||
@subprojects= res.length
|
||||
|
||||
# String to type for confirmation
|
||||
@ok= I18n.t("global.confirm_string")
|
||||
end
|
||||
|
||||
|
||||
def submit
|
||||
ok= I18n.t("global.confirm_string")
|
||||
# Get the settings
|
||||
status_number= Setting['plugin_redmine_delete_project']['status_number'].to_i
|
||||
chmod= Setting['plugin_redmine_delete_project']['chmod']
|
||||
destroy= Setting['plugin_redmine_delete_project']['destroy']
|
||||
repos_path= Setting['plugin_redmine_delete_project']['repos_path'] + "/"
|
||||
|
||||
if params[:confirm][0] == ok
|
||||
dead_project= Project.find_by_identifier(params[:dead_project])
|
||||
if destroy == "yes"
|
||||
res= dead_project.destroy
|
||||
else
|
||||
dead_project.status= status_number
|
||||
res= dead_project.save
|
||||
end
|
||||
|
||||
if res
|
||||
flash[:notice]= I18n.t("project_delete.done")
|
||||
if chmod == "yes"
|
||||
File.chmod 0000, repos_path + dead_project.identifier
|
||||
end
|
||||
else
|
||||
flash[:error]= I18n.t("project_delete.error")
|
||||
end
|
||||
|
||||
else
|
||||
flash[:notice]= I18n.t("project_delete.unconfirmed", :ok => ok)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def find_project
|
||||
# @project variable must be set before calling the authorize filter
|
||||
@project = Project.find(params[:project_id])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<h2><%= I18n.t("index.title") %></h2>
|
||||
|
||||
<% if @subprojects != 0 %>
|
||||
<%= I18n.t("index.subprojects_exist") %>
|
||||
<% else %>
|
||||
<font color="red"><b><%= I18n.t("index.attention") %>:</b></font>
|
||||
<%= I18n.t("index.warning", :dead_project => @dead_project, :ok => @ok).html_safe %>
|
||||
|
||||
<!-- Form -->
|
||||
<%= form_tag :controller=>'delete_project', :action=>'submit' do %>
|
||||
<table>
|
||||
<tr><td><b><%= I18n.t("index.are_you_sure") %></b></td><td>
|
||||
<%= text_field :confirm, params[:confirm], :size => 20 %>
|
||||
</td>
|
||||
<td> <%= hidden_field :dead_project, params[:dead_project], :value => params[:project_id] %></td></tr>
|
||||
</table>
|
||||
|
||||
<!-- Submit -->
|
||||
<%= submit_tag I18n.t("index.submit_button") %>
|
||||
|
||||
<% end %>
|
||||
<!-- /Form -->
|
||||
|
||||
<% end # End du IF @subprojects %>
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
<h2>DeleteProject#submit</h2>
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
<b><%=I18n.t "settings.destroy" %></b>:
|
||||
<%= select_tag 'settings[destroy]', options_for_select([
|
||||
[t("settings.affirmative"), "yes"],
|
||||
[t("settings.negative"), "no"]
|
||||
], @settings['destroy'])%>
|
||||
|
||||
<br/> <br/>
|
||||
|
||||
<b><%= I18n.t "settings.status_number" %></b>:
|
||||
<%= text_field_tag("settings[status_number]", @settings["status_number"]) %>
|
||||
|
||||
|
||||
<br/> <br/>
|
||||
|
||||
|
||||
<b><%=I18n.t "settings.chmod" %></b>:
|
||||
<%= select_tag 'settings[chmod]', options_for_select([
|
||||
[t("settings.affirmative"), "yes"],
|
||||
[t("settings.negative"), "no"]
|
||||
], @settings['chmod'])%>
|
||||
|
||||
<br/> <br/>
|
||||
|
||||
<b><%= I18n.t "settings.repos_path" %></b>:
|
||||
<%= text_field_tag("settings[repos_path]", @settings["repos_path"]) %>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# English strings go here for Rails i18n
|
||||
en:
|
||||
label_feature_name: "Delete Project"
|
||||
|
||||
project_module_delete_project: "Delete Project"
|
||||
|
||||
permission_delete_project: "Delete Project"
|
||||
|
||||
global:
|
||||
confirm_string: "yes"
|
||||
|
||||
project_delete:
|
||||
error: "An error occured, the project has not been deleted"
|
||||
unconfirmed: "Project deletion cancelled (you didn't confirm by saying '%{ok}')"
|
||||
done: "The project has been deleted"
|
||||
|
||||
index:
|
||||
title: "Delete a project"
|
||||
subprojects_exist: "Sub-projects are linked with this project. Delete them first."
|
||||
attention: "Attention"
|
||||
warning: "You are going to delete the project <b>%{dead_project}</b>.<br/>This will be definitive. Please answer '%{ok}' to confirm."
|
||||
are_you_sure: "Are you sure?"
|
||||
submit_button: "Confirm"
|
||||
|
||||
settings:
|
||||
affirmative: "Yes"
|
||||
negative: "No"
|
||||
destroy: "Really delete the project from the database"
|
||||
status_number: "(If no delete:) Which value should be assigned to the status DELETED"
|
||||
chmod: "Apply a 'chmod 000' on the repository"
|
||||
repos_path: "(If chmod is executed:) Path of the repositories"
|
|
@ -0,0 +1,31 @@
|
|||
# Japanese strings go here for Rails i18n
|
||||
ja:
|
||||
label_feature_name: "プロジェクト消去"
|
||||
|
||||
project_module_delete_project: "プロジェクト消去"
|
||||
|
||||
permission_delete_project: "プロジェクト消去"
|
||||
|
||||
global:
|
||||
confirm_string: "はい"
|
||||
|
||||
project_delete:
|
||||
error: "エラーが発生したので、プロジェクトは消去されませんでした"
|
||||
unconfirmed: "プロジェクト消去はキャンセルされました ('%{ok}'と入力されませんでした)"
|
||||
done: "プロジェクトは消去されました"
|
||||
|
||||
index:
|
||||
title: "プロジェクト消去"
|
||||
subprojects_exist: "サブプロジェクトが存在しますので、先にそれらを消去してから実行してください"
|
||||
attention: "警告"
|
||||
warning: "このプロジェクトを消去しようとしています <b>%{dead_project}</b>.<br/>この操作は元にもどせません、確認の為 '%{ok}'と入力してください."
|
||||
are_you_sure: "よろしいですか?"
|
||||
submit_button: "確認"
|
||||
|
||||
settings:
|
||||
affirmative: "Yes"
|
||||
negative: "No"
|
||||
destroy: "Really delete the project from the database"
|
||||
status_number: "(If no delete:) Which value should be assigned to the status DELETED"
|
||||
chmod: "Apply a 'chmod 000' on the repository"
|
||||
repos_path: "(If chmod is executed:) Path of the repositories"
|
|
@ -0,0 +1,4 @@
|
|||
RedmineApp::Application.routes.draw do
|
||||
#map.connect 'projects/:id/code_review/:action', :controller => 'code_review'
|
||||
match 'projects/:id/delete_project/:action', :controller => 'delete_project', :via => [:get, :post]
|
||||
end
|
|
@ -0,0 +1,28 @@
|
|||
require 'redmine'
|
||||
|
||||
Redmine::Plugin.register :redmine_delete_project do
|
||||
name 'Redmine Delete Project plugin'
|
||||
author 'Anthony Paul'
|
||||
description 'Adds an ACL to allow project deletion by non-admin users'
|
||||
version '0.0.4'
|
||||
|
||||
project_module :delete_project do
|
||||
permission :delete_project, {:delete_project => [:index, :submit]}
|
||||
end
|
||||
menu :project_menu, :delete_project, { :controller => 'delete_project', :action => 'index' },
|
||||
:caption => :label_feature_name,
|
||||
:after => :activity,
|
||||
:param => :project_id
|
||||
|
||||
|
||||
# Configure options
|
||||
settings_defaults = {
|
||||
'destroy' => "no",
|
||||
'chmod' => "no",
|
||||
'repos_path' => "/var/svn",
|
||||
'status_number' => "1001"
|
||||
}
|
||||
settings :default => settings_defaults, :partial => 'settings/delete_project'
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
DROP PROCEDURE IF EXISTS update_project_enable_module;
|
||||
DELIMITER |
|
||||
CREATE PROCEDURE update_project_enable_module()
|
||||
BEGIN
|
||||
DECLARE c_project_id INT(11);
|
||||
|
||||
DECLARE curs_project_id CURSOR
|
||||
FOR SELECT id
|
||||
FROM projects
|
||||
WHERE id NOT IN (
|
||||
SELECT project_id
|
||||
FROM enabled_modules
|
||||
WHERE name LIKE 'delete_project' );
|
||||
|
||||
OPEN curs_project_id;
|
||||
|
||||
LOOP
|
||||
FETCH curs_project_id INTO c_project_id;
|
||||
-- SELECT GROUP_CONCAT(name) FROM enabled_modules WHERE project_id=c_project_id;
|
||||
INSERT INTO enabled_modules VALUES ( NULL, c_project_id, 'delete_project');
|
||||
END LOOP;
|
||||
|
||||
CLOSE curs_project_id;
|
||||
END|
|
||||
DELIMITER ;
|
|
@ -0,0 +1,8 @@
|
|||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class DeleteProjectControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
# Load the normal Rails helper
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper')
|
||||
|
||||
# Ensure that we are using the temporary fixture path
|
||||
Engines::Testing.set_fixture_path
|
Loading…
Reference in New Issue