mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-13 01:57:08 +01:00
Resolved merge conflicts in: - src/documents/ai_deletion_manager.py: Kept webhook integration alongside dev changes - src/documents/ai_scanner.py: Kept webhook integration and applied_fields tracking - src/documents/models.py: Integrated AISuggestionFeedback model with webhook imports All conflicts resolved maintaining both webhook functionality and new AI suggestions features from dev branch. Co-authored-by: dawnsystem <42047891+dawnsystem@users.noreply.github.com>
148 lines
5.1 KiB
Python
148 lines
5.1 KiB
Python
# Generated manually for DeletionRequest model
|
|
# Based on model definition in documents/models.py
|
|
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
"""
|
|
Add DeletionRequest model for AI-initiated deletion requests.
|
|
|
|
This model tracks deletion requests that require user approval,
|
|
implementing the safety requirement from agents.md to ensure
|
|
no documents are deleted without explicit user consent.
|
|
"""
|
|
|
|
dependencies = [
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
("documents", "1075_add_performance_indexes"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name="DeletionRequest",
|
|
fields=[
|
|
(
|
|
"id",
|
|
models.BigAutoField(
|
|
auto_created=True,
|
|
primary_key=True,
|
|
serialize=False,
|
|
verbose_name="ID",
|
|
),
|
|
),
|
|
(
|
|
"created_at",
|
|
models.DateTimeField(auto_now_add=True),
|
|
),
|
|
(
|
|
"updated_at",
|
|
models.DateTimeField(auto_now=True),
|
|
),
|
|
(
|
|
"requested_by_ai",
|
|
models.BooleanField(default=True),
|
|
),
|
|
(
|
|
"ai_reason",
|
|
models.TextField(
|
|
help_text="Detailed explanation from AI about why deletion is recommended"
|
|
),
|
|
),
|
|
(
|
|
"status",
|
|
models.CharField(
|
|
choices=[
|
|
("pending", "Pending"),
|
|
("approved", "Approved"),
|
|
("rejected", "Rejected"),
|
|
("cancelled", "Cancelled"),
|
|
("completed", "Completed"),
|
|
],
|
|
default="pending",
|
|
max_length=20,
|
|
),
|
|
),
|
|
(
|
|
"impact_summary",
|
|
models.JSONField(
|
|
default=dict,
|
|
help_text="Summary of what will be affected by this deletion",
|
|
),
|
|
),
|
|
(
|
|
"reviewed_at",
|
|
models.DateTimeField(blank=True, null=True),
|
|
),
|
|
(
|
|
"review_comment",
|
|
models.TextField(
|
|
blank=True,
|
|
help_text="User's comment when reviewing",
|
|
),
|
|
),
|
|
(
|
|
"completed_at",
|
|
models.DateTimeField(blank=True, null=True),
|
|
),
|
|
(
|
|
"completion_details",
|
|
models.JSONField(
|
|
default=dict,
|
|
help_text="Details about the deletion execution",
|
|
),
|
|
),
|
|
(
|
|
"documents",
|
|
models.ManyToManyField(
|
|
help_text="Documents that would be deleted if approved",
|
|
related_name="deletion_requests",
|
|
to="documents.document",
|
|
),
|
|
),
|
|
(
|
|
"reviewed_by",
|
|
models.ForeignKey(
|
|
blank=True,
|
|
help_text="User who reviewed and approved/rejected",
|
|
null=True,
|
|
on_delete=django.db.models.deletion.SET_NULL,
|
|
related_name="reviewed_deletion_requests",
|
|
to=settings.AUTH_USER_MODEL,
|
|
),
|
|
),
|
|
(
|
|
"user",
|
|
models.ForeignKey(
|
|
help_text="User who must approve this deletion",
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
related_name="deletion_requests",
|
|
to=settings.AUTH_USER_MODEL,
|
|
),
|
|
),
|
|
],
|
|
options={
|
|
"verbose_name": "deletion request",
|
|
"verbose_name_plural": "deletion requests",
|
|
"ordering": ["-created_at"],
|
|
},
|
|
),
|
|
# Add composite index for status + user (common query pattern)
|
|
migrations.AddIndex(
|
|
model_name="deletionrequest",
|
|
index=models.Index(
|
|
fields=["status", "user"],
|
|
name="del_req_status_user_idx",
|
|
),
|
|
),
|
|
# Add index for created_at (for chronological queries)
|
|
migrations.AddIndex(
|
|
model_name="deletionrequest",
|
|
index=models.Index(
|
|
fields=["created_at"],
|
|
name="del_req_created_idx",
|
|
),
|
|
),
|
|
]
|