Skip to content

Commit

Permalink
bulk-import | swagger parameter for request body
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Sep 11, 2020
1 parent b2993de commit 763e670
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions core/importers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
class BulkImportView(APIView):
permission_classes = (IsAuthenticated, )

@swagger_auto_schema(manual_parameters=[update_if_exists_param])
@swagger_auto_schema(
manual_parameters=[update_if_exists_param],
request_body=openapi.Schema(type=openapi.TYPE_OBJECT)
)
def post(self, request):
user = self.request.user
username = user.username
Expand All @@ -38,10 +41,12 @@ def post(self, request):
update_if_exists = update_if_exists == 'true'

task_id = str(uuid.uuid4()) + '-' + username

data = request.body.decode('utf-8') if isinstance(request.body, bytes) else request.body
if user.is_staff:
task = bulk_priority_import.apply_async((request.body, username, update_if_exists), task_id=task_id)
task = bulk_priority_import.apply_async((data, username, update_if_exists), task_id=task_id)
else:
task = bulk_import.apply_async((request.body, username, update_if_exists), task_id=task_id)
task = bulk_import.apply_async((data, username, update_if_exists), task_id=task_id)

return Response(dict(task=task.id, state=task.state))

Expand Down

0 comments on commit 763e670

Please sign in to comment.