Skip to content

Fix backup restore and log admin regressions - #85

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-6a18
Draft

Fix backup restore and log admin regressions#85
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-6a18

Conversation

@cursor

@cursor cursor Bot commented Jul 6, 2026

Copy link
Copy Markdown

Bug and impact

  • Backup restore UI could not complete because the template submitted fields the active view did not accept and rendered missing backup details.
  • Backup delete and log view/delete admin paths could 500 due to missing templates, and backup delete was wired from the list as a GET navigation.
  • Log download/delete failed because admin LogEntry audit rows used invalid content_type_id=0.
  • Restoring media could wipe/partially replace MEDIA_ROOT after the DB restore had already committed if media copy failed, leaving DB and files inconsistent.

Root cause

The refactored active inventory/views/system/* views drifted from their templates and audit logging used an invalid FK sentinel. Media restore performed destructive filesystem changes after committing the database restore.

Fix

  • Aligned restore template/view confirmation fields and backup context usage.
  • Added missing backup/log confirmation/view templates and wired list actions to real POST/CSRF or confirmation flows.
  • Changed custom admin log entries to nullable content type IDs.
  • Staged backup media before DB changes, backed up current media, replaced media inside the DB transaction, and restored old media/re-raised on copy failure so the DB rolls back.

Validation

  • python manage.py test inventory.tests.test_views.BackupViewSecurityTest inventory.tests.test_views.LogFileViewTest (9 tests OK; only existing staticfiles warning and expected simulated media failure log)
  • python manage.py test inventory.tests.test_sale_status inventory.tests.test_sales_balance_payment inventory.tests.test_services.MemberServiceTest && python manage.py check (11 tests OK; only existing staticfiles warning)
Open in Web View Automation 

Co-authored-by: Xianist Lab <zhtyyx@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant