2012-09-27 20:59:42 +02:00
|
|
|
class TeamMembersController < ProjectResourceController
|
2011-10-08 23:36:38 +02:00
|
|
|
# Authorize
|
2011-10-17 12:39:03 +02:00
|
|
|
before_filter :authorize_read_project!
|
2012-09-16 16:56:32 +02:00
|
|
|
before_filter :authorize_admin_project!, except: [:index, :show]
|
|
|
|
|
|
|
|
def index
|
|
|
|
end
|
2011-10-08 23:36:38 +02:00
|
|
|
|
|
|
|
def show
|
|
|
|
@team_member = project.users_projects.find(params[:id])
|
2012-08-21 07:20:11 +02:00
|
|
|
@events = @team_member.user.recent_events.where(:project_id => @project.id).limit(7)
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@team_member = project.users_projects.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2012-09-07 08:50:35 +02:00
|
|
|
@project.add_users_ids_to_team(
|
|
|
|
params[:user_ids],
|
|
|
|
params[:project_access]
|
|
|
|
)
|
|
|
|
|
2012-09-16 15:21:20 +02:00
|
|
|
redirect_to project_team_index_path(@project)
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@team_member = project.users_projects.find(params[:id])
|
|
|
|
@team_member.update_attributes(params[:team_member])
|
|
|
|
|
2011-12-07 00:27:07 +01:00
|
|
|
unless @team_member.valid?
|
|
|
|
flash[:alert] = "User should have at least one role"
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|
2012-09-16 15:21:20 +02:00
|
|
|
redirect_to project_team_index_path(@project)
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@team_member = project.users_projects.find(params[:id])
|
|
|
|
@team_member.destroy
|
|
|
|
|
|
|
|
respond_to do |format|
|
2012-09-16 15:21:20 +02:00
|
|
|
format.html { redirect_to project_team_index_path(@project) }
|
2012-08-11 00:07:50 +02:00
|
|
|
format.js { render nothing: true }
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|