mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-13 03:27:13 +00:00
* Feature: store barcode contents, list and search them New setting PAPERLESS_CONSUMER_STORE_BARCODE_VALUES (off by default) stores all barcodes found during consumption with the document: page, type and content. They are listed on the metadata tab with a copy button, returned by the documents API and searchable with barcodes: in the advanced search. Versions keep their own barcodes, reprocessing reads them again. Refs #9898 * Tests: cover the remaining barcode branches Covers unchanged and failing barcode reads on reprocessing, unsupported files and DocumentBarcode.__str__, and uses toHaveLength in the barcode list spec as suggested by SonarCloud. * Address review: keep barcodes when they can't be read, format choices - Reprocessing and new versions keep the stored barcodes when the file can't be scanned or the scan fails, and replace them atomically. - Format is a TextChoices of the zxing-cpp formats, with a test. - Shared scan code, latest_version helper, TypedDict, serializer reuse. - Barcodes in the split manifest, export/import tests, pytest-style tests. * Barcode tests: TIFF reprocess, format check both ways, fixtures - Reprocessing a TIFF with TIFF support off keeps the stored barcodes. - The format test also fails when zxing-cpp drops a format. - Fixtures in place of the sample dir mixin, plugin-level disabled test. - Format labels aren't translated, OpenAPI enum named BarcodeFormatEnum. * Review: module-level zxing reader, shorter barcode docs - read_barcodes_zxing is a module-level function used by scan_pdf. - Drop the trivial __str__ test, mark it no cover. - Shorten the barcode docs and remove the duplicate in configuration.md. * Fix header * Use utility class * Return barcodes from the metadata endpoint only Drop the barcodes field and its prefetches from the document serializer, as agreed in the review. Also remove the now empty component stylesheet. --------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
48 lines
2.0 KiB
Python
48 lines
2.0 KiB
Python
from __future__ import annotations
|
|
|
|
from whoosh_compat import FieldKind
|
|
from whoosh_compat import FieldSpec
|
|
from whoosh_compat import SubpathSpec
|
|
|
|
# Internal-only schema fields with no query-syntax meaning of their own
|
|
# (sort shadow fields, bigram CJK fields, simple_title/simple_content,
|
|
# autocomplete_word, notes_text) are NOT represented here, they are
|
|
# declared in _schema.py's field_descriptors().
|
|
#
|
|
# analyzer/pattern_normalizer are deliberately left at FieldSpec's default
|
|
# (None): they're language-specific and only meaningful to whoosh-compat's
|
|
# parser, so _registry.py attaches them per-language via dataclasses.replace()
|
|
# rather than PUBLIC_FIELDS declaring them itself. _schema.py only reads
|
|
# name/kind/fast and never sees the analyzer at all.
|
|
PUBLIC_FIELDS: tuple[FieldSpec, ...] = (
|
|
FieldSpec("title", FieldKind.TEXT),
|
|
FieldSpec("content", FieldKind.TEXT),
|
|
FieldSpec("correspondent", FieldKind.TEXT),
|
|
FieldSpec("document_type", FieldKind.TEXT, aliases=("type",)),
|
|
FieldSpec("storage_path", FieldKind.TEXT, aliases=("path",)),
|
|
FieldSpec("original_filename", FieldKind.TEXT),
|
|
FieldSpec("tag", FieldKind.TEXT, comma_values=True),
|
|
FieldSpec("checksum", FieldKind.KEYWORD),
|
|
FieldSpec("asn", FieldKind.U64, fast=True),
|
|
FieldSpec("page_count", FieldKind.U64, fast=True),
|
|
FieldSpec("num_notes", FieldKind.U64, fast=True),
|
|
FieldSpec("created", FieldKind.DATE, date_only=True, fast=True),
|
|
FieldSpec("modified", FieldKind.DATETIME, fast=True),
|
|
FieldSpec("added", FieldKind.DATETIME, fast=True),
|
|
FieldSpec(
|
|
"notes",
|
|
FieldKind.JSON,
|
|
subpaths={"user": SubpathSpec(), "note": SubpathSpec(default=True)},
|
|
),
|
|
FieldSpec(
|
|
"custom_fields",
|
|
FieldKind.JSON,
|
|
subpaths={"name": SubpathSpec(), "value": SubpathSpec(default=True)},
|
|
),
|
|
FieldSpec(
|
|
"barcodes",
|
|
FieldKind.JSON,
|
|
subpaths={"value": SubpathSpec(default=True), "format": SubpathSpec()},
|
|
),
|
|
)
|