mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-12 01:26:47 +01:00
automatically update documents whenever a tag or correspondent is changed (this should make the document_retagger and document_correspondent managers somewhat obsolete (?)
This commit is contained in:
parent
c3a144f2ca
commit
e143a20f50
1 changed files with 14 additions and 0 deletions
|
|
@ -110,6 +110,13 @@ class CorrespondentAdmin(CommonAdmin):
|
|||
list_filter = ("matching_algorithm",)
|
||||
list_editable = ("match", "matching_algorithm")
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
super().save_model(request, obj, form, change)
|
||||
|
||||
for document in Document.objects.filter(correspondent__isnull=True).exclude(tags__is_archived_tag=True):
|
||||
if obj.matches(document.content):
|
||||
document.correspondent = obj
|
||||
document.save(update_fields=("correspondent",))
|
||||
|
||||
class TagAdmin(CommonAdmin):
|
||||
|
||||
|
|
@ -117,6 +124,13 @@ class TagAdmin(CommonAdmin):
|
|||
list_filter = ("colour", "matching_algorithm")
|
||||
list_editable = ("colour", "match", "matching_algorithm")
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
super().save_model(request, obj, form, change)
|
||||
|
||||
for document in Document.objects.all().exclude(tags__is_archived_tag=True):
|
||||
if obj.matches(document.content):
|
||||
document.tags.add(obj)
|
||||
|
||||
|
||||
class DocumentAdmin(CommonAdmin):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue