Commit 656a7c39 authored by Gladys Forte's avatar Gladys Forte

Merge pull request #482 in RMS/api-main-service from gladys-dev2 to RMSv2

* commit 'bd9cdc40':
  remove media file
parents 4a2b9606 bd9cdc40
...@@ -15,6 +15,7 @@ from rest_framework.exceptions import ParseError ...@@ -15,6 +15,7 @@ from rest_framework.exceptions import ParseError
from django.db import IntegrityError from django.db import IntegrityError
from rest_framework.exceptions import APIException from rest_framework.exceptions import APIException
from django.db.models import Max from django.db.models import Max
import os
CR_FRONT_LINK = settings.CR_FRONT_LINK CR_FRONT_LINK = settings.CR_FRONT_LINK
...@@ -502,7 +503,13 @@ def crhistory_log_bulk_delete_masterattach(queryset, entity, tbl, form_code, ...@@ -502,7 +503,13 @@ def crhistory_log_bulk_delete_masterattach(queryset, entity, tbl, form_code,
print(r['url']) print(r['url'])
print(settings.MEDIA_ROOT) print(settings.MEDIA_ROOT)
# os.remove(os.path.join(settings.MEDIA_ROOT, self.url.name)) # os.remove(r['url'])
if os.path.exists(r['url']):
os.remove(r['url'])
else:
print("The file does not exist")
return True return True
except IntegrityError as exc: except IntegrityError as exc:
raise APIException(detail=exc) raise APIException(detail=exc)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment