mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 19:17:13 -05:00 
			
		
		
		
	Merge pull request #143 from danielquinn/issue/121
Actually write the date found in the file name. Closes #121.
This commit is contained in:
		
						commit
						53909cf9b0
					
				@ -293,6 +293,9 @@ class Consumer(object):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        self.log("debug", "Saving record to database")
 | 
					        self.log("debug", "Saving record to database")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        created = file_info.created or timezone.make_aware(
 | 
				
			||||||
 | 
					                    datetime.datetime.fromtimestamp(stats.st_mtime))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        with open(doc, "rb") as f:
 | 
					        with open(doc, "rb") as f:
 | 
				
			||||||
            document = Document.objects.create(
 | 
					            document = Document.objects.create(
 | 
				
			||||||
                correspondent=file_info.correspondent,
 | 
					                correspondent=file_info.correspondent,
 | 
				
			||||||
@ -300,10 +303,8 @@ class Consumer(object):
 | 
				
			|||||||
                content=text,
 | 
					                content=text,
 | 
				
			||||||
                file_type=file_info.extension,
 | 
					                file_type=file_info.extension,
 | 
				
			||||||
                checksum=hashlib.md5(f.read()).hexdigest(),
 | 
					                checksum=hashlib.md5(f.read()).hexdigest(),
 | 
				
			||||||
                created=timezone.make_aware(
 | 
					                created=created,
 | 
				
			||||||
                    datetime.datetime.fromtimestamp(stats.st_mtime)),
 | 
					                modified=created
 | 
				
			||||||
                modified=timezone.make_aware(
 | 
					 | 
				
			||||||
                    datetime.datetime.fromtimestamp(stats.st_mtime))
 | 
					 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        relevant_tags = set(list(Tag.match_all(text)) + list(file_info.tags))
 | 
					        relevant_tags = set(list(Tag.match_all(text)) + list(file_info.tags))
 | 
				
			||||||
 | 
				
			|||||||
@ -376,6 +376,7 @@ class FileInfo(object):
 | 
				
			|||||||
        """
 | 
					        """
 | 
				
			||||||
        We use a crude naming convention to make handling the correspondent,
 | 
					        We use a crude naming convention to make handling the correspondent,
 | 
				
			||||||
        title, and tags easier:
 | 
					        title, and tags easier:
 | 
				
			||||||
 | 
					          "<date> - <correspondent> - <title> - <tags>.<suffix>"
 | 
				
			||||||
          "<correspondent> - <title> - <tags>.<suffix>"
 | 
					          "<correspondent> - <title> - <tags>.<suffix>"
 | 
				
			||||||
          "<correspondent> - <title>.<suffix>"
 | 
					          "<correspondent> - <title>.<suffix>"
 | 
				
			||||||
          "<title>.<suffix>"
 | 
					          "<title>.<suffix>"
 | 
				
			||||||
 | 
				
			|||||||
@ -3,7 +3,7 @@ from django.test import TestCase
 | 
				
			|||||||
from ..models import FileInfo
 | 
					from ..models import FileInfo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestAttachment(TestCase):
 | 
					class TestAttributes(TestCase):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    TAGS = ("tag1", "tag2", "tag3")
 | 
					    TAGS = ("tag1", "tag2", "tag3")
 | 
				
			||||||
    EXTENSIONS = (
 | 
					    EXTENSIONS = (
 | 
				
			||||||
@ -154,7 +154,6 @@ class Permutations(TestCase):
 | 
				
			|||||||
                                 correspondent=None, title=None,
 | 
					                                 correspondent=None, title=None,
 | 
				
			||||||
                                 extension=None, tags=None):
 | 
					                                 extension=None, tags=None):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # print(filename)
 | 
					 | 
				
			||||||
        info = FileInfo.from_path(filename)
 | 
					        info = FileInfo.from_path(filename)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # Created
 | 
					        # Created
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user