Skip to content
Snippets Groups Projects
Commit 54244c86 authored by Marcel Nellesen's avatar Marcel Nellesen
Browse files

Fix: Fixed top-level project selection (coscine/issues#1383)

parent 42f3e6c7
No related branches found
No related tags found
2 merge requests!124Update product with master,!123Hotfix/1383 top level
......@@ -327,14 +327,20 @@ namespace Coscine.Database.Models
public IEnumerable<Project> GetTopLevelWithAccess(User user, params string[] allowedAccess)
{
return GetWithAccess(user, allowedAccess, (allowedProjectIds) => GetAllWhere((project) => allowedProjectIds.Contains(project.Id) &&
((!project.SubProjectProjects.Any()) // get top level projects not having any parent projects
|| !(from subProject in project.SubProjectProjects // check if the direct parent project is accessible to the current user
where (from parentProjectRole in subProject.Project.ProjectRoles
where parentProjectRole.UserId == user.Id
&& allowedAccess.Contains(parentProjectRole.Role.DisplayName.ToLower())
select parentProjectRole).Any()
select subProject).Any())));
return GetWithAccess(user, allowedAccess, (allowedProjectIds) => GetAllWhere((project) =>
(
// all accessable projects that have no parents
(!project.SubProjectSubProjectNavigations.Any())
|| // all accessable projects that have no accessable parents
(
project.SubProjectSubProjectNavigations.All(
(parentProjects) =>
parentProjects.Project.ProjectRoles.All((projectRole) => projectRole.UserId != user.Id)
)
)
)
&& project.ProjectRoles.Any((projectRole) => projectRole.UserId == user.Id))
);
}
public void AddResource(Project project, Resource resource)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment