2012-09-27 14:59:42 -04:00
|
|
|
class TeamMembersController < ProjectResourceController
|
2011-10-08 17:36:38 -04:00
|
|
|
# Authorize
|
2011-10-17 06:39:03 -04:00
|
|
|
before_filter :authorize_read_project!
|
2012-09-16 10:56:32 -04:00
|
|
|
before_filter :authorize_admin_project!, except: [:index, :show]
|
|
|
|
|
|
|
|
def index
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
|
|
|
|
def show
|
|
|
|
@team_member = project.users_projects.find(params[:id])
|
2012-08-21 01:20:11 -04:00
|
|
|
@events = @team_member.user.recent_events.where(:project_id => @project.id).limit(7)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@team_member = project.users_projects.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2012-09-07 02:50:35 -04:00
|
|
|
@project.add_users_ids_to_team(
|
|
|
|
params[:user_ids],
|
|
|
|
params[:project_access]
|
|
|
|
)
|
|
|
|
|
2012-09-16 09:21:20 -04:00
|
|
|
redirect_to project_team_index_path(@project)
|
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
|
2012-09-16 09:21:20 -04:00
|
|
|
redirect_to project_team_index_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-09-16 09:21:20 -04:00
|
|
|
format.html { redirect_to project_team_index_path(@project) }
|
2012-08-10 18:07:50 -04:00
|
|
|
format.js { render nothing: true }
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
end
|
2012-10-24 07:20:53 -04:00
|
|
|
|
|
|
|
def apply_import
|
|
|
|
giver = Project.find(params[:source_project_id])
|
|
|
|
status = UsersProject.import_team(giver, project)
|
|
|
|
notice = status ? "Succesfully imported" : "Import failed"
|
|
|
|
|
|
|
|
redirect_to project_team_members_path(project), notice: notice
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|