mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06: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:
		@@ -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):
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user