Skip to content
Snippets Groups Projects
Commit 4ee2126d authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[reports][api] Fix key search in dictionaries

parent 91efa6c9
No related branches found
No related tags found
2 merge requests!2551.4.x,!242Py3 compatibility
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment