Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
greg
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
it-bott-integrasjoner
greg
Commits
733ab1ec
Verified
Commit
733ab1ec
authored
2 years ago
by
Marte Fossum
Browse files
Options
Downloads
Patches
Plain Diff
Hide deleted units from view
parent
ea0ea869
No related branches found
No related tags found
1 merge request
!384
Hide deleted units from view
Pipeline
#179445
passed
2 years ago
Stage: venv update
Stage: tests and linting
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
greg/models.py
+5
-2
5 additions, 2 deletions
greg/models.py
greg/tasks.py
+1
-1
1 addition, 1 deletion
greg/tasks.py
greg/tests/models/test_sponsor.py
+13
-2
13 additions, 2 deletions
greg/tests/models/test_sponsor.py
with
19 additions
and
5 deletions
greg/models.py
+
5
−
2
View file @
733ab1ec
...
...
@@ -643,7 +643,7 @@ class Sponsor(BaseModel):
models
.
UniqueConstraint
(
name
=
"
unique_feide_id
"
,
fields
=
[
"
feide_id
"
])
]
def
get_allowed_units
(
self
)
->
s
e
t
[
OrganizationalUnit
]:
def
get_allowed_units
(
self
)
->
li
st
[
OrganizationalUnit
]:
"""
Fetch every unit the sponsor has access to.
...
...
@@ -659,7 +659,10 @@ class Sponsor(BaseModel):
# Add units accessible through direct access
units
=
units
.
union
({
i
.
organizational_unit
for
i
in
connections
})
return
units
# Remove units that are deleted
units_filtered
=
[
unit
for
unit
in
units
if
not
unit
.
deleted
]
return
units_filtered
class
SponsorOrganizationalUnit
(
BaseModel
):
...
...
This diff is collapsed.
Click to expand it.
greg/tasks.py
+
1
−
1
View file @
733ab1ec
...
...
@@ -41,7 +41,7 @@ def notify_sponsors_roles_ending() -> list[str]:
# Map sponsors with email to units
sponsors
=
Sponsor
.
objects
.
filter
(
work_email__isnull
=
False
)
sp2unit
=
{
s
.
id
:
list
(
s
.
get_allowed_units
()
)
for
s
in
sponsors
}
sp2unit
=
{
s
.
id
:
s
.
get_allowed_units
()
for
s
in
sponsors
}
# Map sponsors to ending roles
# Make sure only the sponsor(s) closest to the role is notified
...
...
This diff is collapsed.
Click to expand it.
greg/tests/models/test_sponsor.py
+
13
−
2
View file @
733ab1ec
...
...
@@ -81,9 +81,20 @@ def test_get_allowed(sponsor_foo, unit1, unit2):
unit2
.
save
()
# Without hier access only get unit connected to
assert
sponsor_foo
.
get_allowed_units
()
==
{
unit1
}
assert
sponsor_foo
.
get_allowed_units
()
==
[
unit1
]
# With hier access also get units below
spu
.
hierarchical_access
=
True
spu
.
save
()
assert
sponsor_foo
.
get_allowed_units
()
==
{
unit1
,
unit2
}
assert
sponsor_foo
.
get_allowed_units
()
==
[
unit1
,
unit2
]
# Don't get deleted units
unit2
.
deleted
=
True
unit2
.
save
()
assert
sponsor_foo
.
get_allowed_units
()
==
[
unit1
]
unit2
.
deleted
=
False
unit1
.
deleted
=
True
unit2
.
save
()
unit1
.
save
()
assert
sponsor_foo
.
get_allowed_units
()
==
[
unit2
]
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