summaryrefslogtreecommitdiff
path: root/app/controllers/users_groups_controller.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-17 16:51:43 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-18 17:47:52 +0300
commite12c9ee2bc76026b146ea1b29fd0acc5ac696d34 (patch)
tree29f1d649c13f16cfdf80fc3b3f19cedc17a0deda /app/controllers/users_groups_controller.rb
parentc9fb7e39eb601d1b959ea89363bb877f7679b2bc (diff)
downloadgitlab-ce-e12c9ee2bc76026b146ea1b29fd0acc5ac696d34.tar.gz
Added UsersGroup scaffold. Simplify adding people to group
Diffstat (limited to 'app/controllers/users_groups_controller.rb')
-rw-r--r--app/controllers/users_groups_controller.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/app/controllers/users_groups_controller.rb b/app/controllers/users_groups_controller.rb
new file mode 100644
index 00000000000..ebc79d621a4
--- /dev/null
+++ b/app/controllers/users_groups_controller.rb
@@ -0,0 +1,40 @@
+class UsersGroupsController < ApplicationController
+ before_filter :group
+
+ # Authorize
+ before_filter :authorize_admin_group!
+
+ layout 'group'
+
+ def create
+ @group.add_users(params[:user_ids].split(','), params[:group_access])
+
+ redirect_to people_group_path(@group), notice: 'Users were successfully added.'
+ end
+
+ def update
+ # TODO: implement
+ end
+
+ def destroy
+ @users_group = @group.users_groups.find(params[:id])
+ @users_group.destroy
+
+ respond_to do |format|
+ format.html { redirect_to people_group_path(@group), notice: 'User was successfully removed from group.' }
+ format.js { render nothing: true }
+ end
+ end
+
+ protected
+
+ def group
+ @group ||= Group.find_by_path(params[:group_id])
+ end
+
+ def authorize_admin_group!
+ unless can?(current_user, :manage_group, group)
+ return render_404
+ end
+ end
+end