-
+
diff --git a/src-ui/src/app/components/common/input/number/number.component.spec.ts b/src-ui/src/app/components/common/input/number/number.component.spec.ts
index b6a281e6fb..889aa21983 100644
--- a/src-ui/src/app/components/common/input/number/number.component.spec.ts
+++ b/src-ui/src/app/components/common/input/number/number.component.spec.ts
@@ -56,7 +56,7 @@ describe('NumberComponent', () => {
component.step = 0.1
component.writeValue(12.3456)
expect(component.value).toEqual(12.3456)
- // float (step = .1) doesnt force 2 decimals
+ // float (step = .1) doesn't force 2 decimals
component.writeValue(11.1)
expect(component.value).toEqual(11.1)
})
diff --git a/src-ui/src/app/components/common/input/password/password.component.spec.ts b/src-ui/src/app/components/common/input/password/password.component.spec.ts
index 1788104a6e..34999e618e 100644
--- a/src-ui/src/app/components/common/input/password/password.component.spec.ts
+++ b/src-ui/src/app/components/common/input/password/password.component.spec.ts
@@ -28,7 +28,7 @@ describe('PasswordComponent', () => {
it('should support use of input field', () => {
expect(component.value).toBeUndefined()
- // TODO: why doesnt this work?
+ // TODO: why doesn't this work?
// input.value = 'foo'
// input.dispatchEvent(new Event('change'))
// fixture.detectChanges()
diff --git a/src-ui/src/app/components/common/input/switch/switch.component.html b/src-ui/src/app/components/common/input/switch/switch.component.html
index 189aa937ff..e0b63c5f7a 100644
--- a/src-ui/src/app/components/common/input/switch/switch.component.html
+++ b/src-ui/src/app/components/common/input/switch/switch.component.html
@@ -2,7 +2,14 @@
@if (!horizontal) {
-
+
@if (removable) {
+
+
+
+ Note: value has not yet been set and will not apply until explicitly changed
+
diff --git a/src-ui/src/app/components/common/input/switch/switch.component.spec.ts b/src-ui/src/app/components/common/input/switch/switch.component.spec.ts
index 08a4598a34..372bfd8abf 100644
--- a/src-ui/src/app/components/common/input/switch/switch.component.spec.ts
+++ b/src-ui/src/app/components/common/input/switch/switch.component.spec.ts
@@ -5,6 +5,7 @@ import {
NG_VALUE_ACCESSOR,
ReactiveFormsModule,
} from '@angular/forms'
+import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap'
describe('SwitchComponent', () => {
let component: SwitchComponent
@@ -15,7 +16,7 @@ describe('SwitchComponent', () => {
TestBed.configureTestingModule({
declarations: [SwitchComponent],
providers: [],
- imports: [FormsModule, ReactiveFormsModule],
+ imports: [FormsModule, ReactiveFormsModule, NgbTooltipModule],
}).compileComponents()
fixture = TestBed.createComponent(SwitchComponent)
@@ -36,4 +37,9 @@ describe('SwitchComponent', () => {
fixture.detectChanges()
expect(component.value).toBeFalsy()
})
+
+ it('should show note if unset', () => {
+ component.value = null
+ expect(component.isUnset).toBeTruthy()
+ })
})
diff --git a/src-ui/src/app/components/common/input/switch/switch.component.ts b/src-ui/src/app/components/common/input/switch/switch.component.ts
index 44e095baac..312c98936f 100644
--- a/src-ui/src/app/components/common/input/switch/switch.component.ts
+++ b/src-ui/src/app/components/common/input/switch/switch.component.ts
@@ -1,4 +1,4 @@
-import { Component, forwardRef } from '@angular/core'
+import { Component, Input, forwardRef } from '@angular/core'
import { NG_VALUE_ACCESSOR } from '@angular/forms'
import { AbstractInputComponent } from '../abstract-input'
@@ -15,7 +15,14 @@ import { AbstractInputComponent } from '../abstract-input'
styleUrls: ['./switch.component.scss'],
})
export class SwitchComponent extends AbstractInputComponent
{
+ @Input()
+ showUnsetNote: boolean = false
+
constructor() {
super()
}
+
+ get isUnset(): boolean {
+ return this.value === null || this.value === undefined
+ }
}
diff --git a/src-ui/src/app/components/common/input/text/text.component.spec.ts b/src-ui/src/app/components/common/input/text/text.component.spec.ts
index 4b0a13bc3e..3b8e76e537 100644
--- a/src-ui/src/app/components/common/input/text/text.component.spec.ts
+++ b/src-ui/src/app/components/common/input/text/text.component.spec.ts
@@ -27,7 +27,7 @@ describe('TextComponent', () => {
it('should support use of input field', () => {
expect(component.value).toBeUndefined()
- // TODO: why doesnt this work?
+ // TODO: why doesn't this work?
// input.value = 'foo'
// input.dispatchEvent(new Event('change'))
// fixture.detectChanges()
diff --git a/src-ui/src/app/components/common/input/url/url.component.spec.ts b/src-ui/src/app/components/common/input/url/url.component.spec.ts
index 33eb96ec58..a0205d7eb9 100644
--- a/src-ui/src/app/components/common/input/url/url.component.spec.ts
+++ b/src-ui/src/app/components/common/input/url/url.component.spec.ts
@@ -27,7 +27,7 @@ describe('TextComponent', () => {
it('should support use of input field', () => {
expect(component.value).toBeUndefined()
- // TODO: why doesnt this work?
+ // TODO: why doesn't this work?
// input.value = 'foo'
// input.dispatchEvent(new Event('change'))
// fixture.detectChanges()
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts
index 388baf70ab..d37fa852a0 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.spec.ts
+++ b/src-ui/src/app/components/document-detail/document-detail.component.spec.ts
@@ -303,7 +303,7 @@ describe('DocumentDetailComponent', () => {
discardPeriodicTasks()
}))
- it('should update title before doc change if wasnt updated via debounce', fakeAsync(() => {
+ it('should update title before doc change if was not updated via debounce', fakeAsync(() => {
initNormally()
component.titleInput.value = 'Foo Bar'
component.titleInput.inputField.nativeElement.dispatchEvent(
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts
index 1e7865f847..edc19ec70f 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.ts
+++ b/src-ui/src/app/components/document-detail/document-detail.component.ts
@@ -157,7 +157,7 @@ export class DocumentDetailComponent
@ViewChild('nav') nav: NgbNav
@ViewChild('pdfPreview') set pdfPreview(element) {
- // this gets called when compontent added or removed from DOM
+ // this gets called when component added or removed from DOM
if (
element &&
element.nativeElement.offsetParent !== null &&
@@ -316,7 +316,7 @@ export class DocumentDetailComponent
.subscribe({
next: (titleValue) => {
// In the rare case when the field changed just after debounced event was fired.
- // We dont want to overwrite whats actually in the text field, so just return
+ // We dont want to overwrite what's actually in the text field, so just return
if (titleValue !== this.titleInput.value) return
this.title = titleValue
diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts
index 1aeccd182d..442114767d 100644
--- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts
+++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts
@@ -82,7 +82,7 @@ export class DocumentCardLargeComponent extends ComponentWithPermissions {
// only show notes with a match
highlights = (this.document['__search_hit__'].note_highlights as string)
.split(',')
- .filter((higlight) => higlight.includes(' highlight.includes(' {
expect(component.textFilterTarget).toEqual('fulltext-morelike') // TEXT_FILTER_TARGET_FULLTEXT_MORELIKE
expect(moreLikeSpy).toHaveBeenCalledWith(1)
expect(component.textFilter).toEqual('Foo Bar')
- // we have to do this here because it cant be done by user input
+ // we have to do this here because it can't be done by user input
expect(component.filterRules).toEqual([
{
rule_type: FILTER_FULLTEXT_MORELIKE,
@@ -1264,7 +1264,7 @@ describe('FilterEditorComponent', () => {
dateCreatedAfter.nativeElement.value = '05/14/2023'
// dateCreatedAfter.triggerEventHandler('change')
- // TODO: why isnt ngModel triggering this on change?
+ // TODO: why isn't ngModel triggering this on change?
component.dateCreatedAfter = '2023-05-14'
fixture.detectChanges()
tick(400)
@@ -1284,7 +1284,7 @@ describe('FilterEditorComponent', () => {
dateCreatedBefore.nativeElement.value = '05/14/2023'
// dateCreatedBefore.triggerEventHandler('change')
- // TODO: why isnt ngModel triggering this on change?
+ // TODO: why isn't ngModel triggering this on change?
component.dateCreatedBefore = '2023-05-14'
fixture.detectChanges()
tick(400)
@@ -1341,7 +1341,7 @@ describe('FilterEditorComponent', () => {
dateAddedAfter.nativeElement.value = '05/14/2023'
// dateAddedAfter.triggerEventHandler('change')
- // TODO: why isnt ngModel triggering this on change?
+ // TODO: why isn't ngModel triggering this on change?
component.dateAddedAfter = '2023-05-14'
fixture.detectChanges()
tick(400)
@@ -1361,7 +1361,7 @@ describe('FilterEditorComponent', () => {
dateAddedBefore.nativeElement.value = '05/14/2023'
// dateAddedBefore.triggerEventHandler('change')
- // TODO: why isnt ngModel triggering this on change?
+ // TODO: why isn't ngModel triggering this on change?
component.dateAddedBefore = '2023-05-14'
fixture.detectChanges()
tick(400)
@@ -1524,7 +1524,7 @@ describe('FilterEditorComponent', () => {
)
ownerToggle.nativeElement.checked = true
// ownerToggle.triggerEventHandler('change')
- // TODO: ngModel isnt doing this here
+ // TODO: ngModel isn't doing this here
component.permissionsSelectionModel.hideUnowned = true
fixture.detectChanges()
expect(component.filterRules).toEqual([
diff --git a/src-ui/src/app/components/document-list/save-view-config-dialog/save-view-config-dialog.component.ts b/src-ui/src/app/components/document-list/save-view-config-dialog/save-view-config-dialog.component.ts
index b079e2a1ee..b7d9a47113 100644
--- a/src-ui/src/app/components/document-list/save-view-config-dialog/save-view-config-dialog.component.ts
+++ b/src-ui/src/app/components/document-list/save-view-config-dialog/save-view-config-dialog.component.ts
@@ -40,7 +40,7 @@ export class SaveViewConfigDialogComponent implements OnInit {
})
ngOnInit(): void {
- // wait to enable close button so it doesnt steal focus from input since its the first clickable element in the DOM
+ // wait to enable close button so it doesn't steal focus from input since its the first clickable element in the DOM
setTimeout(() => {
this.closeEnabled = true
})
diff --git a/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.spec.ts b/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.spec.ts
index d2168d8bd0..59f9160cb9 100644
--- a/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.spec.ts
+++ b/src-ui/src/app/components/manage/correspondent-list/correspondent-list.component.spec.ts
@@ -34,7 +34,7 @@ describe('CorrespondentListComponent', () => {
correspondentsService = TestBed.inject(CorrespondentService)
})
- // Tests are included in management-list.compontent.spec.ts
+ // Tests are included in management-list.component.spec.ts
it('should use correct delete message', () => {
jest.spyOn(correspondentsService, 'listFiltered').mockReturnValue(
diff --git a/src-ui/src/app/components/manage/document-type-list/document-type-list.component.spec.ts b/src-ui/src/app/components/manage/document-type-list/document-type-list.component.spec.ts
index 1642d89b97..ef19e4313e 100644
--- a/src-ui/src/app/components/manage/document-type-list/document-type-list.component.spec.ts
+++ b/src-ui/src/app/components/manage/document-type-list/document-type-list.component.spec.ts
@@ -58,7 +58,7 @@ describe('DocumentTypeListComponent', () => {
fixture.detectChanges()
})
- // Tests are included in management-list.compontent.spec.ts
+ // Tests are included in management-list.component.spec.ts
it('should use correct delete message', () => {
expect(
diff --git a/src-ui/src/app/components/manage/storage-path-list/storage-path-list.component.spec.ts b/src-ui/src/app/components/manage/storage-path-list/storage-path-list.component.spec.ts
index 5571c443dd..6ad0854093 100644
--- a/src-ui/src/app/components/manage/storage-path-list/storage-path-list.component.spec.ts
+++ b/src-ui/src/app/components/manage/storage-path-list/storage-path-list.component.spec.ts
@@ -58,7 +58,7 @@ describe('StoragePathListComponent', () => {
fixture.detectChanges()
})
- // Tests are included in management-list.compontent.spec.ts
+ // Tests are included in management-list.component.spec.ts
it('should use correct delete message', () => {
expect(component.getDeleteMessage({ id: 1, name: 'StoragePath1' })).toEqual(
diff --git a/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts b/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts
index e7be9035ee..5302eb80e5 100644
--- a/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts
+++ b/src-ui/src/app/components/manage/tag-list/tag-list.component.spec.ts
@@ -60,7 +60,7 @@ describe('TagListComponent', () => {
fixture.detectChanges()
})
- // Tests are included in management-list.compontent.spec.ts
+ // Tests are included in management-list.component.spec.ts
it('should use correct delete message', () => {
expect(component.getDeleteMessage({ id: 1, name: 'Tag1' })).toEqual(
diff --git a/src-ui/src/app/components/manage/workflows/workflows.component.ts b/src-ui/src/app/components/manage/workflows/workflows.component.ts
index 2934738887..a80f03577a 100644
--- a/src-ui/src/app/components/manage/workflows/workflows.component.ts
+++ b/src-ui/src/app/components/manage/workflows/workflows.component.ts
@@ -66,7 +66,7 @@ export class WorkflowsComponent
? EditDialogMode.EDIT
: EditDialogMode.CREATE
if (workflow) {
- // quick "deep" clone so original doesnt get modified
+ // quick "deep" clone so original doesn't get modified
const clone = Object.assign({}, workflow)
clone.actions = [...workflow.actions]
clone.triggers = [...workflow.triggers]
diff --git a/src-ui/src/app/data/paperless-config.ts b/src-ui/src/app/data/paperless-config.ts
index dd9dfdb336..69f9b46e0e 100644
--- a/src-ui/src/app/data/paperless-config.ts
+++ b/src-ui/src/app/data/paperless-config.ts
@@ -146,7 +146,7 @@ export const PaperlessConfigOptions: ConfigOption[] = [
key: 'max_image_pixels',
title: $localize`Max Image Pixels`,
type: ConfigOptionType.Number,
- config_key: 'PAPERLESS_OCR_IMAGE_DPI',
+ config_key: 'PAPERLESS_OCR_MAX_IMAGE_PIXELS',
category: ConfigCategory.OCR,
},
{
diff --git a/src-ui/src/app/services/consumer-status.service.ts b/src-ui/src/app/services/consumer-status.service.ts
index 82b081e932..246ddad694 100644
--- a/src-ui/src/app/services/consumer-status.service.ts
+++ b/src-ui/src/app/services/consumer-status.service.ts
@@ -146,7 +146,7 @@ export class ConsumerStatusService {
this.statusWebSocket.onmessage = (ev) => {
let statusMessage: WebsocketConsumerStatusMessage = JSON.parse(ev['data'])
- // fallback if backend didnt restrict message
+ // fallback if backend didn't restrict message
if (
statusMessage.owner_id &&
statusMessage.owner_id !== this.settingsService.currentUser?.id &&
diff --git a/src-ui/src/app/services/document-list-view.service.ts b/src-ui/src/app/services/document-list-view.service.ts
index eece10994d..e1881c2f2f 100644
--- a/src-ui/src/app/services/document-list-view.service.ts
+++ b/src-ui/src/app/services/document-list-view.service.ts
@@ -208,7 +208,7 @@ export class DocumentListViewService {
this.activeListViewState.sortField = newState.sortField
this.activeListViewState.sortReverse = newState.sortReverse
this.activeListViewState.currentPage = newState.currentPage
- this.reload(null, paramsEmpty) // update the params if there arent any
+ this.reload(null, paramsEmpty) // update the params if there aren't any
}
}
diff --git a/src-ui/src/app/services/open-documents.service.ts b/src-ui/src/app/services/open-documents.service.ts
index 9c7d5bf7d4..71b1586fdf 100644
--- a/src-ui/src/app/services/open-documents.service.ts
+++ b/src-ui/src/app/services/open-documents.service.ts
@@ -59,7 +59,7 @@ export class OpenDocumentsService {
openDocument(doc: Document): Observable {
if (this.openDocuments.find((d) => d.id == doc.id) == null) {
if (this.openDocuments.length == this.MAX_OPEN_DOCUMENTS) {
- // at max, ensure changes arent lost
+ // at max, ensure changes aren't lost
const docToRemove = this.openDocuments[this.MAX_OPEN_DOCUMENTS - 1]
const closeObservable = this.closeDocument(docToRemove)
closeObservable.pipe(first()).subscribe((closed) => {
diff --git a/src-ui/src/app/services/rest/group.service.ts b/src-ui/src/app/services/rest/group.service.ts
index 31cc6311d4..d12c6e938f 100644
--- a/src-ui/src/app/services/rest/group.service.ts
+++ b/src-ui/src/app/services/rest/group.service.ts
@@ -23,7 +23,7 @@ export class GroupService extends AbstractNameFilterService {
const { typeKey, actionKey } =
this.permissionService.getPermissionKeys(perm)
if (!typeKey || !actionKey) {
- // dont lose permissions the UI doesnt use
+ // dont lose permissions the UI doesn't use
o.permissions.push(perm)
}
})
diff --git a/src-ui/src/app/services/rest/user.service.ts b/src-ui/src/app/services/rest/user.service.ts
index a908a50e53..4fb02b1f7f 100644
--- a/src-ui/src/app/services/rest/user.service.ts
+++ b/src-ui/src/app/services/rest/user.service.ts
@@ -23,7 +23,7 @@ export class UserService extends AbstractNameFilterService {
const { typeKey, actionKey } =
this.permissionService.getPermissionKeys(perm)
if (!typeKey || !actionKey) {
- // dont lose permissions the UI doesnt use
+ // dont lose permissions the UI doesn't use
o.user_permissions.push(perm)
}
})
diff --git a/src-ui/src/app/utils/ngb-date-parser-formatter.ts b/src-ui/src/app/utils/ngb-date-parser-formatter.ts
index 5d95b21a6d..eb909baefc 100644
--- a/src-ui/src/app/utils/ngb-date-parser-formatter.ts
+++ b/src-ui/src/app/utils/ngb-date-parser-formatter.ts
@@ -53,7 +53,7 @@ export class LocalizedDateParserFormatter extends NgbDateParserFormatter {
if (this.separatorRegExp.test(value)) {
let segments = value.split(this.separatorRegExp)
- // always accept strict yyyy*mm*dd format even if thats not the input format since we can be certain its not yyyy*dd*mm
+ // always accept strict yyyy*mm*dd format even if that's not the input format since we can be certain its not yyyy*dd*mm
if (
value.length == 10 &&
segments.length == 3 &&
diff --git a/src-ui/src/environments/environment.prod.ts b/src-ui/src/environments/environment.prod.ts
index 72daea7d12..933a504cc9 100644
--- a/src-ui/src/environments/environment.prod.ts
+++ b/src-ui/src/environments/environment.prod.ts
@@ -5,7 +5,7 @@ export const environment = {
apiBaseUrl: document.baseURI + 'api/',
apiVersion: '4',
appTitle: 'Paperless-ngx',
- version: '2.3.2',
+ version: '2.3.2-dev',
webSocketHost: window.location.host,
webSocketProtocol: window.location.protocol == 'https:' ? 'wss:' : 'ws:',
webSocketBaseUrl: base_url.pathname + 'ws/',
diff --git a/src/documents/classifier.py b/src/documents/classifier.py
index d11b5f9cf5..cc8af58687 100644
--- a/src/documents/classifier.py
+++ b/src/documents/classifier.py
@@ -204,10 +204,10 @@ class DocumentClassifier:
) and self.last_auto_type_hash == hasher.digest():
return False
- # substract 1 since -1 (null) is also part of the classes.
+ # subtract 1 since -1 (null) is also part of the classes.
# union with {-1} accounts for cases where all documents have
- # correspondents and types assigned, so -1 isnt part of labels_x, which
+ # correspondents and types assigned, so -1 isn't part of labels_x, which
# it usually is.
num_correspondents = len(set(labels_correspondent) | {-1}) - 1
num_document_types = len(set(labels_document_type) | {-1}) - 1
diff --git a/src/documents/consumer.py b/src/documents/consumer.py
index b7a5595759..06e9f68fc4 100644
--- a/src/documents/consumer.py
+++ b/src/documents/consumer.py
@@ -726,12 +726,17 @@ class Consumer(LoggingMixin):
storage_type = Document.STORAGE_TYPE_UNENCRYPTED
+ title = file_info.title[:127]
+ if self.override_title is not None:
+ try:
+ title = self._parse_title_placeholders(self.override_title)
+ except Exception as e:
+ self.log.error(
+ f"Error occurred parsing title override '{self.override_title}', falling back to original. Exception: {e}",
+ )
+
document = Document.objects.create(
- title=(
- self._parse_title_placeholders(self.override_title)
- if self.override_title is not None
- else file_info.title
- )[:127],
+ title=title,
content=text,
mime_type=mime_type,
checksum=hashlib.md5(self.working_copy.read_bytes()).hexdigest(),
diff --git a/src/documents/double_sided.py b/src/documents/double_sided.py
index 8bfad3586b..5acde15973 100644
--- a/src/documents/double_sided.py
+++ b/src/documents/double_sided.py
@@ -35,7 +35,7 @@ def collate(input_doc: ConsumableDocument) -> str:
in reverse order, since the ADF will have scanned the pages from bottom
to top.
- Returns a status message on succcess, or raises a ConsumerError
+ Returns a status message on success, or raises a ConsumerError
in case of failure.
"""
diff --git a/src/documents/file_handling.py b/src/documents/file_handling.py
index 246d03d55a..700a16d8bf 100644
--- a/src/documents/file_handling.py
+++ b/src/documents/file_handling.py
@@ -224,7 +224,7 @@ def generate_filename(
if settings.FILENAME_FORMAT_REMOVE_NONE:
path = path.replace("/-none-/", "/") # remove empty directories
path = path.replace(" -none-", "") # remove when spaced, with space
- path = path.replace("-none-", "") # remove rest of the occurences
+ path = path.replace("-none-", "") # remove rest of the occurrences
path = path.replace("-none-", "none") # backward compatibility
path = path.strip(os.sep)
diff --git a/src/documents/management/commands/document_consumer.py b/src/documents/management/commands/document_consumer.py
index 191f604dec..16bcf9bd90 100644
--- a/src/documents/management/commands/document_consumer.py
+++ b/src/documents/management/commands/document_consumer.py
@@ -264,7 +264,7 @@ class Command(BaseCommand):
polling_interval = settings.CONSUMER_POLLING
if polling_interval == 0: # pragma: no cover
# Only happens if INotify failed to import
- logger.warn("Using polling of 10s, consider settng this")
+ logger.warn("Using polling of 10s, consider setting this")
polling_interval = 10
with ThreadPoolExecutor(max_workers=4) as pool:
diff --git a/src/documents/matching.py b/src/documents/matching.py
index 15d839db66..81154b8f46 100644
--- a/src/documents/matching.py
+++ b/src/documents/matching.py
@@ -345,7 +345,7 @@ def existing_document_matches_workflow(
)
trigger_matched = False
- # Document correpondent vs trigger has_correspondent
+ # Document correspondent vs trigger has_correspondent
if (
trigger.filter_has_correspondent is not None
and document.correspondent != trigger.filter_has_correspondent
diff --git a/src/documents/migrations/0017_auto_20170512_0507.py b/src/documents/migrations/0017_auto_20170512_0507.py
index 74cf39854f..b9477a06cc 100644
--- a/src/documents/migrations/0017_auto_20170512_0507.py
+++ b/src/documents/migrations/0017_auto_20170512_0507.py
@@ -22,7 +22,7 @@ class Migration(migrations.Migration):
(5, "Fuzzy Match"),
],
default=1,
- help_text='Which algorithm you want to use when matching text to the OCR\'d PDF. Here, "any" looks for any occurrence of any word provided in the PDF, while "all" requires that every word provided appear in the PDF, albeit not in the order provided. A "literal" match means that the text you enter must appear in the PDF exactly as you\'ve entered it, and "regular expression" uses a regex to match the PDF. (If you don\'t know what a regex is, you probably don\'t want this option.) Finally, a "fuzzy match" looks for words or phrases that are mostly—but not exactly—the same, which can be useful for matching against documents containg imperfections that foil accurate OCR.',
+ help_text='Which algorithm you want to use when matching text to the OCR\'d PDF. Here, "any" looks for any occurrence of any word provided in the PDF, while "all" requires that every word provided appear in the PDF, albeit not in the order provided. A "literal" match means that the text you enter must appear in the PDF exactly as you\'ve entered it, and "regular expression" uses a regex to match the PDF. (If you don\'t know what a regex is, you probably don\'t want this option.) Finally, a "fuzzy match" looks for words or phrases that are mostly—but not exactly—the same, which can be useful for matching against documents containing imperfections that foil accurate OCR.',
),
),
migrations.AlterField(
@@ -37,7 +37,7 @@ class Migration(migrations.Migration):
(5, "Fuzzy Match"),
],
default=1,
- help_text='Which algorithm you want to use when matching text to the OCR\'d PDF. Here, "any" looks for any occurrence of any word provided in the PDF, while "all" requires that every word provided appear in the PDF, albeit not in the order provided. A "literal" match means that the text you enter must appear in the PDF exactly as you\'ve entered it, and "regular expression" uses a regex to match the PDF. (If you don\'t know what a regex is, you probably don\'t want this option.) Finally, a "fuzzy match" looks for words or phrases that are mostly—but not exactly—the same, which can be useful for matching against documents containg imperfections that foil accurate OCR.',
+ help_text='Which algorithm you want to use when matching text to the OCR\'d PDF. Here, "any" looks for any occurrence of any word provided in the PDF, while "all" requires that every word provided appear in the PDF, albeit not in the order provided. A "literal" match means that the text you enter must appear in the PDF exactly as you\'ve entered it, and "regular expression" uses a regex to match the PDF. (If you don\'t know what a regex is, you probably don\'t want this option.) Finally, a "fuzzy match" looks for words or phrases that are mostly—but not exactly—the same, which can be useful for matching against documents containing imperfections that foil accurate OCR.',
),
),
]
diff --git a/src/documents/migrations/1000_update_paperless_all.py b/src/documents/migrations/1000_update_paperless_all.py
index 6026ce3d28..ae0d217f69 100644
--- a/src/documents/migrations/1000_update_paperless_all.py
+++ b/src/documents/migrations/1000_update_paperless_all.py
@@ -66,7 +66,7 @@ class Migration(migrations.Migration):
(6, "Automatic Classification"),
],
default=1,
- help_text='Which algorithm you want to use when matching text to the OCR\'d PDF. Here, "any" looks for any occurrence of any word provided in the PDF, while "all" requires that every word provided appear in the PDF, albeit not in the order provided. A "literal" match means that the text you enter must appear in the PDF exactly as you\'ve entered it, and "regular expression" uses a regex to match the PDF. (If you don\'t know what a regex is, you probably don\'t want this option.) Finally, a "fuzzy match" looks for words or phrases that are mostly—but not exactly—the same, which can be useful for matching against documents containg imperfections that foil accurate OCR.',
+ help_text='Which algorithm you want to use when matching text to the OCR\'d PDF. Here, "any" looks for any occurrence of any word provided in the PDF, while "all" requires that every word provided appear in the PDF, albeit not in the order provided. A "literal" match means that the text you enter must appear in the PDF exactly as you\'ve entered it, and "regular expression" uses a regex to match the PDF. (If you don\'t know what a regex is, you probably don\'t want this option.) Finally, a "fuzzy match" looks for words or phrases that are mostly—but not exactly—the same, which can be useful for matching against documents containing imperfections that foil accurate OCR.',
),
),
("is_insensitive", models.BooleanField(default=True)),
@@ -100,7 +100,7 @@ class Migration(migrations.Migration):
(6, "Automatic Classification"),
],
default=1,
- help_text='Which algorithm you want to use when matching text to the OCR\'d PDF. Here, "any" looks for any occurrence of any word provided in the PDF, while "all" requires that every word provided appear in the PDF, albeit not in the order provided. A "literal" match means that the text you enter must appear in the PDF exactly as you\'ve entered it, and "regular expression" uses a regex to match the PDF. (If you don\'t know what a regex is, you probably don\'t want this option.) Finally, a "fuzzy match" looks for words or phrases that are mostly—but not exactly—the same, which can be useful for matching against documents containg imperfections that foil accurate OCR.',
+ help_text='Which algorithm you want to use when matching text to the OCR\'d PDF. Here, "any" looks for any occurrence of any word provided in the PDF, while "all" requires that every word provided appear in the PDF, albeit not in the order provided. A "literal" match means that the text you enter must appear in the PDF exactly as you\'ve entered it, and "regular expression" uses a regex to match the PDF. (If you don\'t know what a regex is, you probably don\'t want this option.) Finally, a "fuzzy match" looks for words or phrases that are mostly—but not exactly—the same, which can be useful for matching against documents containing imperfections that foil accurate OCR.',
),
),
migrations.AlterField(
@@ -116,7 +116,7 @@ class Migration(migrations.Migration):
(6, "Automatic Classification"),
],
default=1,
- help_text='Which algorithm you want to use when matching text to the OCR\'d PDF. Here, "any" looks for any occurrence of any word provided in the PDF, while "all" requires that every word provided appear in the PDF, albeit not in the order provided. A "literal" match means that the text you enter must appear in the PDF exactly as you\'ve entered it, and "regular expression" uses a regex to match the PDF. (If you don\'t know what a regex is, you probably don\'t want this option.) Finally, a "fuzzy match" looks for words or phrases that are mostly—but not exactly—the same, which can be useful for matching against documents containg imperfections that foil accurate OCR.',
+ help_text='Which algorithm you want to use when matching text to the OCR\'d PDF. Here, "any" looks for any occurrence of any word provided in the PDF, while "all" requires that every word provided appear in the PDF, albeit not in the order provided. A "literal" match means that the text you enter must appear in the PDF exactly as you\'ve entered it, and "regular expression" uses a regex to match the PDF. (If you don\'t know what a regex is, you probably don\'t want this option.) Finally, a "fuzzy match" looks for words or phrases that are mostly—but not exactly—the same, which can be useful for matching against documents containing imperfections that foil accurate OCR.',
),
),
migrations.AlterField(
diff --git a/src/documents/migrations/1012_fix_archive_files.py b/src/documents/migrations/1012_fix_archive_files.py
index ee38e16dba..87d6ddc787 100644
--- a/src/documents/migrations/1012_fix_archive_files.py
+++ b/src/documents/migrations/1012_fix_archive_files.py
@@ -207,7 +207,7 @@ def create_archive_version(doc, retry_count=3):
return
else:
# This is mostly here for the tika parser in docker
- # environemnts. The servers for parsing need to come up first,
+ # environments. The servers for parsing need to come up first,
# and the docker setup doesn't ensure that tika is running
# before attempting migrations.
logger.error("Parse error, will try again in 5 seconds...")
diff --git a/src/documents/models.py b/src/documents/models.py
index b943fa2b53..f2e122abc9 100644
--- a/src/documents/models.py
+++ b/src/documents/models.py
@@ -394,11 +394,6 @@ class Log(models.Model):
class SavedView(ModelWithOwner):
- class Meta:
- ordering = ("name",)
- verbose_name = _("saved view")
- verbose_name_plural = _("saved views")
-
name = models.CharField(_("name"), max_length=128)
show_on_dashboard = models.BooleanField(
@@ -416,6 +411,14 @@ class SavedView(ModelWithOwner):
)
sort_reverse = models.BooleanField(_("sort reverse"), default=False)
+ class Meta:
+ ordering = ("name",)
+ verbose_name = _("saved view")
+ verbose_name_plural = _("saved views")
+
+ def __str__(self):
+ return f"SavedView {self.name}"
+
class SavedViewFilterRule(models.Model):
RULE_TYPES = [
diff --git a/src/documents/parsers.py b/src/documents/parsers.py
index b823ae9ceb..db4b42792c 100644
--- a/src/documents/parsers.py
+++ b/src/documents/parsers.py
@@ -33,7 +33,7 @@ from documents.utils import copy_file_with_basic_stats
# - XX MON ZZZZ with XX being 1 or 2 and ZZZZ being 4 digits. MONTH is 3 letters
# - XXPP MONTH ZZZZ with XX being 1 or 2 and PP being 2 letters and ZZZZ being 4 digits
-# TODO: isnt there a date parsing library for this?
+# TODO: isn't there a date parsing library for this?
DATE_REGEX = re.compile(
r"(\b|(?!=([_-])))([0-9]{1,2})[\.\/-]([0-9]{1,2})[\.\/-]([0-9]{4}|[0-9]{2})(\b|(?=([_-])))|"
@@ -113,8 +113,6 @@ def get_parser_class_for_mime_type(mime_type: str) -> Optional[type["DocumentPar
options = []
- # Sein letzter Befehl war: KOMMT! Und sie kamen. Alle. Sogar die Parser.
-
for response in document_consumer_declaration.send(None):
parser_declaration = response[1]
supported_mime_types = parser_declaration["mime_types"]
diff --git a/src/documents/serialisers.py b/src/documents/serialisers.py
index 41d3139b35..ffcfbcc1d7 100644
--- a/src/documents/serialisers.py
+++ b/src/documents/serialisers.py
@@ -546,7 +546,7 @@ class CustomFieldInstanceSerializer(serializers.ModelSerializer):
if doc_id not in target_doc_ids:
self.remove_doclink(document, field, doc_id)
- # Create an instance if target doc doesnt have this field or append it to an existing one
+ # Create an instance if target doc doesn't have this field or append it to an existing one
existing_custom_field_instances = {
custom_field.document_id: custom_field
for custom_field in CustomFieldInstance.objects.filter(
@@ -1385,13 +1385,39 @@ class WorkflowActionSerializer(serializers.ModelSerializer):
]
def validate(self, attrs):
- # Empty strings treated as None to avoid unexpected behavior
- if (
- "assign_title" in attrs
- and attrs["assign_title"] is not None
- and len(attrs["assign_title"]) == 0
- ):
- attrs["assign_title"] = None
+ if "assign_title" in attrs and attrs["assign_title"] is not None:
+ if len(attrs["assign_title"]) == 0:
+ # Empty strings treated as None to avoid unexpected behavior
+ attrs["assign_title"] = None
+ else:
+ try:
+ # test against all placeholders, see consumer.py `parse_doc_title_w_placeholders`
+ attrs["assign_title"].format(
+ correspondent="",
+ document_type="",
+ added="",
+ added_year="",
+ added_year_short="",
+ added_month="",
+ added_month_name="",
+ added_month_name_short="",
+ added_day="",
+ added_time="",
+ owner_username="",
+ original_filename="",
+ created="",
+ created_year="",
+ created_year_short="",
+ created_month="",
+ created_month_name="",
+ created_month_name_short="",
+ created_day="",
+ created_time="",
+ )
+ except (ValueError, KeyError) as e:
+ raise serializers.ValidationError(
+ {"assign_title": f'Invalid f-string detected: "{e.args[0]}"'},
+ )
return attrs
diff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.py
index b782cfa7f6..eee06bb6ea 100644
--- a/src/documents/signals/handlers.py
+++ b/src/documents/signals/handlers.py
@@ -570,19 +570,27 @@ def run_workflow(
document.owner = action.assign_owner
if action.assign_title is not None:
- document.title = parse_doc_title_w_placeholders(
- action.assign_title,
- document.correspondent.name
- if document.correspondent is not None
- else "",
- document.document_type.name
- if document.document_type is not None
- else "",
- document.owner.username if document.owner is not None else "",
- timezone.localtime(document.added),
- document.original_filename,
- timezone.localtime(document.created),
- )
+ try:
+ document.title = parse_doc_title_w_placeholders(
+ action.assign_title,
+ document.correspondent.name
+ if document.correspondent is not None
+ else "",
+ document.document_type.name
+ if document.document_type is not None
+ else "",
+ document.owner.username
+ if document.owner is not None
+ else "",
+ document.added,
+ document.original_filename,
+ document.created,
+ )
+ except Exception:
+ logger.exception(
+ f"Error occurred parsing title assignment '{action.assign_title}', falling back to original",
+ extra={"group": logging_group},
+ )
if (
action.assign_view_users is not None
@@ -617,7 +625,7 @@ def run_workflow(
).count()
== 0
):
- # can be triggered on existing docs, so only add the field if it doesnt already exist
+ # can be triggered on existing docs, so only add the field if it doesn't already exist
CustomFieldInstance.objects.create(
field=field,
document=document,
diff --git a/src/documents/tests/test_api_app_config.py b/src/documents/tests/test_api_app_config.py
new file mode 100644
index 0000000000..a12d2a6959
--- /dev/null
+++ b/src/documents/tests/test_api_app_config.py
@@ -0,0 +1,102 @@
+import json
+
+from django.contrib.auth.models import User
+from rest_framework import status
+from rest_framework.test import APITestCase
+
+from documents.tests.utils import DirectoriesMixin
+from paperless.models import ApplicationConfiguration
+from paperless.models import ColorConvertChoices
+
+
+class TestApiAppConfig(DirectoriesMixin, APITestCase):
+ ENDPOINT = "/api/config/"
+
+ def setUp(self) -> None:
+ super().setUp()
+
+ user = User.objects.create_superuser(username="temp_admin")
+ self.client.force_authenticate(user=user)
+
+ def test_api_get_config(self):
+ """
+ GIVEN:
+ - API request to get app config
+ WHEN:
+ - API is called
+ THEN:
+ - Existing config
+ """
+ response = self.client.get(self.ENDPOINT, format="json")
+
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+
+ self.assertEqual(
+ json.dumps(response.data[0]),
+ json.dumps(
+ {
+ "id": 1,
+ "user_args": None,
+ "output_type": None,
+ "pages": None,
+ "language": None,
+ "mode": None,
+ "skip_archive_file": None,
+ "image_dpi": None,
+ "unpaper_clean": None,
+ "deskew": None,
+ "rotate_pages": None,
+ "rotate_pages_threshold": None,
+ "max_image_pixels": None,
+ "color_conversion_strategy": None,
+ },
+ ),
+ )
+
+ def test_api_update_config(self):
+ """
+ GIVEN:
+ - API request to update app config
+ WHEN:
+ - API is called
+ THEN:
+ - Correct HTTP response
+ - Config is updated
+ """
+ response = self.client.patch(
+ f"{self.ENDPOINT}1/",
+ json.dumps(
+ {
+ "color_conversion_strategy": ColorConvertChoices.RGB,
+ },
+ ),
+ content_type="application/json",
+ )
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ config = ApplicationConfiguration.objects.first()
+ self.assertEqual(config.color_conversion_strategy, ColorConvertChoices.RGB)
+
+ def test_api_update_config_empty_fields(self):
+ """
+ GIVEN:
+ - API request to update app config with empty string for user_args JSONField and language field
+ WHEN:
+ - API is called
+ THEN:
+ - Correct HTTP response
+ - user_args is set to None
+ """
+ response = self.client.patch(
+ f"{self.ENDPOINT}1/",
+ json.dumps(
+ {
+ "user_args": "",
+ "language": "",
+ },
+ ),
+ content_type="application/json",
+ )
+ self.assertEqual(response.status_code, status.HTTP_200_OK)
+ config = ApplicationConfiguration.objects.first()
+ self.assertEqual(config.user_args, None)
+ self.assertEqual(config.language, None)
diff --git a/src/documents/tests/test_api_documents.py b/src/documents/tests/test_api_documents.py
index f19711a96c..66da23ef7b 100644
--- a/src/documents/tests/test_api_documents.py
+++ b/src/documents/tests/test_api_documents.py
@@ -1276,7 +1276,7 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase):
GIVEN:
- NUMBER_OF_SUGGESTED_DATES = 0 (disables feature)
WHEN:
- - API reuqest for document suggestions
+ - API request for document suggestions
THEN:
- Dont check for suggested dates at all
"""
@@ -1526,7 +1526,7 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase):
GIVEN:
- A document with a single note
WHEN:
- - API reuqest for document notes is made
+ - API request for document notes is made
THEN:
- The associated note is returned
"""
diff --git a/src/documents/tests/test_api_search.py b/src/documents/tests/test_api_search.py
index 9f952ec547..0247d3293a 100644
--- a/src/documents/tests/test_api_search.py
+++ b/src/documents/tests/test_api_search.py
@@ -55,7 +55,7 @@ class TestDocumentSearchApi(DirectoriesMixin, APITestCase):
with AsyncWriter(index.open_index()) as writer:
# Note to future self: there is a reason we dont use a model signal handler to update the index: some operations edit many documents at once
# (retagger, renamer) and we don't want to open a writer for each of these, but rather perform the entire operation with one writer.
- # That's why we cant open the writer in a model on_save handler or something.
+ # That's why we can't open the writer in a model on_save handler or something.
index.update_document(writer, d1)
index.update_document(writer, d2)
index.update_document(writer, d3)
@@ -903,8 +903,8 @@ class TestDocumentSearchApi(DirectoriesMixin, APITestCase):
GIVEN:
- Documents with owners set & without
WHEN:
- - API reuqest for advanced query (search) is made by non-superuser
- - API reuqest for advanced query (search) is made by superuser
+ - API request for advanced query (search) is made by non-superuser
+ - API request for advanced query (search) is made by superuser
THEN:
- Only owned docs are returned for regular users
- All docs are returned for superuser
@@ -959,7 +959,7 @@ class TestDocumentSearchApi(DirectoriesMixin, APITestCase):
GIVEN:
- Documents with granted view permissions to others
WHEN:
- - API reuqest for advanced query (search) is made by user
+ - API request for advanced query (search) is made by user
THEN:
- Only docs with granted view permissions are returned
"""
diff --git a/src/documents/tests/test_api_workflows.py b/src/documents/tests/test_api_workflows.py
index d7a7ad6ff4..21e887c24f 100644
--- a/src/documents/tests/test_api_workflows.py
+++ b/src/documents/tests/test_api_workflows.py
@@ -248,6 +248,45 @@ class TestApiWorkflows(DirectoriesMixin, APITestCase):
self.assertEqual(WorkflowTrigger.objects.count(), 1)
+ def test_api_create_invalid_assign_title(self):
+ """
+ GIVEN:
+ - API request to create a workflow
+ - Invalid f-string for assign_title
+ WHEN:
+ - API is called
+ THEN:
+ - Correct HTTP 400 response
+ - No objects are created
+ """
+ response = self.client.post(
+ self.ENDPOINT,
+ json.dumps(
+ {
+ "name": "Workflow 1",
+ "order": 1,
+ "triggers": [
+ {
+ "type": WorkflowTrigger.WorkflowTriggerType.DOCUMENT_UPDATED,
+ },
+ ],
+ "actions": [
+ {
+ "assign_title": "{created_year]",
+ },
+ ],
+ },
+ ),
+ content_type="application/json",
+ )
+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
+ self.assertIn(
+ "Invalid f-string detected",
+ response.data["actions"][0]["assign_title"][0],
+ )
+
+ self.assertEqual(Workflow.objects.count(), 1)
+
def test_api_create_workflow_trigger_action_empty_fields(self):
"""
GIVEN:
diff --git a/src/documents/tests/test_classifier.py b/src/documents/tests/test_classifier.py
index 4e361aa8e6..0b91e223f1 100644
--- a/src/documents/tests/test_classifier.py
+++ b/src/documents/tests/test_classifier.py
@@ -414,7 +414,7 @@ class TestClassifier(DirectoriesMixin, TestCase):
)
doc2 = Document.objects.create(
title="doc2",
- content="this is a document from noone",
+ content="this is a document from no one",
checksum="B",
)
diff --git a/src/documents/tests/test_consumer.py b/src/documents/tests/test_consumer.py
index 24f7ff3388..f772659707 100644
--- a/src/documents/tests/test_consumer.py
+++ b/src/documents/tests/test_consumer.py
@@ -423,6 +423,16 @@ class TestConsumer(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
self.assertEqual(document.title, "Override Title")
self._assert_first_last_send_progress()
+ def testOverrideTitleInvalidPlaceholders(self):
+ with self.assertLogs("paperless.consumer", level="ERROR") as cm:
+ document = self.consumer.try_consume_file(
+ self.get_test_file(),
+ override_title="Override {correspondent]",
+ )
+ self.assertEqual(document.title, "sample")
+ expected_str = "Error occurred parsing title override 'Override {correspondent]', falling back to original"
+ self.assertIn(expected_str, cm.output[0])
+
def testOverrideCorrespondent(self):
c = Correspondent.objects.create(name="test")
@@ -665,7 +675,7 @@ class TestConsumer(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
@override_settings(FILENAME_FORMAT="{correspondent}/{title}")
@mock.patch("documents.signals.handlers.generate_unique_filename")
def testFilenameHandlingUnstableFormat(self, m):
- filenames = ["this", "that", "now this", "i cant decide"]
+ filenames = ["this", "that", "now this", "i cannot decide"]
def get_filename():
f = filenames.pop()
diff --git a/src/documents/tests/test_date_parsing.py b/src/documents/tests/test_date_parsing.py
index 682151a5c4..54b4d7b532 100644
--- a/src/documents/tests/test_date_parsing.py
+++ b/src/documents/tests/test_date_parsing.py
@@ -212,8 +212,8 @@ class TestDate(TestCase):
def test_multiple_dates(self):
text = """This text has multiple dates.
- For example 02.02.2018, 22 July 2022 and Dezember 2021.
- But not 24-12-9999 because its in the future..."""
+ For example 02.02.2018, 22 July 2022 and December 2021.
+ But not 24-12-9999 because it's in the future..."""
dates = list(parse_date_generator("", text))
self.assertEqual(len(dates), 3)
self.assertEqual(
diff --git a/src/documents/tests/test_delayedquery.py b/src/documents/tests/test_delayedquery.py
index 962df71928..b0dfc2ed2b 100644
--- a/src/documents/tests/test_delayedquery.py
+++ b/src/documents/tests/test_delayedquery.py
@@ -43,7 +43,7 @@ class TestDelayedQuery(TestCase):
)
def test_get_permission_criteria(self):
- # tests contains touples of user instances and the expected filter
+ # tests contains tuples of user instances and the expected filter
tests = (
(None, [query.Term("has_owner", False)]),
(User(42, username="foo", is_superuser=True), []),
@@ -113,7 +113,7 @@ class TestDelayedQuery(TestCase):
)
def test_tags_query_filters(self):
- # tests contains touples of query_parameter dics and the expected whoosh query
+ # tests contains tuples of query_parameter dics and the expected whoosh query
param = "tags"
field, _ = DelayedQuery.param_map[param]
tests = (
diff --git a/src/documents/tests/test_migration_encrypted_webp_conversion.py b/src/documents/tests/test_migration_encrypted_webp_conversion.py
index 879f4b0dff..47b900658c 100644
--- a/src/documents/tests/test_migration_encrypted_webp_conversion.py
+++ b/src/documents/tests/test_migration_encrypted_webp_conversion.py
@@ -165,7 +165,7 @@ class TestMigrateToEncrytpedWebPThumbnails(TestMigrations):
):
"""
GIVEN:
- - Encrytped document exists with existing encrypted WebP thumbnail path
+ - Encrypted document exists with existing encrypted WebP thumbnail path
WHEN:
- Migration is attempted
THEN:
diff --git a/src/documents/tests/test_workflows.py b/src/documents/tests/test_workflows.py
index b4ad4aa57f..b688eecc9a 100644
--- a/src/documents/tests/test_workflows.py
+++ b/src/documents/tests/test_workflows.py
@@ -966,6 +966,50 @@ class TestWorkflows(DirectoriesMixin, FileSystemAssertsMixin, APITestCase):
expected_str = f"Document correspondent {doc.correspondent} does not match {trigger.filter_has_correspondent}"
self.assertIn(expected_str, cm.output[1])
+ def test_document_added_invalid_title_placeholders(self):
+ """
+ GIVEN:
+ - Existing workflow with added trigger type
+ - Assign title field has an error
+ WHEN:
+ - File that matches is added
+ THEN:
+ - Title is not updated, error is output
+ """
+ trigger = WorkflowTrigger.objects.create(
+ type=WorkflowTrigger.WorkflowTriggerType.DOCUMENT_ADDED,
+ filter_filename="*sample*",
+ )
+ action = WorkflowAction.objects.create(
+ assign_title="Doc {created_year]",
+ )
+ w = Workflow.objects.create(
+ name="Workflow 1",
+ order=0,
+ )
+ w.triggers.add(trigger)
+ w.actions.add(action)
+ w.save()
+
+ now = timezone.localtime(timezone.now())
+ created = now - timedelta(weeks=520)
+ doc = Document.objects.create(
+ original_filename="sample.pdf",
+ title="sample test",
+ content="Hello world bar",
+ created=created,
+ )
+
+ with self.assertLogs("paperless.handlers", level="ERROR") as cm:
+ document_consumption_finished.send(
+ sender=self.__class__,
+ document=doc,
+ )
+ expected_str = f"Error occurred parsing title assignment '{action.assign_title}', falling back to original"
+ self.assertIn(expected_str, cm.output[0])
+
+ self.assertEqual(doc.title, "sample test")
+
def test_document_updated_workflow(self):
trigger = WorkflowTrigger.objects.create(
type=WorkflowTrigger.WorkflowTriggerType.DOCUMENT_UPDATED,
diff --git a/src/paperless/checks.py b/src/paperless/checks.py
index a9ed6a6ca1..0bfdce2cd8 100644
--- a/src/paperless/checks.py
+++ b/src/paperless/checks.py
@@ -95,8 +95,8 @@ def debug_mode_check(app_configs, **kwargs):
return [
Warning(
"DEBUG mode is enabled. Disable Debug mode. This is a serious "
- "security issue, since it puts security overides in place which "
- "are meant to be only used during development. This "
+ "security issue, since it puts security overrides in place "
+ "which are meant to be only used during development. This "
"also means that paperless will tell anyone various "
"debugging information when something goes wrong.",
),
diff --git a/src/paperless/serialisers.py b/src/paperless/serialisers.py
index db7ca21f7a..fb366f808e 100644
--- a/src/paperless/serialisers.py
+++ b/src/paperless/serialisers.py
@@ -122,7 +122,15 @@ class ProfileSerializer(serializers.ModelSerializer):
class ApplicationConfigurationSerializer(serializers.ModelSerializer):
- user_args = serializers.JSONField(binary=True)
+ user_args = serializers.JSONField(binary=True, allow_null=True)
+
+ def run_validation(self, data):
+ # Empty strings treated as None to avoid unexpected behavior
+ if "user_args" in data and data["user_args"] == "":
+ data["user_args"] = None
+ if "language" in data and data["language"] == "":
+ data["language"] = None
+ return super().run_validation(data)
class Meta:
model = ApplicationConfiguration
diff --git a/src/paperless/settings.py b/src/paperless/settings.py
index f2d306bbf9..e13518ce3d 100644
--- a/src/paperless/settings.py
+++ b/src/paperless/settings.py
@@ -499,8 +499,8 @@ AUTH_PASSWORD_VALIDATORS = [
# Disable Django's artificial limit on the number of form fields to submit at
# once. This is a protection against overloading the server, but since this is
-# a self-hosted sort of gig, the benefits of being able to mass-delete a tonne
-# of log entries outweight the benefits of such a safeguard.
+# a self-hosted sort of gig, the benefits of being able to mass-delete a ton
+# of log entries outweigh the benefits of such a safeguard.
DATA_UPLOAD_MAX_NUMBER_FIELDS = None
diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.py
index c79f03affd..76e5ed2e78 100644
--- a/src/paperless_mail/mail.py
+++ b/src/paperless_mail/mail.py
@@ -767,7 +767,7 @@ class MailAccountHandler(LoggingMixin):
message=message,
)
else:
- # No files to consume, just mark as processed if it wasnt by .eml processing
+ # No files to consume, just mark as processed if it wasn't by .eml processing
if not ProcessedMail.objects.filter(
rule=rule,
uid=message.uid,
diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.py
index 577db36fd8..26130b6432 100644
--- a/src/paperless_mail/tests/test_mail.py
+++ b/src/paperless_mail/tests/test_mail.py
@@ -223,7 +223,7 @@ class TestMail(
attachments: Union[int, list[_AttachmentDef]] = 1,
body: str = "",
subject: str = "the subject",
- from_: str = "noone@mail.com",
+ from_: str = "no_one@mail.com",
to: Optional[list[str]] = None,
seen: bool = False,
flagged: bool = False,