Added delete all in dropbox service and iot client help command

This commit is contained in:
Martin Schett
2020-12-06 18:24:07 +01:00
parent ce34ce8562
commit ddf0cbf2d7
3 changed files with 34 additions and 2 deletions
+18 -2
View File
@@ -109,19 +109,35 @@ class ImageEndpoint:
def image_api_delete(request: HttpRequest, identifier):
logger.debug('Image DELETE single call: {}'.format(request))
result_bool = True
# get metadata from MongoDB
metadata = MongoDBService.getSingle(identifier)
if not metadata:
return JsonResponse({'Result': 'Error - could not find any metadata in mongoDB.',
'id': identifier}, status=404, safe=False)
resp = MongoDBService.deleteSingle(identifier)
print(resp)
return JsonResponse({'Result': 'success1'}, safe=False)
if not DropboxService.delete_file(metadata['filename']):
print('Error deleting file in dropbox')
result_bool = False
return JsonResponse({'Result': result_bool}, safe=False)
@staticmethod
@api_view(['DELETE'])
def image_api_delete_all(request: HttpRequest):
logger.debug('Image DELETE single call: {}'.format(request))
result_bool = True
resp = MongoDBService.deleteAll()
print(resp)
return JsonResponse({'Result': 'success1'}, safe=False)
if not DropboxService.delete_all():
print('Error deleting dropbox folder')
result_bool = False
return JsonResponse({'Result': result_bool}, safe=False)