From 2508183af9bf0bba7d0bdc882ac6e0f733b7d3ee Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Thu, 18 Jan 2018 16:15:44 +0100 Subject: [PATCH] seed project creator role --- config/locales/en.yml | 3 +++ lib/open_project/global_roles/engine.rb | 1 + .../global_roles/patches/role_seeder_patch.rb | 21 +++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 lib/open_project/global_roles/patches/role_seeder_patch.rb diff --git a/config/locales/en.yml b/config/locales/en.yml index 5b036d638a..24988c935f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -28,3 +28,6 @@ en: label_not_changeable: (not changeable) label_no_assignable_role: No global role available for assignment label_global: Global + + seeders: + default_role_project_creator: 'Project creator' diff --git a/lib/open_project/global_roles/engine.rb b/lib/open_project/global_roles/engine.rb index 16d14a29b2..a22eae85fb 100644 --- a/lib/open_project/global_roles/engine.rb +++ b/lib/open_project/global_roles/engine.rb @@ -32,6 +32,7 @@ module OpenProject::GlobalRoles assets %w(global_roles/global_roles.js) patches [:Principal, :Role, :User, :RolesController, :UsersController] + patch_with_namespace :BasicData, :RoleSeeder initializer 'patch helper' do require_relative 'patches/roles_helper_patch' diff --git a/lib/open_project/global_roles/patches/role_seeder_patch.rb b/lib/open_project/global_roles/patches/role_seeder_patch.rb new file mode 100644 index 0000000000..473b6abe3e --- /dev/null +++ b/lib/open_project/global_roles/patches/role_seeder_patch.rb @@ -0,0 +1,21 @@ +module OpenProject::GlobalRoles::Patches + module RoleSeederPatch + def self.included(base) + base.prepend InstanceMethods + end + + module InstanceMethods + def roles + super + [project_creator] + end + + def project_creator + { name: I18n.t(:'seeders.default_role_project_creator'), + position: 6, + permissions: [:add_project], + type: 'GlobalRole' + } + end + end + end +end