mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-31 02:27:10 -04: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
					
				| @ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user