def post(self, request, *args, **kwargs): upload = request.FILES.get('bulk_upload_file') if not upload: messages.error(request, _('no file uploaded')) return self.get(request, *args, **kwargs) elif not upload.name.endswith('.xlsx'): messages.error(request, _('please use xlsx format only')) return self.get(request, *args, **kwargs) domain = args[0] # stash this in soil to make it easier to pass to celery file_ref = expose_cached_download( upload.read(), expiry=1*60*60, file_extension=file_extention_from_filename(upload.name) ) task = import_products_async.delay( domain, file_ref.download_id, ) file_ref.set_task(task) return HttpResponseRedirect( reverse( ProductImportStatusView.urlname, args=[domain, file_ref.download_id] ) )
def post(self, request, *args, **kwargs): upload = request.FILES.get('bulk_upload_file') if not upload: messages.error(request, _('no file uploaded')) return self.get(request, *args, **kwargs) elif not upload.name.endswith('.xlsx'): messages.error(request, _('please use xlsx format only')) return self.get(request, *args, **kwargs) domain = args[0] # stash this in soil to make it easier to pass to celery file_ref = expose_cached_download( upload.read(), expiry=1*60*60, file_extension=file_extention_from_filename(upload.name) ) task = import_products_async.delay( domain, file_ref.download_id, ) file_ref.set_task(task) return HttpResponseRedirect( reverse( ProductImportStatusView.urlname, args=[domain, file_ref.download_id] ) )