Commit ff3caad4 authored by Douwe Maan's avatar Douwe Maan

Rename manage_group ability to admin_group for consistency with project.

parent ae6d0aaa
...@@ -13,7 +13,7 @@ class Groups::ApplicationController < ApplicationController ...@@ -13,7 +13,7 @@ class Groups::ApplicationController < ApplicationController
end end
def authorize_admin_group! def authorize_admin_group!
unless can?(current_user, :manage_group, group) unless can?(current_user, :admin_group, group)
return render_404 return render_404
end end
end end
......
...@@ -51,6 +51,6 @@ class Groups::MilestonesController < ApplicationController ...@@ -51,6 +51,6 @@ class Groups::MilestonesController < ApplicationController
end end
def authorize_group_milestone! def authorize_group_milestone!
return render_404 unless can?(current_user, :manage_group, group) return render_404 unless can?(current_user, :admin_group, group)
end end
end end
...@@ -198,11 +198,11 @@ class Ability ...@@ -198,11 +198,11 @@ class Ability
]) ])
end end
# Only group owner and administrators can manage group # Only group owner and administrators can admin group
if group.has_owner?(user) || user.admin? if group.has_owner?(user) || user.admin?
rules.push(*[ rules.push(*[
:manage_group, :admin_group,
:manage_namespace :admin_namespace
]) ])
end end
...@@ -212,11 +212,11 @@ class Ability ...@@ -212,11 +212,11 @@ class Ability
def namespace_abilities(user, namespace) def namespace_abilities(user, namespace)
rules = [] rules = []
# Only namespace owner and administrators can manage it # Only namespace owner and administrators can admin it
if namespace.owner == user || user.admin? if namespace.owner == user || user.admin?
rules.push(*[ rules.push(*[
:create_projects, :create_projects,
:manage_namespace :admin_namespace
]) ])
end end
...@@ -254,7 +254,7 @@ class Ability ...@@ -254,7 +254,7 @@ class Ability
rules = [] rules = []
target_user = subject.user target_user = subject.user
group = subject.group group = subject.group
can_manage = group_abilities(user, group).include?(:manage_group) can_manage = group_abilities(user, group).include?(:admin_group)
if can_manage && (user != target_user) if can_manage && (user != target_user)
rules << :modify_group_member rules << :modify_group_member
rules << :destroy_group_member rules << :destroy_group_member
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
- group = group_member.group - group = group_member.group
%li %li
.pull-right .pull-right
- if can?(current_user, :manage_group, group) - if can?(current_user, :admin_group, group)
= link_to edit_group_path(group), class: "btn-sm btn btn-grouped" do = link_to edit_group_path(group), class: "btn-sm btn btn-grouped" do
%i.fa.fa-cogs %i.fa.fa-cogs
Settings Settings
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
= search_field_tag :search, params[:search], { placeholder: 'Find existing member by name', class: 'form-control search-text-input input-mn-300' } = search_field_tag :search, params[:search], { placeholder: 'Find existing member by name', class: 'form-control search-text-input input-mn-300' }
= button_tag 'Search', class: 'btn' = button_tag 'Search', class: 'btn'
- if current_user && current_user.can?(:manage_group, @group) - if current_user && current_user.can?(:admin_group, @group)
.pull-right .pull-right
= button_tag class: 'btn btn-new js-toggle-button', type: 'button' do = button_tag class: 'btn btn-new js-toggle-button', type: 'button' do
Add members Add members
......
%li{class: "milestone milestone-#{milestone.closed? ? 'closed' : 'open'}", id: dom_id(milestone.milestones.first) } %li{class: "milestone milestone-#{milestone.closed? ? 'closed' : 'open'}", id: dom_id(milestone.milestones.first) }
.pull-right .pull-right
- if can?(current_user, :manage_group, @group) - if can?(current_user, :admin_group, @group)
- if milestone.closed? - if milestone.closed?
= link_to 'Reopen Milestone', group_milestone_path(@group, milestone.safe_title, title: milestone.title, milestone: {state_event: :activate }), method: :put, class: "btn btn-sm btn-grouped btn-reopen" = link_to 'Reopen Milestone', group_milestone_path(@group, milestone.safe_title, title: milestone.title, milestone: {state_event: :activate }), method: :put, class: "btn btn-sm btn-grouped btn-reopen"
- else - else
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
Open Open
Milestone #{@group_milestone.title} Milestone #{@group_milestone.title}
.pull-right .pull-right
- if can?(current_user, :manage_group, @group) - if can?(current_user, :admin_group, @group)
- if @group_milestone.active? - if @group_milestone.active?
= link_to 'Close Milestone', group_milestone_path(@group, @group_milestone.safe_title, title: @group_milestone.title, milestone: {state_event: :close }), method: :put, class: "btn btn-sm btn-close" = link_to 'Close Milestone', group_milestone_path(@group, @group_milestone.safe_title, title: @group_milestone.title, milestone: {state_event: :close }), method: :put, class: "btn btn-sm btn-close"
- else - else
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.panel-heading .panel-heading
%strong= @group.name %strong= @group.name
projects: projects:
- if can? current_user, :manage_group, @group - if can? current_user, :admin_group, @group
.panel-head-actions .panel-head-actions
= link_to new_project_path(namespace_id: @group.id), class: "btn btn-sm btn-success" do = link_to new_project_path(namespace_id: @group.id), class: "btn btn-sm btn-success" do
%i.fa.fa-plus %i.fa.fa-plus
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
%span %span
Members Members
- if can?(current_user, :manage_group, @group) - if can?(current_user, :admin_group, @group)
= nav_link(html_options: { class: "#{"active" if group_settings_page?} separate-item" }) do = nav_link(html_options: { class: "#{"active" if group_settings_page?} separate-item" }) do
= link_to edit_group_path(@group), title: 'Settings', class: "tab no-highlight" do = link_to edit_group_path(@group), title: 'Settings', class: "tab no-highlight" do
%i.fa.fa-cogs %i.fa.fa-cogs
......
...@@ -24,7 +24,7 @@ module API ...@@ -24,7 +24,7 @@ module API
# POST /groups/:id/members # POST /groups/:id/members
post ":id/members" do post ":id/members" do
group = find_group(params[:id]) group = find_group(params[:id])
authorize! :manage_group, group authorize! :admin_group, group
required_attributes! [:user_id, :access_level] required_attributes! [:user_id, :access_level]
unless validate_access_level?(params[:access_level]) unless validate_access_level?(params[:access_level])
...@@ -50,7 +50,7 @@ module API ...@@ -50,7 +50,7 @@ module API
# PUT /groups/:id/members/:user_id # PUT /groups/:id/members/:user_id
put ':id/members/:user_id' do put ':id/members/:user_id' do
group = find_group(params[:id]) group = find_group(params[:id])
authorize! :manage_group, group authorize! :admin_group, group
required_attributes! [:access_level] required_attributes! [:access_level]
group_member = group.group_members.find_by(user_id: params[:user_id]) group_member = group.group_members.find_by(user_id: params[:user_id])
...@@ -74,7 +74,7 @@ module API ...@@ -74,7 +74,7 @@ module API
# DELETE /groups/:id/members/:user_id # DELETE /groups/:id/members/:user_id
delete ":id/members/:user_id" do delete ":id/members/:user_id" do
group = find_group(params[:id]) group = find_group(params[:id])
authorize! :manage_group, group authorize! :admin_group, group
member = group.group_members.find_by(user_id: params[:user_id]) member = group.group_members.find_by(user_id: params[:user_id])
if member.nil? if member.nil?
......
...@@ -61,7 +61,7 @@ module API ...@@ -61,7 +61,7 @@ module API
# DELETE /groups/:id # DELETE /groups/:id
delete ":id" do delete ":id" do
group = find_group(params[:id]) group = find_group(params[:id])
authorize! :manage_group, group authorize! :admin_group, group
group.destroy group.destroy
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment