-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
call core api delete from django delete #406
Conversation
django_app/tests/test_views.py
Outdated
@@ -195,7 +238,6 @@ def test_post_message_to_new_session(alice: User, client: Client, requests_mock: | |||
assert response.status_code == HTTPStatus.FOUND | |||
assert "Location" in response.headers | |||
session_id = URL(response.url).parts[-2] | |||
assert ChatMessage.objects.get(chat_history__id=session_id, role=ChatRoleEnum.user).text == "Are you there?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm not sure why this got deleted - will fix on Monday
if request.method == "POST": | ||
logger.info("Removing document: %s", request.POST["doc_id"]) | ||
file.delete() | ||
api = CoreApiClient(host=settings.CORE_API_HOST, port=settings.CORE_API_PORT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be declared just once, maybe as a constant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ultimately I'd like to inject it.
f5d9a17
to
d61ce14
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, could we change the file deletion setting to seconds instead of days for future proofing please?
@@ -64,6 +69,7 @@ class File(UUIDPrimaryKeyBase, TimeStampedModel): | |||
user = models.ForeignKey(User, on_delete=models.CASCADE) | |||
original_file_name = models.TextField(max_length=2048, blank=True, null=True) | |||
core_file_uuid = models.UUIDField(null=True) | |||
expiry_date = models.DateField(default=get_default_expiry_date) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either:
- this needs to be nullable or we will get an error on migration, or
- we could compute this field on the fly from the
created_at: datetime
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm something went wrong changing branch - that should be from a different ticket.
@@ -24,6 +24,7 @@ | |||
from yarl import URL | |||
|
|||
logger = logging.getLogger(__name__) | |||
core_api = CoreApiClient(host=settings.CORE_API_HOST, port=settings.CORE_API_PORT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one RFC, otherwise LGTM
5c7a991
to
09b9eab
Compare
Context
Currently the frontend deletion of a file only deletes the file from the Django and S3 storage, but not the Elastic storage.
Changes proposed in this pull request
Deleting a file from the user interface propagates a call to core-api to delete the file and its chunks. If that API request fails, then the file will not delete from the Django database.
If the call to the API fails, the user will see this view:
![Screenshot 2024-05-20 at 12 31 30](https://private-user-images.githubusercontent.com/23265724/332051269-0887b6ea-a20c-4b26-95a2-f74395b8b96a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1NjY2MzQsIm5iZiI6MTczOTU2NjMzNCwicGF0aCI6Ii8yMzI2NTcyNC8zMzIwNTEyNjktMDg4N2I2ZWEtYTIwYy00YjI2LTk1YTItZjc0Mzk1YjhiOTZhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDIwNTIxNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTEyMWI2NTI1MDhkOGRlYmJiNmYwZWM4ZGUxNjZlYzZjZmM2MmIxNjQ3YjI3MTNkYTcxNzA5M2QyMGE3YjczMmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.8Mt6pWQKUCE6mBP-7UUAZD4NXZhoNai4HBELs9Za9cQ)
Guidance to review
Try deleting files from django.
Relevant links
https://technologyprogramme.atlassian.net/browse/REDBOX-256
Things to check
[ ] I have added any new ENV vars in all deployed environments