Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Show more breadcrumbs
ssa
workspaces
Commits
215106b4
Commit
215106b4
authored
3 years ago
by
Charlotte Hausman
Browse files
Options
Downloads
Patches
Plain Diff
uncomplicate the endpoints
parent
9652da5a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!647
display versions in UI
,
!646
Create new REST endpoints for returning capability versions
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
services/capability/capability/views/capability_version.py
+9
-10
9 additions, 10 deletions
services/capability/capability/views/capability_version.py
with
9 additions
and
10 deletions
services/capability/capability/views/capability_version.py
+
9
−
10
View file @
215106b4
...
...
@@ -29,13 +29,18 @@ from pyramid.view import view_config
@view_config
(
route_name
=
"
view_all_versions
"
,
renderer
=
"
json
"
)
def
view_all_versions
(
request
:
Request
):
"""
Pyramid view that accepts a request to view all versions of a capability request
URL: capability/request/{capability_request_id}/versions
:param request: GET request
:return: 200 OK response with JSON-formatted info of latest version of request with given ID
or 404 response (HTTPNotFound) if capability request with given ID does not exist
or 412 response (HTTPPreconditionFailed) if capability request with given ID has no versions
"""
capability_request
=
request
.
capability_info
.
lookup_capability_request
(
request
.
matchdict
[
"
capability_request_id
"
])
if
capability_request
:
if
capability_request
.
versions
:
versions
=
[]
for
version
in
capability_request
.
versions
:
versions
.
append
(
version
.
__json__
())
return
capability_request
.
versions
else
:
no_versions_msg
=
(
...
...
@@ -97,13 +102,7 @@ def view_specific_version(request: Request) -> Response:
if
capability_request
:
version
=
capability_request
.
versions
[
int
(
version_id
)
-
1
]
if
version
:
version_json
=
version
.
__json__
()
version_json
[
"
files
"
]
=
[]
for
file
in
version
.
files
:
version_json
[
"
files
"
].
append
(
file
.
__json__
())
return
Response
(
json_body
=
version_json
)
return
version
else
:
no_versions_msg
=
(
f
"
Capability request with ID
{
request
.
matchdict
[
'
capability_request_id
'
]
}
has no versions.
"
...
...
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