2013-01-19 12:48:05 -05:00
|
|
|
class Teams::ProjectsController < Teams::ApplicationController
|
|
|
|
def index
|
2013-01-22 12:21:07 -05:00
|
|
|
@projects = user_team.projects
|
|
|
|
@avaliable_projects = current_user.admin? ? Project.without_team(user_team) : (Project.personal(current_user) + current_user.projects).uniq
|
2013-01-19 12:48:05 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
2013-01-22 12:21:07 -05:00
|
|
|
@projects = Project.scoped
|
|
|
|
@projects = @projects.without_team(user_team) if user_team.projects.any?
|
|
|
|
#@projects.reject!(&:empty_repo?)
|
2013-01-19 12:48:05 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2013-01-22 12:21:07 -05:00
|
|
|
unless params[:project_ids].blank?
|
|
|
|
project_ids = params[:project_ids]
|
|
|
|
access = params[:greatest_project_access]
|
|
|
|
user_team.assign_to_projects(project_ids, access)
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to admin_team_path(user_team), notice: 'Projects was successfully added.'
|
2013-01-19 12:48:05 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2013-01-22 12:21:07 -05:00
|
|
|
@user_team = user_team
|
2013-01-19 12:48:05 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2013-01-22 12:21:07 -05:00
|
|
|
if user_team.update_project_access(project, params[:greatest_project_access])
|
|
|
|
redirect_to admin_team_path(user_team), notice: 'Membership was successfully updated.'
|
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
2013-01-19 12:48:05 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2013-01-22 12:21:07 -05:00
|
|
|
user_team.resign_from_project(project)
|
|
|
|
redirect_to admin_team_path(user_team), notice: 'Project was successfully removed.'
|
2013-01-19 12:48:05 -05:00
|
|
|
end
|
|
|
|
end
|