mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 03:16:10 -06:00 
			
		
		
		
	Make DocumentSerializer return the original_filename
Make get_original_file_name return the original filename instead of the public filename.
This commit is contained in:
		@@ -414,7 +414,7 @@ class DocumentSerializer(OwnedObjectSerializer, DynamicFieldsModelSerializer):
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    def get_original_file_name(self, obj):
 | 
			
		||||
        return obj.get_public_filename()
 | 
			
		||||
        return obj.original_filename
 | 
			
		||||
 | 
			
		||||
    def get_archived_file_name(self, obj):
 | 
			
		||||
        if obj.has_archive_version:
 | 
			
		||||
 
 | 
			
		||||
@@ -579,6 +579,7 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase):
 | 
			
		||||
            content="things i paid for in september",
 | 
			
		||||
            pk=3,
 | 
			
		||||
            checksum="C",
 | 
			
		||||
            original_filename="someepdf.pdf",
 | 
			
		||||
        )
 | 
			
		||||
        with AsyncWriter(index.open_index()) as writer:
 | 
			
		||||
            # Note to future self: there is a reason we dont use a model signal handler to update the index: some operations edit many documents at once
 | 
			
		||||
@@ -598,6 +599,7 @@ class TestDocumentApi(DirectoriesMixin, DocumentConsumeDelayMixin, APITestCase):
 | 
			
		||||
        self.assertEqual(response.data["count"], 1)
 | 
			
		||||
        self.assertEqual(len(results), 1)
 | 
			
		||||
        self.assertCountEqual(response.data["all"], [d3.id])
 | 
			
		||||
        self.assertEqual(results[0]["original_file_name"], "someepdf.pdf")
 | 
			
		||||
 | 
			
		||||
        response = self.client.get("/api/documents/?query=statement")
 | 
			
		||||
        results = response.data["results"]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user