Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Merge branch 'dev' into feature-autocolor

jonaswinkler723369582460
diff --cc Pipfile
index 1cf5a312f,29a91ece3..0e72eb1c0
--- a/Pipfile
+++ b/Pipfile
@@@ -32,15 -33,28 +33,29 @@@ python-dateutil = "*
python-magic = "*"
psycopg2-binary = "*"
redis = "*"
- scikit-learn="~=0.23.2"
+ # Pinned because aarch64 wheels and updates cause warnings when loading the classifier model.
+ scikit-learn="==0.24.0"
+ # Prevent scipy updates because 1.6 is incompatible with python 3.6
+ scipy="~=1.5.4"
whitenoise = "~=5.2.0"
- watchdog = "*"
+ watchdog = "~=1.0.0"
whoosh="~=2.7.4"
- inotifyrecursive = ">=0.3.4"
- ocrmypdf = "*"
+ inotifyrecursive = "~=0.3.4"
+ ocrmypdf = "~=11.6"
tqdm = "*"
+ tika = "*"
+ # TODO: This will sadly also install daphne+dependencies,
+ # which an ASGI server we don't need. Adds about 15MB image size.
+ channels = "~=3.0"
+ channels-redis = "*"
+ uvicorn = {extras = ["standard"], version = "*"}
+ concurrent-log-handler = "*"
+ # uvloop 0.15+ incompatible with python 3.6
+ uvloop = "~=0.14.0"
+ # TODO: keep an eye on piwheel builds and update this once available (https://www.piwheels.org/project/cryptography/)
+ cryptography = "~=3.3.2"
+ "pdfminer.six" = "*"
+colorhash = "*"
[dev-packages]
coveralls = "*"
diff --cc src-ui/src/app/components/manage/tag-list/tag-edit-dialog/tag-edit-dialog.component.html
index 2f6dded52,418a5c281..0d2f6a1c7
--- a/src-ui/src/app/components/manage/tag-list/tag-edit-dialog/tag-edit-dialog.component.html
+++ b/src-ui/src/app/components/manage/tag-list/tag-edit-dialog/tag-edit-dialog.component.html
@@@ -6,15 -6,25 +6,25 @@@
</button>
</div>
<div class="modal-body">
- <app-input-text title="Name" formControlName="name"></app-input-text>
- <app-input-select title="Colour" [items]="getColours()" formControlName="colour" [textColor]="getColor(objectForm.value.colour).textColor" [backgroundColor]="getColor(objectForm.value.colour).id"></app-input-select>
- <app-input-check title="Inbox tag" formControlName="is_inbox_tag" hint="Inbox tags are automatically assigned to all consumed documents."></app-input-check>
- <app-input-text title="Match" formControlName="match"></app-input-text>
- <app-input-select title="Matching algorithm" [items]="getMatchingAlgorithms()" formControlName="matching_algorithm"></app-input-select>
- <app-input-check title="Case insensitive" formControlName="is_insensitive"></app-input-check>
+ <app-input-text i18n-title title="Name" formControlName="name" [error]="error?.name"></app-input-text>
+
+
+ <div class="form-group paperless-input-select">
+ <label for="colour" i18n>Color</label>
+ <ng-select name="colour" formControlName="colour" [items]="getColours()" bindValue="id" bindLabel="name" [clearable]="false">
+ <ng-template ng-option-tmp ng-label-tmp let-item="item">
- <span class="badge" [style.background]="item.value" [style.color]="item.textColor">{{item.name}}</span>
++ <span class="badge" [style.background]="item.id" [style.color]="item.textColor">{{item.name}}</span>
+ </ng-template>
+ </ng-select>
+ </div>
+
+ <app-input-check i18n-title title="Inbox tag" formControlName="is_inbox_tag" i18n-hint hint="Inbox tags are automatically assigned to all consumed documents."></app-input-check>
+ <app-input-select i18n-title title="Matching algorithm" [items]="getMatchingAlgorithms()" formControlName="matching_algorithm"></app-input-select>
+ <app-input-text *ngIf="patternRequired" i18n-title title="Matching pattern" formControlName="match" [error]="error?.match"></app-input-text>
+ <app-input-check *ngIf="patternRequired" i18n-title title="Case insensitive" formControlName="is_insensitive"></app-input-check>
</div>
<div class="modal-footer">
- <button type="button" class="btn btn-outline-dark" (click)="cancel()">Cancel</button>
- <button type="submit" class="btn btn-primary">Save</button>
+ <button type="button" class="btn btn-outline-dark" (click)="cancel()" i18n [disabled]="networkActive">Cancel</button>
+ <button type="submit" class="btn btn-primary" i18n [disabled]="networkActive">Save</button>
</div>
</form>
diff --cc src-ui/src/app/components/manage/tag-list/tag-edit-dialog/tag-edit-dialog.component.ts
index 8017f275b,d67369a8b..d5b281e30
--- a/src-ui/src/app/components/manage/tag-list/tag-edit-dialog/tag-edit-dialog.component.ts
+++ b/src-ui/src/app/components/manage/tag-list/tag-edit-dialog/tag-edit-dialog.component.ts
@@@ -13,8 -13,16 +13,16 @@@ import { ToastService } from 'src/app/s
})
export class TagEditDialogComponent extends EditDialogComponent<PaperlessTag> {
- constructor(service: TagService, activeModal: NgbActiveModal, toastService: ToastService) {
+ constructor(service: TagService, activeModal: NgbActiveModal, toastService: ToastService) {
- super(service, activeModal, toastService, 'tag')
+ super(service, activeModal, toastService)
+ }
+
+ getCreateTitle() {
+ return $localize`Create new tag`
+ }
+
+ getEditTitle() {
+ return $localize`Edit tag`
}
getForm(): FormGroup {
diff --cc src-ui/src/app/components/manage/tag-list/tag-list.component.ts
index 582835de1,f9d0678ab..ac468c46b
--- a/src-ui/src/app/components/manage/tag-list/tag-list.component.ts
+++ b/src-ui/src/app/components/manage/tag-list/tag-list.component.ts
@@@ -18,14 -23,15 +23,19 @@@ export class TagListComponent extends G
}
getColor(id) {
- return TAG_COLOURS.find(c => c.id == id)
+ var color = TAG_COLOURS.find(c => c.id == id)
+ if (color) {
+ return color
+ }
+ return { id: id, name: id, textColor: "#ffffff" }
}
- getObjectName(object: PaperlessTag) {
- return `tag '${object.name}'`
+ getDeleteMessage(object: PaperlessTag) {
+ return $localize`Do you really want to delete the tag "${object.name}"?`
+ }
+
+ filterDocuments(object: PaperlessTag) {
+ this.list.quickFilter([{rule_type: FILTER_HAS_TAG, value: object.id.toString()}])
+
}
}
diff --cc src-ui/src/app/data/paperless-tag.ts
index 3d8ddfdaf,45ef8a613..1518caa1f
--- a/src-ui/src/app/data/paperless-tag.ts
+++ b/src-ui/src/app/data/paperless-tag.ts
@@@ -3,20 -3,19 +3,20 @@@ import { ObjectWithId } from './object-
export const TAG_COLOURS = [
- {id: 1, value: "#a6cee3", name: $localize`Light blue`, textColor: "#000000"},
- {id: 2, value: "#1f78b4", name: $localize`Blue`, textColor: "#ffffff"},
- {id: 3, value: "#b2df8a", name: $localize`Light green`, textColor: "#000000"},
- {id: 4, value: "#33a02c", name: $localize`Green`, textColor: "#ffffff"},
- {id: 5, value: "#fb9a99", name: $localize`Light red`, textColor: "#000000"},
- {id: 6, value: "#e31a1c", name: $localize`Red `, textColor: "#ffffff"},
- {id: 7, value: "#fdbf6f", name: $localize`Light orange`, textColor: "#000000"},
- {id: 8, value: "#ff7f00", name: $localize`Orange`, textColor: "#000000"},
- {id: 9, value: "#cab2d6", name: $localize`Light violet`, textColor: "#000000"},
- {id: 10, value: "#6a3d9a", name: $localize`Violet`, textColor: "#ffffff"},
- {id: 11, value: "#b15928", name: $localize`Brown`, textColor: "#ffffff"},
- {id: 12, value: "#000000", name: $localize`Black`, textColor: "#ffffff"},
- {id: 13, value: "#cccccc", name: $localize`Light grey`, textColor: "#000000"}
+ { id: "", name: "Auto", textColor: "#000000" },
- { id: "#a6cee3", name: "Light Blue", textColor: "#000000" },
- { id: "#1f78b4", name: "Blue", textColor: "#ffffff" },
- { id: "#b2df8a", name: "Light Green", textColor: "#000000" },
- { id: "#33a02c", name: "Green", textColor: "#000000" },
- { id: "#fb9a99", name: "Light Red", textColor: "#000000" },
- { id: "#e31a1c", name: "Red ", textColor: "#ffffff" },
- { id: "#fdbf6f", name: "Light Orange", textColor: "#000000" },
- { id: "#ff7f00", name: "Orange", textColor: "#000000" },
- { id: "#cab2d6", name: "Light Violet", textColor: "#000000" },
- { id: "#6a3d9a", name: "Violet", textColor: "#ffffff" },
- { id: "#b15928", name: "Brown", textColor: "#000000" },
- { id: "#000000", name: "Black", textColor: "#ffffff" },
- { id: "#cccccc", name: "Light Grey", textColor: "#000000" }
++ { id: "#a6cee3", name: $localize`Light blue`, textColor: "#000000" },
++ { id: "#1f78b4", name: $localize`Blue`, textColor: "#ffffff" },
++ { id: "#b2df8a", name: $localize`Light green`, textColor: "#000000" },
++ { id: "#33a02c", name: $localize`Green`, textColor: "#ffffff" },
++ { id: "#fb9a99", name: $localize`Light red`, textColor: "#000000" },
++ { id: "#e31a1c", name: $localize`Red `, textColor: "#ffffff" },
++ { id: "#fdbf6f", name: $localize`Light orange`, textColor: "#000000" },
++ { id: "#ff7f00", name: $localize`Orange`, textColor: "#000000" },
++ { id: "#cab2d6", name: $localize`Light violet`, textColor: "#000000" },
++ { id: "#6a3d9a", name: $localize`Violet`, textColor: "#ffffff" },
++ { id: "#b15928", name: $localize`Brown`, textColor: "#ffffff" },
++ { id: "#000000", name: $localize`Black`, textColor: "#ffffff" },
++ { id: "#cccccc", name: $localize`Light grey`, textColor: "#000000" }
]
export interface PaperlessTag extends MatchingModel {
diff --cc src/documents/models.py
index 5491e4038,1b94b3cc9..47361776a
--- a/src/documents/models.py
+++ b/src/documents/models.py
@@@ -5,14 -5,17 +5,18 @@@ import o
import re
from collections import OrderedDict
+ import pathvalidate
+
import dateutil.parser
+from colorhash import ColorHash
from django.conf import settings
+ from django.contrib.auth.models import User
from django.db import models
from django.utils import timezone
- from django.utils.text import slugify
+ from django.utils.timezone import is_aware
+
+ from django.utils.translation import gettext_lazy as _
- from documents.file_handling import archive_name_from_filename
from documents.parsers import get_default_file_extension
@@@ -85,23 -77,37 +78,30 @@@ class Correspondent(MatchingModel)
class Tag(MatchingModel):
- colour = models.CharField(blank=True, max_length=7)
- COLOURS = (
- (1, "#a6cee3"),
- (2, "#1f78b4"),
- (3, "#b2df8a"),
- (4, "#33a02c"),
- (5, "#fb9a99"),
- (6, "#e31a1c"),
- (7, "#fdbf6f"),
- (8, "#ff7f00"),
- (9, "#cab2d6"),
- (10, "#6a3d9a"),
- (11, "#b15928"),
- (12, "#000000"),
- (13, "#cccccc")
- )
-
- colour = models.PositiveIntegerField(
++ colour = models.CharField(
+ _("color"),
- choices=COLOURS, default=1)
++ blank=True, max_length=7)
is_inbox_tag = models.BooleanField(
+ _("is inbox tag"),
default=False,
- help_text="Marks this tag as an inbox tag: All newly consumed "
- "documents will be tagged with inbox tags."
+ help_text=_("Marks this tag as an inbox tag: All newly consumed "
+ "documents will be tagged with inbox tags.")
)
+ class Meta:
+ verbose_name = _("tag")
+ verbose_name_plural = _("tags")
+
+ def save(self, *args, **kwargs):
+ if self.colour == "":
+ self.colour = ColorHash(
+ self.name,
+ lightness=(0.35, 0.45, 0.55, 0.65),
+ saturation=(0.2, 0.3, 0.4, 0.5)).hex
+
+ super().save(*args, **kwargs)
+
class DocumentType(MatchingModel):