Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kumanyaev <me@zzet.org>2013-01-20 15:25:16 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-01-25 00:31:24 +0400
commit9804b7df68a0ba4a1b144bc652351ad77a38fc3f (patch)
tree788c521aa4192dc95af8c063f33f3edd90174131 /app/controllers
parent9d318db48f4d76b8493aefa80e7b29c2ea3cc1cf (diff)
Move admin team members management to own controller
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/admin/teams/application_controller.rb12
-rw-r--r--app/controllers/admin/teams/members_controller.rb35
2 files changed, 47 insertions, 0 deletions
diff --git a/app/controllers/admin/teams/application_controller.rb b/app/controllers/admin/teams/application_controller.rb
new file mode 100644
index 00000000000..a2920b626b5
--- /dev/null
+++ b/app/controllers/admin/teams/application_controller.rb
@@ -0,0 +1,12 @@
+# Provides a base class for Admin controllers to subclass
+#
+# Automatically sets the layout and ensures an administrator is logged in
+class Admin::Teams::ApplicationController < Admin::ApplicationController
+ before_filter :user_team
+
+ private
+
+ def user_team
+ @team = UserTeam.find_by_path(params[:team_id])
+ end
+end
diff --git a/app/controllers/admin/teams/members_controller.rb b/app/controllers/admin/teams/members_controller.rb
new file mode 100644
index 00000000000..4037bff510e
--- /dev/null
+++ b/app/controllers/admin/teams/members_controller.rb
@@ -0,0 +1,35 @@
+class Admin::Teams::MembersController < Admin::Teams::ApplicationController
+ def new
+ @users = User.active
+ @users = @users.not_in_team(@team) if @team.members.any?
+ @users = UserDecorator.decorate @users
+ end
+
+ def create
+ unless params[:user_ids].blank?
+ user_ids = params[:user_ids]
+ access = params[:default_project_access]
+ is_admin = params[:group_admin]
+ @team.add_members(user_ids, access, is_admin)
+ end
+
+ redirect_to admin_team_path(@team), notice: 'Members was successfully added.'
+ end
+
+ def edit
+ @member = @team.members.find(params[:id])
+ end
+
+ def update
+ @member = @team.members.find(params[:id])
+ options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]}
+ if @team.update_membership(@member, options)
+ redirect_to admin_team_path(@team), notice: 'Membership was successfully updated.'
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ end
+end