mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-20 20:46:53 +00:00
Fix: read zones before the consume transaction and write them before workflows
Zone OCR ran inside the consume transaction, read the working copy instead of the archive, and ran after the document added workflows. Zones are now read from the archive before the transaction and written just before those workflows, keeping values supplied at consume time.
This commit is contained in:
1 parent
54be9dc9c5
commit
a6b81b2d64
9 files changed
+1112
-164
No files matched your search
@@ -52,6 +52,7 @@ from documents.zone_ocr import _render_pages
|
||||
from documents.zone_ocr import _resolve_doc_path
|
||||
from documents.zone_ocr import _zone_language
|
||||
from documents.zone_ocr import extract_zone_preview
|
||||
from documents.zone_ocr import get_templates_for_content
|
||||
from documents.zone_ocr import get_templates_for_document
|
||||
from documents.zone_ocr import run_zone_extraction
|
||||
from paperless_testing.factories import CustomFieldFactory
|
||||
@@ -1707,6 +1708,39 @@ class TestTemplateVisibility:
|
||||
get_templates_for_document(document, requester=other),
|
||||
) == Counter([unowned, private])
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("has_owner", "expected_names"),
|
||||
[
|
||||
pytest.param(True, {"Mine", "Unowned"}, id="owner"),
|
||||
pytest.param(False, {"Mine", "Unowned", "Private"}, id="no-owner"),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures("mine", "unowned", "private")
|
||||
def test_content_selection_follows_the_owner_rule(
|
||||
self,
|
||||
owner: User,
|
||||
has_owner: bool, # noqa: FBT001
|
||||
expected_names: set[str],
|
||||
) -> None:
|
||||
"""
|
||||
GIVEN:
|
||||
- Templates owned by two users and an unowned template, all
|
||||
matching "Northwind", and one matching only other text
|
||||
WHEN:
|
||||
- Templates are selected for unsaved text, with or without an owner
|
||||
THEN:
|
||||
- Only matching templates apply
|
||||
- An owner sees owned and unowned templates, no owner sees all
|
||||
"""
|
||||
make_visible_template("Other sender", match="Contoso")
|
||||
|
||||
templates = get_templates_for_content(
|
||||
"Northwind Power & Light statement",
|
||||
owner if has_owner else None,
|
||||
)
|
||||
|
||||
assert {template.name for template in templates} == expected_names
|
||||
|
||||
@pytest.mark.usefixtures("private")
|
||||
def test_versions_use_the_root_documents_owner(
|
||||
self,
|
||||
|
||||
Reference in new issue
Block a user