Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
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
Container Registry
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp
Commits
b6ac3c93
Commit
b6ac3c93
authored
4 years ago
by
Calum Mackervoy
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: nested container resolves as id-less container
parent
dcab4da1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!130
Resolve "DjangoLDP resolve_id error on container path"
Pipeline
#5941
passed
4 years ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
djangoldp/models.py
+7
-4
7 additions, 4 deletions
djangoldp/models.py
with
7 additions
and
4 deletions
djangoldp/models.py
+
7
−
4
View file @
b6ac3c93
...
...
@@ -118,13 +118,16 @@ class Model(models.Model):
def
resolve_id
(
cls
,
id
):
'''
Resolves the id of a given path (e.g. /container/1/)
Raises
ValidationError if the path has no id, a Resolver404 if the path cannot be found
Raises
Resolver404 if the path cannot be found, ValidationError if the path is for a model base
and an ObjectDoesNotExist exception if the resource does not exist
'''
id
=
cls
.
__clean_path
(
id
)
view
,
args
,
kwargs
=
get_resolver
().
resolve
(
id
)
if
len
(
kwargs
.
keys
())
==
0
:
raise
ValidationError
(
'
no id in given path
'
)
match
=
get_resolver
().
resolve
(
id
)
kwargs
=
match
.
kwargs
view
=
match
.
func
if
match
.
url_name
.
endswith
(
'
-list
'
)
or
len
(
match
.
kwargs
.
keys
())
==
0
:
raise
ValidationError
(
'
resolve_id received a path for a container or nested container
'
)
return
view
.
initkwargs
[
'
model
'
].
objects
.
get
(
**
kwargs
)
@classonlymethod
...
...
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