openproject-ensure_project_hierarchy 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +35 -0
- data/app/views/settings/_openproject_ensure_project_hierarchy.html.erb +10 -0
- data/config/locales/de.yml +8 -0
- data/config/locales/en.yml +8 -0
- data/lib/open_project/ensure_project_hierarchy.rb +5 -0
- data/lib/open_project/ensure_project_hierarchy/engine.rb +24 -0
- data/lib/open_project/ensure_project_hierarchy/patches.rb +2 -0
- data/lib/open_project/ensure_project_hierarchy/patches/project_patch.rb +36 -0
- data/lib/open_project/ensure_project_hierarchy/patches/projects_controller_patch.rb +36 -0
- data/lib/open_project/ensure_project_hierarchy/version.rb +5 -0
- data/lib/openproject-ensure_project_hierarchy.rb +1 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c161be0488b95656f7e66701a9b044b4b22b7966
|
4
|
+
data.tar.gz: 909858bb807edc78dc8972e3fa8b31f0faf4e2d1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 15cb9043cf21680b755ff014488aac5d892de3643804eb67b1c67b1ae8107e8c4ea9c80d5bf46d5d478ba75f9af65ff4d4a13c967b9b1944971e11016d5b0393
|
7
|
+
data.tar.gz: 5cde86fab68912c5899aaf86838a8a4f0e5d267346bc44f2e6ae8b7cbfdc86228540e201ea3450457aa8a202a6b0b54b398d0b9e06649be0d3891d95abb23757
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# OpenProject Ensure Project Hierarchy Plugin
|
2
|
+
|
3
|
+
This plugin ensures subproject identifiers are prefixed with their parent
|
4
|
+
project's identifier.
|
5
|
+
|
6
|
+
## Notes
|
7
|
+
|
8
|
+
* Admins are allowed to set any identifier regardless of the parent project.
|
9
|
+
* You cannot update the identifier of a project without changing the parent project to a matching value.
|
10
|
+
|
11
|
+
## Requirements
|
12
|
+
|
13
|
+
* OpenProject Version >= 3.0
|
14
|
+
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Create a file `Gemfile.plugins` in your OpenProject installation with the following content:
|
19
|
+
|
20
|
+
gem "openproject-plugins", :git => "https://github.com/opf/openproject-plugins.git", :branch => "stable"
|
21
|
+
gem "openproject-ensure_project_hierarchy", :git => "https://github.com/oliverguenther/openproject-ensure_project_hierarchy.git", :branch => "stable"
|
22
|
+
|
23
|
+
|
24
|
+
Please see the [OpenProject plugin overview](https://www.openproject.org/projects/openproject/wiki/OpenProject_Plug-Ins)
|
25
|
+
for more details.
|
26
|
+
|
27
|
+
## License
|
28
|
+
|
29
|
+
Copyright (c) 2014 Oliver Günther (mail@oliverguenther.de)
|
30
|
+
|
31
|
+
This plugin is forked from the [ChiliProject Ensure Project Hierarchy Plugin](https://github.com/thegcat/chiliproject_ensure_project_hierarchy) by Felix Schäfer.
|
32
|
+
|
33
|
+
Copyright (c) 2011 Felix Schäfer
|
34
|
+
|
35
|
+
This plugin is licensed under the MIT license. See COPYING for details.
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<h3><%= l(:separator) %></h3>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<label><%= l(:separator) %></label>
|
5
|
+
<%= text_field_tag("settings[separator]",
|
6
|
+
Setting.plugin_openproject_ensure_project_hierarchy[:separator], :size => 10)
|
7
|
+
%>
|
8
|
+
<br />
|
9
|
+
<em><%= t(:separator_desc, default_separator: Setting.plugin_openproject_ensure_project_hierarchy[:separator]) %></em>
|
10
|
+
</p>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# German strings go here for Rails i18n
|
2
|
+
de:
|
3
|
+
activerecord:
|
4
|
+
errors:
|
5
|
+
messages:
|
6
|
+
prefix_invalid: "muss den Präfix \"%{prefix}\" haben"
|
7
|
+
separator: Trennzeichen
|
8
|
+
separator_desc: "Das Trennzeichen zwischen Nutzername und Projektname. Standard: \'%{default_separator}\'"
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# English strings go here for Rails i18n
|
2
|
+
en:
|
3
|
+
activerecord:
|
4
|
+
errors:
|
5
|
+
messages:
|
6
|
+
prefix_invalid: "must start with \"%{prefix}\""
|
7
|
+
separator: Separator
|
8
|
+
separator_desc: "The separator between username and the given project name. Defaults to \'%{default_separator}\'"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module OpenProject::EnsureProjectHierarchy
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
engine_name :openproject_ensure_project_hierarchy
|
4
|
+
|
5
|
+
|
6
|
+
def self.settings
|
7
|
+
{ :partial => 'settings/openproject_ensure_project_hierarchy',
|
8
|
+
:default => {
|
9
|
+
:separator => '-',
|
10
|
+
}
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
include OpenProject::Plugins::ActsAsOpEngine
|
15
|
+
|
16
|
+
register 'openproject-ensure_project_hierarchy',
|
17
|
+
:author_url => 'https://github.com/oliverguenther/openproject-ensure_project_hierarchy',
|
18
|
+
:requires_openproject => '>= 3.0.0',
|
19
|
+
:settings => settings
|
20
|
+
|
21
|
+
patches [ :Project, :ProjectsController ]
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module OpenProject::EnsureProjectHierarchy
|
2
|
+
module Patches
|
3
|
+
module ProjectPatch
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
unloadable
|
8
|
+
|
9
|
+
include InstanceMethods
|
10
|
+
|
11
|
+
validate :identifier_hierarchy_correctness
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
module InstanceMethods
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def identifier_hierarchy_correctness
|
21
|
+
return true if User.current.admin?
|
22
|
+
|
23
|
+
if parent && !identifier.start_with?([parent.identifier,
|
24
|
+
Setting.plugin_openproject_ensure_project_hierarchy[:separator]].join)
|
25
|
+
|
26
|
+
errors.add :identifier, :prefix_invalid, :prefix => "#{parent.identifier}-"
|
27
|
+
return false
|
28
|
+
end
|
29
|
+
true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
Project.send(:include, OpenProject::EnsureProjectHierarchy::Patches::ProjectPatch)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module OpenProject::EnsureProjectHierarchy
|
2
|
+
module Patches
|
3
|
+
module ProjectsControllerPatch
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
unloadable
|
8
|
+
|
9
|
+
include InstanceMethods
|
10
|
+
|
11
|
+
alias_method_chain :new, :default_identifier_for_new_subprojects
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
module InstanceMethods
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def new_with_default_identifier_for_new_subprojects
|
21
|
+
new_without_default_identifier_for_new_subprojects
|
22
|
+
if params[:parent_id]
|
23
|
+
|
24
|
+
parent_project = Project.find params[:parent_id]
|
25
|
+
@project.identifier = [parent_project.identifier,
|
26
|
+
Setting.plugin_openproject_ensure_project_hierarchy[:separator]].join
|
27
|
+
|
28
|
+
Rails.logger.info("[EnsureProjectHierarchy] Overriding project identifier to #{@project.identifier}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
ProjectsController.send(:include, OpenProject::EnsureProjectHierarchy::Patches::ProjectsControllerPatch)
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'open_project/ensure_project_hierarchy'
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openproject-ensure_project_hierarchy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oliver Günther
|
8
|
+
- Felix Schäfer
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '3.2'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '3.2'
|
28
|
+
description: This plugin ensures subproject identifiers are prefixes with their parent
|
29
|
+
project's identifier.
|
30
|
+
email: mail@oliverguenther.de
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- README.md
|
36
|
+
- app/views/settings/_openproject_ensure_project_hierarchy.html.erb
|
37
|
+
- config/locales/de.yml
|
38
|
+
- config/locales/en.yml
|
39
|
+
- lib/open_project/ensure_project_hierarchy.rb
|
40
|
+
- lib/open_project/ensure_project_hierarchy/engine.rb
|
41
|
+
- lib/open_project/ensure_project_hierarchy/patches.rb
|
42
|
+
- lib/open_project/ensure_project_hierarchy/patches/project_patch.rb
|
43
|
+
- lib/open_project/ensure_project_hierarchy/patches/projects_controller_patch.rb
|
44
|
+
- lib/open_project/ensure_project_hierarchy/version.rb
|
45
|
+
- lib/openproject-ensure_project_hierarchy.rb
|
46
|
+
homepage: https://www.github.com/oliverguenther/openproject-ensure_project_hierarchy
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
metadata: {}
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 2.2.2
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: Ensure Project Hierarchy Plugin
|
70
|
+
test_files: []
|
71
|
+
has_rdoc:
|