2013-01-20 12:25:16 +01:00
|
|
|
class Admin::Teams::MembersController < Admin::Teams::ApplicationController
|
|
|
|
def new
|
2013-01-24 19:31:28 +01:00
|
|
|
@users = User.potential_team_members(user_team)
|
2013-03-01 14:24:59 +01:00
|
|
|
@users = UserDecorator.decorate_collection @users
|
2013-01-20 12:25:16 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
unless params[:user_ids].blank?
|
|
|
|
user_ids = params[:user_ids]
|
|
|
|
access = params[:default_project_access]
|
|
|
|
is_admin = params[:group_admin]
|
2013-01-22 23:20:27 +01:00
|
|
|
user_team.add_members(user_ids, access, is_admin)
|
2013-01-20 12:25:16 +01:00
|
|
|
end
|
|
|
|
|
2013-01-22 23:20:27 +01:00
|
|
|
redirect_to admin_team_path(user_team), notice: 'Members was successfully added into Team of users.'
|
2013-01-20 12:25:16 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2013-01-22 18:29:19 +01:00
|
|
|
team_member
|
2013-01-20 12:25:16 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]}
|
2013-01-22 23:20:27 +01:00
|
|
|
if user_team.update_membership(team_member, options)
|
|
|
|
redirect_to admin_team_path(user_team), notice: "Membership for #{team_member.name} was successfully updated in Team of users."
|
2013-01-20 12:25:16 +01:00
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2013-01-23 20:39:47 +01:00
|
|
|
user_team.remove_member(team_member)
|
|
|
|
redirect_to admin_team_path(user_team), notice: "Member #{team_member.name} was successfully removed from Team of users."
|
2013-01-20 22:04:53 +01:00
|
|
|
end
|
|
|
|
|
2013-01-22 18:29:19 +01:00
|
|
|
protected
|
2013-01-20 22:04:53 +01:00
|
|
|
|
|
|
|
def team_member
|
2013-01-25 19:33:49 +01:00
|
|
|
@member ||= user_team.members.find_by_username(params[:id])
|
2013-01-20 12:25:16 +01:00
|
|
|
end
|
|
|
|
end
|