Move team project management to own controller
This commit is contained in:
parent
cca9935970
commit
b7470440ff
8 changed files with 121 additions and 0 deletions
42
app/controllers/admin/teams/projects_controller.rb
Normal file
42
app/controllers/admin/teams/projects_controller.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
class Admin::Teams::ProjectsController < Admin::Teams::ApplicationController
|
||||
before_filter :team_project, only: [:edit, :destroy, :update]
|
||||
|
||||
def new
|
||||
@projects = Project.scoped
|
||||
@projects = @projects.without_team(@team) if @team.projects.any?
|
||||
#@projects.reject!(&:empty_repo?)
|
||||
end
|
||||
|
||||
def create
|
||||
unless params[:project_ids].blank?
|
||||
project_ids = params[:project_ids]
|
||||
access = params[:greatest_project_access]
|
||||
@team.assign_to_projects(project_ids, access)
|
||||
end
|
||||
|
||||
redirect_to admin_team_path(@team), notice: 'Projects was successfully added.'
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @team.update_project_access(@project, params[:greatest_project_access])
|
||||
redirect_to admin_team_path(@team), notice: 'Membership was successfully updated.'
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@team.resign_from_project(@project)
|
||||
redirect_to admin_team_path(@team), notice: 'Project was successfully removed.'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def team_project
|
||||
@project = @team.projects.find_by_path(params[:id])
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue