mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Merge pull request #853 from lippoliv/bugfix-document_exporter-document-dates-are-off-by-one-day-#267
Bugfix document exporter document dates are off by one day #267
This commit is contained in:
		| @@ -11,7 +11,6 @@ from django.conf import settings | ||||
| from django.contrib.auth.models import User | ||||
| from django.db import models | ||||
| from django.utils import timezone | ||||
| from django.utils.timezone import is_aware | ||||
| from django.utils.translation import gettext_lazy as _ | ||||
| from documents.parsers import get_default_file_extension | ||||
|  | ||||
| @@ -210,10 +209,8 @@ class Document(models.Model): | ||||
|         verbose_name_plural = _("documents") | ||||
|  | ||||
|     def __str__(self): | ||||
|         if is_aware(self.created): | ||||
|             created = timezone.localdate(self.created).isoformat() | ||||
|         else: | ||||
|         created = datetime.date.isoformat(self.created) | ||||
|  | ||||
|         if self.correspondent and self.title: | ||||
|             return f"{created} {self.correspondent} {self.title}" | ||||
|         else: | ||||
|   | ||||
| @@ -3,6 +3,11 @@ import tempfile | ||||
| from pathlib import Path | ||||
| from unittest import mock | ||||
|  | ||||
| try: | ||||
|     import zoneinfo | ||||
| except ImportError: | ||||
|     import backports.zoneinfo as zoneinfo | ||||
|  | ||||
| from django.test import override_settings | ||||
| from django.test import TestCase | ||||
| from django.utils import timezone | ||||
| @@ -55,6 +60,24 @@ class TestDocument(TestCase): | ||||
|         ) | ||||
|         self.assertEqual(doc.get_public_filename(), "2020-12-25 test.pdf") | ||||
|  | ||||
|     def test_file_name_with_timezone(self): | ||||
|  | ||||
|         doc = Document( | ||||
|             mime_type="application/pdf", | ||||
|             title="test", | ||||
|             created=timezone.datetime( | ||||
|                 2020, | ||||
|                 12, | ||||
|                 25, | ||||
|                 0, | ||||
|                 0, | ||||
|                 0, | ||||
|                 0, | ||||
|                 zoneinfo.ZoneInfo("Europe/Berlin"), | ||||
|             ), | ||||
|         ) | ||||
|         self.assertEqual(doc.get_public_filename(), "2020-12-25 test.pdf") | ||||
|  | ||||
|     def test_file_name_jpg(self): | ||||
|  | ||||
|         doc = Document( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Quinn Casey
					Quinn Casey