Commit c8227889 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Refactor groups/projects members controller

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 036fac06
...@@ -21,7 +21,7 @@ class Groups::GroupMembersController < Groups::ApplicationController ...@@ -21,7 +21,7 @@ class Groups::GroupMembersController < Groups::ApplicationController
end end
def create def create
if params[:user_ids].empty? if params[:user_ids].blank?
return redirect_to group_group_members_path(@group), alert: 'No users specified.' return redirect_to group_group_members_path(@group), alert: 'No users specified.'
end end
......
...@@ -25,16 +25,18 @@ class Projects::ProjectMembersController < Projects::ApplicationController ...@@ -25,16 +25,18 @@ class Projects::ProjectMembersController < Projects::ApplicationController
end end
def create def create
if params[:user_ids].empty? if params[:user_ids].blank? && params[:group_ids].blank?
return redirect_to namespace_project_project_members_path(@project.namespace, @project), alert: 'No users specified.' return redirect_to namespace_project_project_members_path(@project.namespace, @project), alert: 'No users or groups specified.'
end end
if params[:user_ids].present?
@project.team.add_users( @project.team.add_users(
params[:user_ids].split(','), params[:user_ids].split(','),
params[:access_level], params[:access_level],
expires_at: params[:expires_at], expires_at: params[:expires_at],
current_user: current_user current_user: current_user
) )
end
redirect_to namespace_project_project_members_path(@project.namespace, @project), notice: 'Users were successfully added.' redirect_to namespace_project_project_members_path(@project.namespace, @project), notice: 'Users were successfully added.'
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