2011-10-13 03:00:00 +02:00
|
|
|
class TeamMembersController < ApplicationController
|
|
|
|
before_filter :project
|
|
|
|
|
|
|
|
# Authorize
|
|
|
|
before_filter :add_project_abilities
|
2011-10-21 19:04:41 +02:00
|
|
|
before_filter :authorize_read_project!
|
|
|
|
before_filter :authorize_admin_project!, :only => [:new, :create, :destroy, :update]
|
2011-10-13 03:00:00 +02: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
|
2011-10-22 15:07:26 +02:00
|
|
|
@team_member.save
|
2011-10-13 03:00:00 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@team_member = project.users_projects.find(params[:id])
|
|
|
|
@team_member.update_attributes(params[:team_member])
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.js
|
2011-10-22 15:07:26 +02:00
|
|
|
format.html do
|
|
|
|
unless @team_member.valid?
|
|
|
|
flash[:alert] = "User should have at least one role"
|
|
|
|
end
|
|
|
|
redirect_to team_project_path(@project)
|
|
|
|
end
|
2011-10-13 03:00:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@team_member = project.users_projects.find(params[:id])
|
|
|
|
@team_member.destroy
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to root_path }
|
|
|
|
format.js { render :nothing => true }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|