mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-08-28 05:33:24 +00:00
Docs: remove stale drf-writable-nested references, DRY up audit-actor update()
Final-review cleanup on refactor/remove-drf-writable-nested: several comments/docstrings still described drf-writable-nested's removed NestedUpdateMixin behavior in the present tense. Rewrote them to explain the shared context-cache and delete-query-count guarantees in terms of the current code (bulk-edit's per-field CustomFieldInstanceSerializer construction, and _sync_custom_fields' single hard-delete query). Also collapsed the duplicated `if custom_fields_data is not None: self._sync_custom_fields(...)` line in DocumentSerializer.update()'s audit-log branches into a single code path using contextlib.nullcontext(), removing the drift risk that caused the earlier audit-actor bug. No behavior change.
This commit is contained in:
@@ -592,9 +592,10 @@ class TestCustomFieldsAPI(DirectoriesMixin, APITestCase):
|
||||
WHEN:
|
||||
- A second, separately-instantiated CustomFieldInstanceSerializer
|
||||
validates the same field id, sharing that same context
|
||||
(this is what drf-writable-nested does: it rebuilds a fresh
|
||||
serializer -- and fresh field instances -- per item while
|
||||
matching existing vs. new instances during save())
|
||||
(this mirrors what real call sites do, e.g. bulk-edit's
|
||||
validate_custom_fields()/_validate_custom_field_values()
|
||||
constructing a fresh CustomFieldInstanceSerializer per
|
||||
submitted field, all sharing the outer serializer's context)
|
||||
THEN:
|
||||
- No additional query is issued to resolve the CustomField
|
||||
"""
|
||||
@@ -1560,12 +1561,10 @@ class TestCustomFieldsAPI(DirectoriesMixin, APITestCase):
|
||||
- A PATCH request updates 2 of them, adds 1 new one, and omits
|
||||
the 3rd (which should be deleted)
|
||||
THEN:
|
||||
- The number of queries used to create/update/delete the
|
||||
CustomFieldInstance rows is bounded and does not scale with
|
||||
drf-writable-nested's per-item serializer-rebuild + separate
|
||||
soft-delete-then-hard-delete-after pattern (one query per
|
||||
CustomFieldInstance write via update_or_create, plus exactly
|
||||
one final hard-delete query -- not two delete passes)
|
||||
- The omitted custom field is removed via exactly one
|
||||
delete-shaped query, not drf-writable-nested's old two-step
|
||||
soft-delete-then-hard-delete-after pattern (two delete
|
||||
passes)
|
||||
"""
|
||||
doc = Document.objects.create(
|
||||
title="WOW",
|
||||
|
||||
Reference in New Issue
Block a user