Skip to content

Complete Allow the user to delete the rules file from the downloads#1219

Draft
brian-kim31 wants to merge 12 commits into
mainfrom
rules_delete
Draft

Complete Allow the user to delete the rules file from the downloads#1219
brian-kim31 wants to merge 12 commits into
mainfrom
rules_delete

Conversation

@brian-kim31
Copy link
Copy Markdown
Contributor

✨ Feature

PR Description

The purpose of this PR is to let users clean up their downloads by deleting rules files they no longer need. When someone deletes a file, we remove it from storage to save space, but keep a record in the database so we can track what was generated and when it was deleted. We also automatically hide files older than 30 days to keep the downloads page tidy (you can change this with the FILE_RETENTION_DAYS setting).

Related Issues or other material

Related #856
Closes #856

Screenshots, example outputs/behaviour etc.

Screenshot 2025-10-08 at 18 03 43 Screenshot 2025-10-08 at 18 03 54 Screenshot 2025-10-08 at 18 11 09

Comment thread app/api/files/models.py
Comment thread app/api/files/views.py Outdated
Comment thread app/next-client-app/api/files.ts Outdated
Comment thread docker-compose.yml Outdated
Comment thread app/next-client-app/components/files/DeleteFileDialog.tsx Outdated
Comment thread app/api/files/models.py
deleted_at = models.DateTimeField(null=True, blank=True)
deleted_by = models.ForeignKey(
settings.AUTH_USER_MODEL,
on_delete=models.SET_NULL,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to decide the behaviour when the associated user is deleted: either keeping the file for record (as you did here) or deleting the associated files as well (as @AndyRae did in line 54)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the above is about the case when the associated users are deleted. Anyway, we can come back to this later when Andy comes back (I don't think this is a blocker for other PRs), or you can decide as the PR author. I just want the deleting behaviour to be consistent.

Comment thread docker-compose.yml Outdated
<DialogHeader className="text-start">
<DialogTitle>Delete File</DialogTitle>
</DialogHeader>
<p className="text-sm text-muted-foreground">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please show me how it looks if we have text-sm text-muted-foreground? I can't check it. Just want to make sure the text look okay and clear in dark and light mode.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndrewThien Here is how it looks. I think it's clear enough to read. What do you think?

Screenshot 2025-10-10 at 10 31 09 Screenshot 2025-10-10 at 10 31 22

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't put the text-muted-foreground here, cause it is the main question
Screenshot 2025-10-10 at 10 55 41

Comment thread app/next-client-app/components/files/FileDownloadsTable.tsx
Comment thread app/api/files/views.py Outdated
get_queryset():
Retrieves the queryset of FileDownload objects filtered by the scan report ID.
Retrieves the queryset of FileDownload objects filtered by the scan report ID
and age (files older than OLD_FILE_THRESHOLD are excluded).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not longger correct

@AndyRae AndyRae removed this from Carrot Backlog Nov 18, 2025
@brian-kim31 brian-kim31 marked this pull request as draft February 3, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow the user to delete the rules file from the downloads

3 participants