Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
454da644
Commit
454da644
authored
2 years ago
by
Erwan Rouchet
Committed by
Bastien Abadie
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix AttributeError on RetrieveModelVersion HTML 404
parent
219aa0c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1943
Fix AttributeError on RetrieveModelVersion HTML 404
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
arkindex/training/api.py
+1
-6
1 addition, 6 deletions
arkindex/training/api.py
arkindex/training/serializers.py
+6
-1
6 additions, 1 deletion
arkindex/training/serializers.py
arkindex/training/tests/test_model_api.py
+4
-2
4 additions, 2 deletions
arkindex/training/tests/test_model_api.py
with
11 additions
and
9 deletions
arkindex/training/api.py
+
1
−
6
View file @
454da644
...
...
@@ -129,15 +129,10 @@ class ModelVersionsRetrieve(TrainingModelMixin, RetrieveUpdateDestroyAPIView):
def
get_serializer_context
(
self
):
context
=
super
().
get_serializer_context
()
context
.
update
({
'
model
'
:
self
.
model_version
.
model
,
'
is_contributor
'
:
self
.
access_level
and
self
.
access_level
>=
Role
.
Contributor
.
value
,
'
is_contributor
'
:
getattr
(
self
,
'
access_level
'
,
0
)
>=
Role
.
Contributor
.
value
,
})
return
context
def
get_object
(
self
,
*
args
,
**
kwargs
):
self
.
model_version
=
super
().
get_object
(
*
args
,
**
kwargs
)
return
self
.
model_version
def
check_object_permissions
(
self
,
request
,
model_version
):
self
.
access_level
=
get_max_level
(
self
.
request
.
user
,
model_version
.
model
)
...
...
This diff is collapsed.
Click to expand it.
arkindex/training/serializers.py
+
6
−
1
View file @
454da644
...
...
@@ -17,6 +17,8 @@ from arkindex.users.utils import get_max_level
def
_model_from_context
(
serializer_field
):
if
isinstance
(
serializer_field
.
parent
.
instance
,
ModelVersion
):
return
serializer_field
.
parent
.
instance
.
model
return
serializer_field
.
context
.
get
(
'
model
'
)
...
...
@@ -114,7 +116,10 @@ class ModelVersionSerializer(serializers.ModelSerializer):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
model
=
self
.
context
.
get
(
'
model
'
)
if
isinstance
(
self
.
instance
,
ModelVersion
):
model
=
self
.
instance
.
model
else
:
model
=
self
.
context
.
get
(
'
model
'
)
if
model
:
qs
=
ModelVersion
.
objects
.
filter
(
model_id
=
model
.
id
)
if
getattr
(
self
.
instance
,
'
id
'
,
None
):
...
...
This diff is collapsed.
Click to expand it.
arkindex/training/tests/test_model_api.py
+
4
−
2
View file @
454da644
...
...
@@ -496,14 +496,15 @@ class TestModelAPI(FixtureAPITestCase):
'
hash
'
:
'
n
'
*
32
,
'
archive_hash
'
:
'
n
'
*
32
,
}
with
self
.
assertNumQueries
(
9
):
response
=
self
.
client
.
patch
(
reverse
(
'
api:model-version-retrieve
'
,
kwargs
=
{
'
pk
'
:
str
(
self
.
model_version1
.
id
)}),
request
,
format
=
'
json
'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertDictEqual
(
response
.
json
(),
{
'
id
'
:
str
(
self
.
model_version1
.
id
),
'
model_id
'
:
str
(
self
.
model_version1
.
model_id
),
...
...
@@ -544,14 +545,15 @@ class TestModelAPI(FixtureAPITestCase):
'
hash
'
:
'
n
'
*
32
,
'
archive_hash
'
:
'
n
'
*
32
,
}
with
self
.
assertNumQueries
(
9
):
response
=
self
.
client
.
patch
(
reverse
(
'
api:model-version-retrieve
'
,
kwargs
=
{
'
pk
'
:
str
(
self
.
model_version3
.
id
)}),
request
,
format
=
'
json
'
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
,
response
.
json
())
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
self
.
assertDictEqual
(
response
.
json
(),
{
'
id
'
:
str
(
self
.
model_version3
.
id
),
'
model_id
'
:
str
(
self
.
model_version3
.
model_id
),
...
...
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