gitlabhq/app/controllers/team_members_controller.rb

48 lines
1.1 KiB
Ruby
Raw Normal View History

2011-10-08 23:36:38 +02:00
class TeamMembersController < ApplicationController
before_filter :project
2011-11-01 10:22:16 +01:00
layout "project"
2011-10-08 23:36:38 +02:00
# Authorize
before_filter :add_project_abilities
2011-10-17 12:39:03 +02:00
before_filter :authorize_read_project!
2011-12-15 22:57:46 +01:00
before_filter :authorize_admin_project!, :except => [:show]
2011-10-08 23:36:38 +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
2012-01-14 22:46:06 +01:00
if @team_member.save
redirect_to team_project_path(@project)
else
render "new"
end
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])
unless @team_member.valid?
flash[:alert] = "User should have at least one role"
2011-10-08 23:36:38 +02:00
end
redirect_to team_project_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|
format.html { redirect_to root_path }
format.js { render :nothing => true }
2011-10-08 23:36:38 +02:00
end
end
end