diff options
author | Valery Sizov <valery@gitlab.com> | 2016-10-28 13:55:33 +0300 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2016-11-01 10:17:04 +0200 |
commit | 921677782f09d7baf4b6655570d4efc16ab46779 (patch) | |
tree | aa2b8435b8b4c6ada18cb92146ccec3b8051fb8e /app/controllers | |
parent | a60cc42b262cb63ce5d2284f1f3f41d6521daa14 (diff) | |
download | gitlab-ce-921677782f09d7baf4b6655570d4efc16ab46779.tar.gz |
Implement CreateMembers service to make controller thinrefactor_group_members
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/project_members_controller.rb | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb index d08f490de18..699a56ae2f8 100644 --- a/app/controllers/projects/project_members_controller.rb +++ b/app/controllers/projects/project_members_controller.rb @@ -25,18 +25,15 @@ class Projects::ProjectMembersController < Projects::ApplicationController end def create - if params[:user_ids].blank? - return redirect_to(namespace_project_project_members_path(@project.namespace, @project), alert: 'No users or groups specified.') - end + status = Members::CreateService.new(@project, current_user, params).execute - @project.team.add_users( - params[:user_ids].split(','), - params[:access_level], - expires_at: params[:expires_at], - current_user: current_user - ) + redirect_url = namespace_project_project_members_path(@project.namespace, @project) - redirect_to namespace_project_project_members_path(@project.namespace, @project), notice: 'Users were successfully added.' + if status + redirect_to redirect_url, notice: 'Users were successfully added.' + else + redirect_to redirect_url, alert: 'No users or groups specified.' + end end def update |