Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
beat
beat.web
Commits
4ee2126d
Commit
4ee2126d
authored
6 years ago
by
Samuel GAIST
Browse files
Options
Downloads
Patches
Plain Diff
[reports][api] Fix key search in dictionaries
parent
91efa6c9
No related branches found
No related tags found
2 merge requests
!255
1.4.x
,
!242
Py3 compatibility
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/reports/api.py
+13
-13
13 additions, 13 deletions
beat/web/reports/api.py
with
13 additions
and
13 deletions
beat/web/reports/api.py
+
13
−
13
View file @
4ee2126d
...
...
@@ -142,10 +142,10 @@ class UserReportListView(generics.ListCreateAPIView):
return
Response
(
result
,
status
=
status
.
HTTP_201_CREATED
)
else
:
if
details
.
has_key
(
'
error
'
)
:
if
'
error
'
in
details
:
return
BadRequestResponse
({
'
error
'
:
details
[
'
error
'
]})
elif
details
.
has_key
(
'
common_analyzers
'
)
:
elif
'
common_analyzers
'
in
details
:
result
=
{
'
common_analyzers
'
:
details
[
'
common_analyzers
'
],
}
...
...
@@ -163,7 +163,7 @@ class ReportDetailView(generics.RetrieveUpdateDestroyAPIView):
writing_serializer_class
=
ReportUpdateSerializer
def
get_queryset
(
self
):
if
self
.
kwargs
.
has_key
(
'
number
'
)
:
if
'
number
'
in
self
.
kwargs
:
report
=
get_object_or_404
(
Report
,
number
=
int
(
self
.
kwargs
.
get
(
'
number
'
)))
else
:
owner_name
=
self
.
kwargs
.
get
(
'
owner_name
'
)
...
...
@@ -177,7 +177,7 @@ class ReportDetailView(generics.RetrieveUpdateDestroyAPIView):
def
get_permissions
(
self
):
permission_classes
=
[
IsAuthorOrPublished
]
if
self
.
kwargs
.
has_key
(
'
number
'
)
:
if
'
number
'
in
self
.
kwargs
:
permission_classes
=
[
IsAccessibleOutside
]
else
:
permission_classes
=
[
IsAuthorOrPublished
]
...
...
@@ -202,7 +202,7 @@ class ReportDetailView(generics.RetrieveUpdateDestroyAPIView):
serializer
=
self
.
serializer_class
(
report
,
context
=
{
'
request
'
:
request
})
data
=
serializer
.
data
if
self
.
kwargs
.
has_key
(
'
number
'
)
and
report
.
status
==
Report
.
LOCKED
:
if
'
number
'
in
self
.
kwargs
and
report
.
status
==
Report
.
LOCKED
:
data
[
"
anonymous
"
]
=
True
return
Response
(
data
)
...
...
@@ -214,7 +214,7 @@ class ReportDetailView(generics.RetrieveUpdateDestroyAPIView):
def
update
(
self
,
request
,
owner_name
,
report_name
):
# Process the query string
if
request
.
GET
.
has_key
(
'
fields
'
)
:
if
'
fields
'
in
request
.
GET
:
fields_to_return
=
request
.
GET
[
'
fields
'
].
split
(
'
,
'
)
else
:
# Available fields (not returned by default):
...
...
@@ -344,7 +344,7 @@ class PublishReportView(BaseReportActionView):
report
=
self
.
get_queryset
()
visible_algorithms_names
=
[]
if
request
.
data
.
has_key
(
'
visible_algorithms
'
)
:
if
'
visible_algorithms
'
in
request
.
data
:
visible_algorithms_names
=
request
.
data
[
'
visible_algorithms
'
]
# Build algorithms sharing information
...
...
@@ -409,10 +409,10 @@ class ReportAddExperimentsView(BaseReportActionView):
return
Response
(
result
)
else
:
if
details
.
has_key
(
'
error
'
)
:
if
'
error
'
in
details
:
return
BadRequestResponse
({
'
error
'
:
details
[
'
error
'
]})
elif
details
.
has_key
(
'
common_analyzers
'
)
:
elif
'
common_analyzers
'
in
details
:
result
=
{
'
common_analyzers
'
:
details
[
'
common_analyzers
'
],
}
...
...
@@ -486,12 +486,12 @@ class ReportResultsView(CommonContextMixin, generics.RetrieveAPIView):
report_content
=
json
.
loads
(
report
.
content
)
if
not
report_content
.
has_key
(
"
alias_experiments
"
)
:
if
"
alias_experiments
"
not
in
report_content
:
report_content
[
"
alias_experiments
"
]
=
{}
for
experiment
in
report
.
experiments
.
iterator
():
serializer
=
self
.
get_serializer
(
experiment
,
fields
=
[
'
results
'
,
'
blocks_status
'
,
'
execution_info
'
,
'
declaration
'
])
if
not
report_content
[
"
alias_experiments
"
]
.
has_key
(
experiment
.
fullname
())
:
if
experiment
.
fullname
()
not
in
report_content
[
"
alias_experiments
"
]:
report_content
[
"
alias_experiments
"
][
experiment
.
fullname
()]
=
experiment
.
name
if
report
.
status
==
Report
.
LOCKED
:
...
...
@@ -527,12 +527,12 @@ class ReportResultsAllExperimentsView(CommonContextMixin, generics.RetrieveAPIVi
report_content
=
json
.
loads
(
report
.
content
)
if
not
report_content
.
has_key
(
"
alias_experiments
"
)
:
if
"
alias_experiments
"
not
in
report_content
:
report_content
[
"
alias_experiments
"
]
=
{}
for
experiment
in
report
.
experiments
.
iterator
():
serializer
=
self
.
get_serializer
(
experiment
,
fields
=
[
'
results
'
,
'
blocks_status
'
,
'
execution_info
'
,
'
declaration
'
])
if
not
report_content
[
"
alias_experiments
"
]
.
has_key
(
experiment
.
fullname
())
:
if
experiment
.
fullname
()
not
in
report_content
[
"
alias_experiments
"
]:
report_content
[
"
alias_experiments
"
][
experiment
.
fullname
()]
=
experiment
.
name
if
report
.
status
==
Report
.
LOCKED
:
...
...
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