2011-10-08 17:36:38 -04:00
|
|
|
class TeamMembersController < ApplicationController
|
2011-10-26 09:46:25 -04:00
|
|
|
before_filter :project
|
2011-11-01 05:22:16 -04:00
|
|
|
layout "project"
|
2011-10-08 17:36:38 -04:00
|
|
|
|
|
|
|
# Authorize
|
|
|
|
before_filter :add_project_abilities
|
2011-10-17 06:39:03 -04:00
|
|
|
before_filter :authorize_read_project!
|
2011-12-15 16:57:46 -05:00
|
|
|
before_filter :authorize_admin_project!, :except => [:show]
|
2011-10-08 17:36:38 -04:00
|
|
|
|
|
|
|
def show
|
|
|
|
@team_member = project.users_projects.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@team_member = project.users_projects.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@team_member = UsersProject.new(params[:team_member])
|
|
|
|
@team_member.project = project
|
2012-01-14 16:46:06 -05:00
|
|
|
if @team_member.save
|
|
|
|
redirect_to team_project_path(@project)
|
|
|
|
else
|
|
|
|
render "new"
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@team_member = project.users_projects.find(params[:id])
|
|
|
|
@team_member.update_attributes(params[:team_member])
|
|
|
|
|
2011-12-06 18:27:07 -05:00
|
|
|
unless @team_member.valid?
|
|
|
|
flash[:alert] = "User should have at least one role"
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
2011-12-06 18:27:07 -05:00
|
|
|
redirect_to team_project_path(@project)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@team_member = project.users_projects.find(params[:id])
|
|
|
|
@team_member.destroy
|
|
|
|
|
|
|
|
respond_to do |format|
|
2012-01-28 04:54:11 -05:00
|
|
|
format.html { redirect_to team_project_path(@project) }
|
2011-10-26 09:46:25 -04:00
|
|
|
format.js { render :nothing => true }
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|