2013-01-19 18:47:08 +01:00
|
|
|
class Teams::MembersController < Teams::ApplicationController
|
2013-01-22 23:20:27 +01:00
|
|
|
|
2013-01-22 21:58:44 +01:00
|
|
|
skip_before_filter :authorize_manage_user_team!, only: [:index]
|
2013-01-19 18:47:08 +01:00
|
|
|
|
|
|
|
def index
|
2013-01-22 23:20:27 +01:00
|
|
|
@members = user_team.members
|
2013-01-19 18:47:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
2013-01-22 23:20:27 +01:00
|
|
|
@users = User.active
|
|
|
|
@users = @users.not_in_team(user_team) if user_team.members.any?
|
|
|
|
@users = UserDecorator.decorate @users
|
2013-01-19 18:47:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2013-01-22 23:20:27 +01:00
|
|
|
unless params[:user_ids].blank?
|
|
|
|
user_ids = params[:user_ids]
|
|
|
|
access = params[:default_project_access]
|
|
|
|
is_admin = params[:group_admin]
|
|
|
|
user_team.add_members(user_ids, access, is_admin)
|
|
|
|
end
|
2013-01-19 18:47:08 +01:00
|
|
|
|
2013-01-23 20:39:47 +01:00
|
|
|
redirect_to team_members_path(user_team), notice: 'Members was successfully added into Team of users.'
|
2013-01-22 23:20:27 +01:00
|
|
|
end
|
2013-01-19 18:47:08 +01:00
|
|
|
|
2013-01-22 23:20:27 +01:00
|
|
|
def edit
|
|
|
|
team_member
|
2013-01-19 18:47:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2013-01-22 23:20:27 +01:00
|
|
|
options = {default_projects_access: params[:default_project_access], group_admin: params[:group_admin]}
|
|
|
|
if user_team.update_membership(team_member, options)
|
2013-01-23 20:39:47 +01:00
|
|
|
redirect_to team_members_path(user_team), notice: "Membership for #{team_member.name} was successfully updated in Team of users."
|
2013-01-22 23:20:27 +01:00
|
|
|
else
|
|
|
|
render :edit
|
2013-01-19 18:47:08 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2013-01-23 20:39:47 +01:00
|
|
|
user_team.remove_member(team_member)
|
|
|
|
redirect_to team_path(user_team), notice: "Member #{team_member.name} was successfully removed from Team of users."
|
2013-01-19 18:47:08 +01:00
|
|
|
end
|
|
|
|
|
2013-01-22 23:20:27 +01:00
|
|
|
protected
|
2013-01-19 18:47:08 +01:00
|
|
|
|
2013-01-22 23:20:27 +01:00
|
|
|
def team_member
|
|
|
|
@member ||= user_team.members.find(params[:id])
|
2013-01-19 18:47:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|