redmine_nonproject_modules 0.4.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/group_merge.rb +1 -4
- data/app/models/group_permission.rb +2 -3
- data/config/initializers/001_patches.rb +1 -1
- data/config/initializers/group_permissions.rb +2 -2
- data/init.rb +4 -4
- data/lib/redmine_nonproject_modules/menu_controller_entry.rb +69 -0
- data/lib/redmine_nonproject_modules/patches/controller_patch.rb +3 -1
- data/lib/redmine_nonproject_modules/patches/group_patch.rb +2 -2
- data/lib/redmine_nonproject_modules/patches/redmine/i18n_patch.rb +2 -2
- data/lib/redmine_nonproject_modules/patches/redmine/menu_manager/mapper.rb +20 -0
- data/lib/redmine_nonproject_modules/patches/redmine/menu_manager_patch.rb +16 -77
- data/lib/redmine_nonproject_modules/patches/redmine/plugin.rb +1 -1
- data/lib/redmine_nonproject_modules/patches/user_patch.rb +2 -2
- data/lib/redmine_nonproject_modules/version.rb +1 -1
- data/lib/tasks/redmine_nonproject_modules.rake +1 -1
- metadata +25 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f9433cc7007312e8ef5c011eee4ddb3b79974c6ccd8cd85e680208b6a0649e1
|
4
|
+
data.tar.gz: 1a41f84dd10c23981d902370e2c9807151ae1f57dde131ca96439a09c0ba56cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c85ec4ca425a83d840800b041d64b12aadb295be0520afdd4b5534e4ad98731cfe9cfe2a964f013b4da0b6497b67844f203ea79107216afc47b6942c9daefe97
|
7
|
+
data.tar.gz: 11dc39bc9fdef85a9358697f58345bc61efb1aa1715319044b2752b4314d114394f0241a486cd94c7ba77c9c21b2559609543ef40bcd63629a8467d39f3d3c38
|
data/app/models/group_merge.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'eac_rails_utils/models/tableless'
|
4
4
|
|
5
|
-
class GroupMerge <
|
5
|
+
class GroupMerge < EacRailsUtils::Models::Tableless
|
6
6
|
ONLY_ON_TARGET = :only_on_target
|
7
7
|
ONLY_ON_SOURCE = :only_on_source
|
8
8
|
ON_BOTH = :on_both
|
@@ -12,9 +12,6 @@ class GroupMerge < ::EacRailsUtils::Models::Tableless
|
|
12
12
|
belongs_to :source, class_name: 'Group'
|
13
13
|
belongs_to :target, class_name: 'Group'
|
14
14
|
|
15
|
-
validates :source, presence: true
|
16
|
-
validates :target, presence: true
|
17
|
-
|
18
15
|
def to_merge_elements
|
19
16
|
(target_elements + source_elements).uniq.map do |x|
|
20
17
|
[x[0], element_on_status(x)]
|
@@ -5,8 +5,7 @@ require 'eac_ruby_utils/simple_cache'
|
|
5
5
|
class GroupPermission < ActiveRecord::Base
|
6
6
|
belongs_to :group
|
7
7
|
|
8
|
-
validates :
|
9
|
-
validates :permission, presence: true, uniqueness: { scope: [:group],
|
8
|
+
validates :permission, presence: true, uniqueness: { scope: [:group], # rubocop:disable Rails/UniqueValidationWithoutIndex
|
10
9
|
case_sensitive: false }
|
11
10
|
|
12
11
|
def permission=(value)
|
@@ -27,7 +26,7 @@ class GroupPermission < ActiveRecord::Base
|
|
27
26
|
permission(key).description
|
28
27
|
end
|
29
28
|
|
30
|
-
def permission?(permission, user = false)
|
29
|
+
def permission?(permission, user = false) # rubocop:disable Style/OptionalBooleanParameter
|
31
30
|
return permission_by_hash?(permission, user) if permission.is_a?(Hash)
|
32
31
|
|
33
32
|
permission(permission).user_has?(user || User.current)
|
@@ -3,6 +3,6 @@
|
|
3
3
|
require 'redmine_nonproject_modules/patches/controller_patch'
|
4
4
|
require 'redmine_nonproject_modules/patches/group_patch'
|
5
5
|
require 'redmine_nonproject_modules/patches/redmine/i18n_patch'
|
6
|
-
require 'redmine_nonproject_modules/patches/redmine/
|
6
|
+
require 'redmine_nonproject_modules/patches/redmine/menu_manager/mapper'
|
7
7
|
require 'redmine_nonproject_modules/patches/redmine/plugin'
|
8
8
|
require 'redmine_nonproject_modules/patches/user_patch'
|
data/init.rb
CHANGED
@@ -8,9 +8,9 @@ require 'redmine_nonproject_modules/version'
|
|
8
8
|
|
9
9
|
Redmine::Plugin.register :redmine_nonproject_modules do
|
10
10
|
name 'Redmine non-project modules'
|
11
|
-
author
|
12
|
-
description
|
13
|
-
version
|
14
|
-
url
|
11
|
+
author RedmineNonprojectModules::AUTHOR
|
12
|
+
description RedmineNonprojectModules::SUMMARY
|
13
|
+
version RedmineNonprojectModules::VERSION
|
14
|
+
url RedmineNonprojectModules::HOMEPAGE
|
15
15
|
author_url 'https://github.com/eduardobogoni'
|
16
16
|
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
|
5
|
+
module RedmineNonprojectModules
|
6
|
+
class MenuControllerEntry
|
7
|
+
# @!method initialize(controller, options = {})
|
8
|
+
# @param controller [String]
|
9
|
+
# @param options [Hash]
|
10
|
+
common_constructor :controller, :options, default: [{}] do
|
11
|
+
self.controller = controller.to_s
|
12
|
+
self.options = options.with_indifferent_access
|
13
|
+
end
|
14
|
+
|
15
|
+
def build
|
16
|
+
[build_name, build_url, build_options]
|
17
|
+
end
|
18
|
+
|
19
|
+
def permissions
|
20
|
+
parse_permissions(permissions_const)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def build_name
|
26
|
+
r = controller
|
27
|
+
r = "#{r}_#{action}" unless action == 'index'
|
28
|
+
r.to_sym
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_url
|
32
|
+
{ controller: controller, action: action, id: id }
|
33
|
+
end
|
34
|
+
|
35
|
+
def build_options
|
36
|
+
{
|
37
|
+
caption: build_caption,
|
38
|
+
if: proc { GroupPermission.permission?(permissions_const) }
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def build_caption
|
43
|
+
:"label_#{build_name}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def controller_class
|
47
|
+
Object.const_get("#{controller.camelize}Controller")
|
48
|
+
end
|
49
|
+
|
50
|
+
def action
|
51
|
+
options[:action] || 'index'
|
52
|
+
end
|
53
|
+
|
54
|
+
def id
|
55
|
+
options[:id]
|
56
|
+
end
|
57
|
+
|
58
|
+
def permissions_const
|
59
|
+
controller_class.const_get('PERMISSIONS')
|
60
|
+
end
|
61
|
+
|
62
|
+
def parse_permissions(permission)
|
63
|
+
return parse_permissions(permission.values) if permission.is_a?(Hash)
|
64
|
+
return permission.flat_map { |v| parse_permissions(v) } if permission.is_a?(Enumerable)
|
65
|
+
|
66
|
+
[permission.to_s]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -28,5 +28,7 @@ end
|
|
28
28
|
unless ActionController::Base.included_modules.include?(
|
29
29
|
RedmineNonprojectModules::Patches::ControllerPatch
|
30
30
|
)
|
31
|
-
|
31
|
+
ActiveSupport.on_load(:action_controller) do
|
32
|
+
include RedmineNonprojectModules::Patches::ControllerPatch
|
33
|
+
end
|
32
34
|
end
|
@@ -22,6 +22,6 @@ module RedmineNonprojectModules
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
unless
|
26
|
-
|
25
|
+
unless Group.included_modules.include?(RedmineNonprojectModules::Patches::GroupPatch)
|
26
|
+
Group.include RedmineNonprojectModules::Patches::GroupPatch
|
27
27
|
end
|
@@ -23,7 +23,7 @@ module RedmineNonprojectModules
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
x =
|
27
|
-
y =
|
26
|
+
x = Redmine::I18n
|
27
|
+
y = RedmineNonprojectModules::Patches::Redmine::I18nPatch
|
28
28
|
|
29
29
|
x.send(:include, y) unless x.included_modules.include?(y)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RedmineNonprojectModules
|
4
|
+
module Patches
|
5
|
+
module Redmine
|
6
|
+
module MenuManagerMapperPatch
|
7
|
+
def push_controller(*args)
|
8
|
+
e = ::RedmineNonprojectModules::MenuControllerEntry.new(*args)
|
9
|
+
push(*e.build)
|
10
|
+
e.permissions.each do |p|
|
11
|
+
::GroupPermission.add_permission(p)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Redmine::MenuManager::Mapper
|
20
|
+
.include(RedmineNonprojectModules::Patches::Redmine::MenuManagerMapperPatch)
|
@@ -3,92 +3,31 @@
|
|
3
3
|
module RedmineNonprojectModules
|
4
4
|
module Patches
|
5
5
|
module Redmine
|
6
|
-
module
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
module InstanceMethods
|
13
|
-
def push_controller(*args)
|
14
|
-
e = ControllerEntry.new(*args)
|
15
|
-
push(*e.build)
|
16
|
-
e.permissions.each do |p|
|
17
|
-
::GroupPermission.add_permission(p)
|
6
|
+
module MenuManager
|
7
|
+
module Mapper
|
8
|
+
def self.included(base)
|
9
|
+
base.send(:include, InstanceMethods)
|
18
10
|
end
|
19
11
|
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class ControllerEntry
|
23
|
-
def initialize(controller, options = {})
|
24
|
-
@controller = controller.to_s
|
25
|
-
@options = options.with_indifferent_access
|
26
|
-
end
|
27
|
-
|
28
|
-
def build
|
29
|
-
[build_name, build_url, build_options]
|
30
|
-
end
|
31
|
-
|
32
|
-
def permissions
|
33
|
-
parse_permissions(permissions_const)
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
attr_reader :controller, :options
|
39
|
-
|
40
|
-
def build_name
|
41
|
-
r = controller
|
42
|
-
r = "#{r}_#{action}" unless action == 'index'
|
43
|
-
r.to_sym
|
44
|
-
end
|
45
|
-
|
46
|
-
def build_url
|
47
|
-
{ controller: controller, action: action, id: id }
|
48
|
-
end
|
49
|
-
|
50
|
-
def build_options
|
51
|
-
{
|
52
|
-
caption: build_caption,
|
53
|
-
if: proc { GroupPermission.permission?(permissions_const) }
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
def build_caption
|
58
|
-
"label_#{build_name}".to_sym
|
59
|
-
end
|
60
|
-
|
61
|
-
def controller_class
|
62
|
-
Object.const_get("#{controller.camelize}Controller")
|
63
|
-
end
|
64
12
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
def permissions_const
|
74
|
-
controller_class.const_get('PERMISSIONS')
|
75
|
-
end
|
76
|
-
|
77
|
-
def parse_permissions(permission)
|
78
|
-
return parse_permissions(permission.values) if permission.is_a?(Hash)
|
79
|
-
return permission.flat_map { |v| parse_permissions(v) } if permission.is_a?(Enumerable)
|
80
|
-
|
81
|
-
[permission.to_s]
|
13
|
+
module InstanceMethods
|
14
|
+
def push_controller(*args)
|
15
|
+
e = ::RedmineNonprojectModules::MenuControllerEntry.new(*args)
|
16
|
+
push(*e.build)
|
17
|
+
e.permissions.each do |p|
|
18
|
+
::GroupPermission.add_permission(p)
|
19
|
+
end
|
20
|
+
end
|
82
21
|
end
|
83
22
|
end
|
84
23
|
end
|
85
24
|
end
|
86
25
|
end
|
87
26
|
|
88
|
-
unless
|
89
|
-
|
27
|
+
unless Redmine::MenuManager::Mapper.included_modules.include?(
|
28
|
+
RedmineNonprojectModules::Patches::Redmine::MenuManager::Mapper
|
90
29
|
)
|
91
|
-
|
92
|
-
|
30
|
+
Redmine::MenuManager::Mapper.include(
|
31
|
+
RedmineNonprojectModules::Patches::Redmine::MenuManager::Mapper
|
93
32
|
)
|
94
33
|
end
|
@@ -16,6 +16,6 @@ module RedmineNonprojectModules
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
unless
|
20
|
-
|
19
|
+
unless User.included_modules.include?(RedmineNonprojectModules::Patches::UserPatch)
|
20
|
+
User.include RedmineNonprojectModules::Patches::UserPatch
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_nonproject_modules
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- 0.
|
7
|
+
- 0.5.1
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eac_active_scaffold
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '0.5'
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.5.
|
22
|
+
version: 0.5.3
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '0.5'
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.5.
|
32
|
+
version: 0.5.3
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: eac_rails_utils
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,25 +56,22 @@ dependencies:
|
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '0.
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 0.119.2
|
59
|
+
version: '0.121'
|
63
60
|
type: :runtime
|
64
61
|
prerelease: false
|
65
62
|
version_requirements: !ruby/object:Gem::Requirement
|
66
63
|
requirements:
|
67
64
|
- - "~>"
|
68
65
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0.
|
70
|
-
- - ">="
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: 0.119.2
|
66
|
+
version: '0.121'
|
73
67
|
- !ruby/object:Gem::Dependency
|
74
68
|
name: i18n-recursive-lookup
|
75
69
|
requirement: !ruby/object:Gem::Requirement
|
76
70
|
requirements:
|
77
71
|
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0.0'
|
74
|
+
- - ">="
|
78
75
|
- !ruby/object:Gem::Version
|
79
76
|
version: 0.0.5
|
80
77
|
type: :runtime
|
@@ -82,6 +79,9 @@ dependencies:
|
|
82
79
|
version_requirements: !ruby/object:Gem::Requirement
|
83
80
|
requirements:
|
84
81
|
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.0'
|
84
|
+
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: 0.0.5
|
87
87
|
- !ruby/object:Gem::Dependency
|
@@ -99,19 +99,25 @@ dependencies:
|
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: '4.6'
|
101
101
|
- !ruby/object:Gem::Dependency
|
102
|
-
name:
|
102
|
+
name: eac_rails_gem_support
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
105
|
- - "~>"
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version: 0.
|
107
|
+
version: '0.9'
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.9.2
|
108
111
|
type: :development
|
109
112
|
prerelease: false
|
110
113
|
version_requirements: !ruby/object:Gem::Requirement
|
111
114
|
requirements:
|
112
115
|
- - "~>"
|
113
116
|
- !ruby/object:Gem::Version
|
114
|
-
version: 0.
|
117
|
+
version: '0.9'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 0.9.2
|
115
121
|
description:
|
116
122
|
email:
|
117
123
|
executables: []
|
@@ -147,9 +153,11 @@ files:
|
|
147
153
|
- init.rb
|
148
154
|
- lib/redmine_nonproject_modules.rb
|
149
155
|
- lib/redmine_nonproject_modules/dispatcher_finder.rb
|
156
|
+
- lib/redmine_nonproject_modules/menu_controller_entry.rb
|
150
157
|
- lib/redmine_nonproject_modules/patches/controller_patch.rb
|
151
158
|
- lib/redmine_nonproject_modules/patches/group_patch.rb
|
152
159
|
- lib/redmine_nonproject_modules/patches/redmine/i18n_patch.rb
|
160
|
+
- lib/redmine_nonproject_modules/patches/redmine/menu_manager/mapper.rb
|
153
161
|
- lib/redmine_nonproject_modules/patches/redmine/menu_manager_patch.rb
|
154
162
|
- lib/redmine_nonproject_modules/patches/redmine/plugin.rb
|
155
163
|
- lib/redmine_nonproject_modules/patches/user_patch.rb
|
@@ -166,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
166
174
|
requirements:
|
167
175
|
- - ">="
|
168
176
|
- !ruby/object:Gem::Version
|
169
|
-
version:
|
177
|
+
version: 2.7.0
|
170
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
179
|
requirements:
|
172
180
|
- - ">="
|