diff options
author | gitlabhq <m@gitlabhq.com> | 2011-10-09 00:36:38 +0300 |
---|---|---|
committer | gitlabhq <m@gitlabhq.com> | 2011-10-09 00:36:38 +0300 |
commit | 9ba1224867665844b117fa037e1465bb706b3685 (patch) | |
tree | 52fbfc1cdb55df21843965479c97be0c91121a9a /app/controllers/team_members_controller.rb | |
parent | 93efff945215a4407afcaf0cba15ac601b56df0d (diff) | |
download | gitlab-ce-9ba1224867665844b117fa037e1465bb706b3685.tar.gz |
init commit
Diffstat (limited to 'app/controllers/team_members_controller.rb')
-rw-r--r-- | app/controllers/team_members_controller.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/app/controllers/team_members_controller.rb b/app/controllers/team_members_controller.rb new file mode 100644 index 00000000000..fd3c944b289 --- /dev/null +++ b/app/controllers/team_members_controller.rb @@ -0,0 +1,66 @@ +class TeamMembersController < ApplicationController + before_filter :project + + # Authorize + before_filter :add_project_abilities + before_filter :authorize_read_team_member! + before_filter :authorize_admin_team_member!, :only => [:new, :create, :destroy, :update] + + def show + @team_member = project.users_projects.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.js + format.json { render json: @team_member } + end + end + + def new + @team_member = project.users_projects.new + + respond_to do |format| + format.html # new.html.erb + format.js + format.json { render json: @team_member } + end + end + + def create + @team_member = UsersProject.new(params[:team_member]) + @team_member.project = project + + respond_to do |format| + if @team_member.save + format.html { redirect_to @team_member, notice: 'Team member was successfully created.' } + format.js + format.json { render json: @team_member, status: :created, location: @team_member } + else + format.html { render action: "new" } + format.js + format.json { render json: @team_member.errors, status: :unprocessable_entity } + end + end + end + + def update + @team_member = project.users_projects.find(params[:id]) + @team_member.update_attributes(params[:team_member]) + + respond_to do |format| + format.js + format.html { redirect_to team_project_path(@project)} + 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.json { head :ok } + format.js { render :nothing => true } + end + end +end |