gitlab-org--gitlab-foss/app/controllers/admin/groups_controller.rb
Dmitriy Zaporozhets 9a4c8f7e41
Improve admin group page performance
Add pagination for projects and members to /admin/groups/:group page

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-06-02 18:58:00 +03:00

59 lines
1.4 KiB
Ruby

class Admin::GroupsController < Admin::ApplicationController
before_filter :group, only: [:edit, :show, :update, :destroy, :project_update, :project_teams_update]
def index
@groups = Group.order('name ASC')
@groups = @groups.search(params[:name]) if params[:name].present?
@groups = @groups.page(params[:page]).per(20)
end
def show
@members = @group.members.order("group_access DESC").page(params[:members_page]).per(30)
@projects = @group.projects.page(params[:projects_page]).per(30)
end
def new
@group = Group.new
end
def edit
end
def create
@group = Group.new(params[:group])
@group.path = @group.name.dup.parameterize if @group.name
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(params[:group])
redirect_to [:admin, @group], notice: 'Group was successfully updated.'
else
render "edit"
end
end
def project_teams_update
@group.add_users(params[:user_ids].split(','), params[:group_access])
redirect_to [:admin, @group], notice: 'Users were successfully added.'
end
def destroy
@group.destroy
redirect_to admin_groups_path, notice: 'Group was successfully deleted.'
end
private
def group
@group = Group.find_by(path: params[:id])
end
end