Commit 7403afea authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Reject non-owned projects to assign to teams

parent b4967b37
...@@ -16,13 +16,19 @@ class Teams::ProjectsController < Teams::ApplicationController ...@@ -16,13 +16,19 @@ class Teams::ProjectsController < Teams::ApplicationController
end end
def create def create
unless params[:project_ids].blank? redirect_to :back if params[:project_ids].blank?
project_ids = params[:project_ids]
access = params[:greatest_project_access] project_ids = params[:project_ids]
user_team.assign_to_projects(project_ids, access) access = params[:greatest_project_access]
end
# Reject non-allowed projects
allowed_project_ids = current_user.owned_projects.map(&:id)
project_ids.select! { |id| allowed_project_ids.include?(id) }
# Assign projects to team
user_team.assign_to_projects(project_ids, access)
redirect_to team_projects_path(user_team), notice: 'Team of users was successfully assgned to projects.' redirect_to team_projects_path(user_team), notice: 'Team of users was successfully assigned to projects.'
end end
def edit def edit
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment