mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-10-07 16:47: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>
103 lines
4.2 KiB
Python
103 lines
4.2 KiB
Python
# Generated by Django 5.2.16 on 2026-09-30 23:01
|
|
|
|
import django.db.models.deletion
|
|
from django.db import migrations
|
|
from django.db import models
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
dependencies = [
|
|
("documents", "0026_alter_document_archive_checksum_and_more"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name="DocumentBarcode",
|
|
fields=[
|
|
(
|
|
"id",
|
|
models.AutoField(
|
|
auto_created=True,
|
|
primary_key=True,
|
|
serialize=False,
|
|
verbose_name="ID",
|
|
),
|
|
),
|
|
(
|
|
"page",
|
|
models.PositiveIntegerField(
|
|
help_text="Page of the original file, starting at 1",
|
|
verbose_name="page",
|
|
),
|
|
),
|
|
("value", models.TextField(verbose_name="value")),
|
|
(
|
|
"format",
|
|
models.CharField(
|
|
choices=[
|
|
("Codabar", "Codabar"),
|
|
("Code39", "Code 39"),
|
|
("Code39Std", "Code 39 Standard"),
|
|
("Code39Ext", "Code 39 Extended"),
|
|
("Code32", "Code 32"),
|
|
("PZN", "Pharmazentralnummer"),
|
|
("Code93", "Code 93"),
|
|
("Code128", "Code 128"),
|
|
("ITF", "ITF"),
|
|
("ITF14", "ITF-14"),
|
|
("DataBar", "DataBar"),
|
|
("DataBarOmni", "DataBar Omni"),
|
|
("DataBarStk", "DataBar Stacked"),
|
|
("DataBarStkOmni", "DataBar Stacked Omni"),
|
|
("DataBarLtd", "DataBar Limited"),
|
|
("DataBarExp", "DataBar Expanded"),
|
|
("DataBarExpStk", "DataBar Expanded Stacked"),
|
|
("EANUPC", "EAN/UPC"),
|
|
("EAN13", "EAN-13"),
|
|
("EAN8", "EAN-8"),
|
|
("EAN5", "EAN-5"),
|
|
("EAN2", "EAN-2"),
|
|
("ISBN", "ISBN"),
|
|
("UPCA", "UPC-A"),
|
|
("UPCE", "UPC-E"),
|
|
("Telepen", "Telepen"),
|
|
("TelepenAlpha", "Telepen Alpha"),
|
|
("TelepenNumeric", "Telepen Numeric"),
|
|
("OtherBarcode", "Other barcode"),
|
|
("DXFilmEdge", "DX Film Edge"),
|
|
("PDF417", "PDF417"),
|
|
("CompactPDF417", "Compact PDF417"),
|
|
("MicroPDF417", "MicroPDF417"),
|
|
("Aztec", "Aztec"),
|
|
("AztecCode", "Aztec Code"),
|
|
("AztecRune", "Aztec Rune"),
|
|
("QRCode", "QR Code"),
|
|
("QRCodeModel1", "QR Code Model 1"),
|
|
("QRCodeModel2", "QR Code Model 2"),
|
|
("MicroQRCode", "Micro QR Code"),
|
|
("RMQRCode", "rMQR Code"),
|
|
("DataMatrix", "Data Matrix"),
|
|
("MaxiCode", "MaxiCode"),
|
|
],
|
|
max_length=32,
|
|
verbose_name="format",
|
|
),
|
|
),
|
|
(
|
|
"document",
|
|
models.ForeignKey(
|
|
on_delete=django.db.models.deletion.CASCADE,
|
|
related_name="barcodes",
|
|
to="documents.document",
|
|
verbose_name="document",
|
|
),
|
|
),
|
|
],
|
|
options={
|
|
"verbose_name": "document barcode",
|
|
"verbose_name_plural": "document barcodes",
|
|
"ordering": ("page", "id"),
|
|
},
|
|
),
|
|
]
|