diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-12-07 09:11:41 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-12-07 09:11:41 +0000 |
commit | 2c569be63b3275c311606e4afcfb8311e810401f (patch) | |
tree | cbad93902334c10575d3e6ad1cd1f8903fa8c6f4 /app/controllers/concerns | |
parent | 61bd5b2cdb19e78e5f3f5688dc6fc2668e8a5608 (diff) | |
download | gitlab-ce-2c569be63b3275c311606e4afcfb8311e810401f.tar.gz |
Resolve "Display member role per project"
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r-- | app/controllers/concerns/renders_member_access.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/controllers/concerns/renders_member_access.rb b/app/controllers/concerns/renders_member_access.rb new file mode 100644 index 00000000000..d640378c24d --- /dev/null +++ b/app/controllers/concerns/renders_member_access.rb @@ -0,0 +1,23 @@ +module RendersMemberAccess + def prepare_groups_for_rendering(groups) + preload_max_member_access_for_collection(Group, groups) + + groups + end + + def prepare_projects_for_rendering(projects) + preload_max_member_access_for_collection(Project, projects) + + projects + end + + private + + def preload_max_member_access_for_collection(klass, collection) + return if !current_user || collection.blank? + + method_name = "max_member_access_for_#{klass.name.underscore}_ids" + + current_user.public_send(method_name, collection.ids) # rubocop:disable GitlabSecurity/PublicSend + end +end |