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
75740d97
Verified
Commit
75740d97
authored
2 years ago
by
Marte Fossum
Browse files
Options
Downloads
Patches
Plain Diff
Add pagination to list-sponsororgunits
parent
cdef42c9
No related branches found
No related tags found
1 merge request
!397
Add pagination to list-sponsororgunits
Pipeline
#187486
passed
2 years ago
Stage: venv update
Stage: tests and linting
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
greg/api/views/sponsor.py
+5
-0
5 additions, 0 deletions
greg/api/views/sponsor.py
greg/tests/api/test_sponsor.py
+1
-1
1 addition, 1 deletion
greg/tests/api/test_sponsor.py
with
6 additions
and
1 deletion
greg/api/views/sponsor.py
+
5
−
0
View file @
75740d97
...
...
@@ -69,6 +69,7 @@ class SponsorOrgunitLinkView(
mixins
.
CreateModelMixin
,
mixins
.
RetrieveModelMixin
,
mixins
.
DestroyModelMixin
,
mixins
.
ListModelMixin
,
GenericViewSet
,
):
"""
Endpoint that allows manipulation of links between a sponsor and the units he is attached to
"""
...
...
@@ -126,6 +127,10 @@ class SponsorOrgunitLinkView(
"""
Lists all SponsorOrganizationalUnit objects connected to the sponsor
"""
sponsor_id
=
kwargs
[
"
sponsor_id
"
]
all_units
=
self
.
queryset
.
filter
(
sponsor__id
=
sponsor_id
).
all
()
page
=
self
.
paginate_queryset
(
all_units
)
if
page
is
not
None
:
serializer
=
self
.
serializer_class
(
page
,
many
=
True
)
return
self
.
get_paginated_response
(
serializer
.
data
)
serializer
=
self
.
serializer_class
(
all_units
,
many
=
True
)
return
Response
(
serializer
.
data
)
...
...
This diff is collapsed.
Click to expand it.
greg/tests/api/test_sponsor.py
+
1
−
1
View file @
75740d97
...
...
@@ -233,7 +233,7 @@ def test_list_all_sponsor_orgunits(
):
url
=
reverse
(
"
v1:sponsor_orgunit-list
"
,
kwargs
=
{
"
sponsor_id
"
:
sponsor_guy
.
id
})
sponsor_units
=
client
.
get
(
url
).
json
()
sponsor_units
=
client
.
get
(
url
).
json
()
[
"
results
"
]
assert
len
(
sponsor_units
)
==
2
...
...
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