feat!: drop skip_archive_file field, add archive_file_generation to ApplicationConfiguration

Replace the old skip_archive_file DB field with the correctly-named
archive_file_generation field on ApplicationConfiguration. Remove the
temporary getattr fallback in OcrConfig now that the migration exists.
Update all test fixtures and API response assertions to use the new field name.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Trenton H
2026-03-26 13:39:49 -07:00
parent a53144ef8d
commit 6658d94f77
6 changed files with 51 additions and 14 deletions

View File

@@ -46,7 +46,7 @@ class TestApiAppConfig(DirectoriesMixin, APITestCase):
"pages": None,
"language": None,
"mode": None,
"skip_archive_file": None,
"archive_file_generation": None,
"image_dpi": None,
"unpaper_clean": None,
"deskew": None,

View File

@@ -64,14 +64,9 @@ class OcrConfig(OutputTypeConfig):
self.pages = app_config.pages or settings.OCR_PAGES
self.language = app_config.language or settings.OCR_LANGUAGE
self.mode = app_config.mode or settings.OCR_MODE
# Task 4 renames the DB field from skip_archive_file to archive_file_generation.
# Until that migration runs, fall back to the old field name.
_db_archive = getattr(
app_config,
"archive_file_generation",
None,
) or getattr(app_config, "skip_archive_file", None)
self.archive_file_generation = _db_archive or settings.ARCHIVE_FILE_GENERATION
self.archive_file_generation = (
app_config.archive_file_generation or settings.ARCHIVE_FILE_GENERATION
)
self.image_dpi = app_config.image_dpi or settings.OCR_IMAGE_DPI
self.clean = app_config.unpaper_clean or settings.OCR_CLEAN
self.deskew = (

View File

@@ -0,0 +1,44 @@
# Generated by Django 5.2.12 on 2026-03-26 20:31
from django.db import migrations
from django.db import models
class Migration(migrations.Migration):
dependencies = [
("paperless", "0007_optimize_integer_field_sizes"),
]
operations = [
migrations.RemoveField(
model_name="applicationconfiguration",
name="skip_archive_file",
),
migrations.AddField(
model_name="applicationconfiguration",
name="archive_file_generation",
field=models.CharField(
blank=True,
choices=[("auto", "auto"), ("always", "always"), ("never", "never")],
max_length=8,
null=True,
verbose_name="Controls archive file generation",
),
),
migrations.AlterField(
model_name="applicationconfiguration",
name="mode",
field=models.CharField(
blank=True,
choices=[
("auto", "auto"),
("force", "force"),
("redo", "redo"),
("off", "off"),
],
max_length=16,
null=True,
verbose_name="Sets the OCR mode",
),
),
]

View File

@@ -126,11 +126,11 @@ class ApplicationConfiguration(AbstractSingletonModel):
choices=ModeChoices.choices,
)
skip_archive_file = models.CharField(
verbose_name=_("Controls the generation of an archive file"),
archive_file_generation = models.CharField(
verbose_name=_("Controls archive file generation"),
null=True,
blank=True,
max_length=16,
max_length=8,
choices=ArchiveFileGenerationChoices.choices,
)

View File

@@ -709,7 +709,6 @@ def null_app_config(mocker: MockerFixture) -> MagicMock:
language=None,
mode=None,
archive_file_generation=None,
skip_archive_file=None,
image_dpi=None,
unpaper_clean=None,
deskew=None,

View File

@@ -22,7 +22,6 @@ def null_app_config(mocker) -> MagicMock:
language=None,
mode=None,
archive_file_generation=None,
skip_archive_file=None,
image_dpi=None,
unpaper_clean=None,
deskew=None,