Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Database
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Coscine
backend
libraries
Database
Commits
54244c86
Commit
54244c86
authored
4 years ago
by
Marcel Nellesen
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Fixed top-level project selection (coscine/issues#1383)
parent
42f3e6c7
No related branches found
No related tags found
2 merge requests
!124
Update product with master
,
!123
Hotfix/1383 top level
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Database/Models/ProjectModel.cs
+20
-14
20 additions, 14 deletions
src/Database/Models/ProjectModel.cs
with
20 additions
and
14 deletions
src/Database/Models/ProjectModel.cs
+
20
−
14
View file @
54244c86
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment