debian-mirror-gitlab/app/controllers/admin/groups_controller.rb

65 lines
1.6 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
class Admin::GroupsController < Admin::ApplicationController
2015-09-11 14:41:01 +05:30
before_action :group, only: [:edit, :show, :update, :destroy, :project_update, :members_update]
2014-09-02 18:07:02 +05:30
def index
2015-04-26 12:48:37 +05:30
@groups = Group.all
@groups = @groups.sort(@sort = params[:sort])
2014-09-02 18:07:02 +05:30
@groups = @groups.search(params[:name]) if params[:name].present?
2016-06-02 11:05:42 +05:30
@groups = @groups.page(params[:page])
2014-09-02 18:07:02 +05:30
end
def show
2016-06-02 11:05:42 +05:30
@members = @group.members.order("access_level DESC").page(params[:members_page])
@projects = @group.projects.page(params[:projects_page])
2014-09-02 18:07:02 +05:30
end
def new
@group = Group.new
end
def edit
end
def create
@group = Group.new(group_params)
2015-04-26 12:48:37 +05:30
@group.name = @group.path.dup unless @group.name
2014-09-02 18:07:02 +05:30
if @group.save
@group.add_owner(current_user)
redirect_to [:admin, @group], notice: 'Group was successfully created.'
else
render "new"
end
end
def update
if @group.update_attributes(group_params)
redirect_to [:admin, @group], notice: 'Group was successfully updated.'
else
render "edit"
end
end
2015-04-26 12:48:37 +05:30
def members_update
@group.add_users(params[:user_ids].split(','), params[:access_level], current_user)
2014-09-02 18:07:02 +05:30
redirect_to [:admin, @group], notice: 'Users were successfully added.'
end
def destroy
2015-09-11 14:41:01 +05:30
DestroyGroupService.new(@group, current_user).execute
2014-09-02 18:07:02 +05:30
redirect_to admin_groups_path, notice: 'Group was successfully deleted.'
end
private
def group
2016-06-02 11:05:42 +05:30
@group ||= Group.find_by(path: params[:id])
2014-09-02 18:07:02 +05:30
end
def group_params
2016-06-02 11:05:42 +05:30
params.require(:group).permit(:name, :description, :path, :avatar, :visibility_level)
2014-09-02 18:07:02 +05:30
end
end