forked from github/plane
fix: bulk modules importer (#973)
This commit is contained in:
parent
21992f540f
commit
b2ad071608
@ -487,11 +487,16 @@ class BulkImportModulesEndpoint(BaseAPIView):
|
|||||||
ignore_conflicts=True,
|
ignore_conflicts=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
modules = Module.objects.filter(id__in=[module.id for module in modules])
|
||||||
|
|
||||||
|
if len(modules) == len(modules_data):
|
||||||
_ = ModuleLink.objects.bulk_create(
|
_ = ModuleLink.objects.bulk_create(
|
||||||
[
|
[
|
||||||
ModuleLink(
|
ModuleLink(
|
||||||
module=module,
|
module=module,
|
||||||
url=module_data.get("link", {}).get("url", "https://plane.so"),
|
url=module_data.get("link", {}).get(
|
||||||
|
"url", "https://plane.so"
|
||||||
|
),
|
||||||
title=module_data.get("link", {}).get(
|
title=module_data.get("link", {}).get(
|
||||||
"title", "Original Issue"
|
"title", "Original Issue"
|
||||||
),
|
),
|
||||||
@ -529,6 +534,12 @@ class BulkImportModulesEndpoint(BaseAPIView):
|
|||||||
return Response(
|
return Response(
|
||||||
{"modules": serializer.data}, status=status.HTTP_201_CREATED
|
{"modules": serializer.data}, status=status.HTTP_201_CREATED
|
||||||
)
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
return Response(
|
||||||
|
{"message": "Modules created but issues could not be imported"},
|
||||||
|
status=status.HTTP_200_OK,
|
||||||
|
)
|
||||||
except Project.DoesNotExist:
|
except Project.DoesNotExist:
|
||||||
return Response(
|
return Response(
|
||||||
{"error": "Project does not exist"}, status=status.HTTP_404_NOT_FOUND
|
{"error": "Project does not exist"}, status=status.HTTP_404_NOT_FOUND
|
||||||
|
Loading…
Reference in New Issue
Block a user