mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-31 10:37:12 -04:00 
			
		
		
		
	Actually handle the change to using a Sender model
This commit is contained in:
		
							parent
							
								
									d1c811555c
								
							
						
					
					
						commit
						2e48036f92
					
				| @ -7,7 +7,7 @@ from .models import Sender, Document | ||||
| 
 | ||||
| class DocumentAdmin(admin.ModelAdmin): | ||||
| 
 | ||||
|     search_fields = ("sender", "title", "content",) | ||||
|     search_fields = ("sender__name", "title", "content",) | ||||
|     list_display = ("edit", "created", "sender", "title", "pdf") | ||||
|     list_filter = ("created", "sender") | ||||
|     save_on_top = True | ||||
|  | ||||
| @ -13,9 +13,10 @@ from PIL import Image | ||||
| 
 | ||||
| from django.conf import settings | ||||
| from django.core.management.base import BaseCommand | ||||
| from django.template.defaultfilters import slugify | ||||
| from django.utils import timezone | ||||
| 
 | ||||
| from documents.models import Document | ||||
| from documents.models import Document, Sender | ||||
| 
 | ||||
| 
 | ||||
| class Command(BaseCommand): | ||||
| @ -170,7 +171,10 @@ class Command(BaseCommand): | ||||
| 
 | ||||
|         m = re.match(self.PARSER_REGEX, pdf) | ||||
|         if m: | ||||
|             return m.group(1), m.group(2) | ||||
|             sender_name, title = m.group(1), m.group(2) | ||||
|             sender, __ = Sender.objects.get_or_create( | ||||
|                 name=sender_name, defaults={"slug": slugify(sender_name)}) | ||||
|             return sender, title | ||||
| 
 | ||||
|         return "", "" | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user