misc: remove RuntimeWarning naive datetime (#39438)

RuntimeWarning: DateTimeField received a naive datetime
This commit is contained in:
Lauréline Guérin 2020-01-31 10:55:19 +01:00
parent 31f2899f8f
commit d217767257
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
3 changed files with 11 additions and 5 deletions

View File

@ -174,8 +174,8 @@ def download_transactions_csv(request):
Transaction.objects
.filter(
status__in=(eopayment.PAID, eopayment.ACCEPTED),
start_date__gte=form.cleaned_data['start_date'],
start_date__lte=form.cleaned_data['end_date'],
start_date__date__gte=form.cleaned_data['start_date'],
start_date__date__lte=form.cleaned_data['end_date'],
).order_by('-start_date'))
for transaction in transactions:
row = [transaction.order_id,

View File

@ -40,6 +40,7 @@ from django.utils.encoding import python_2_unicode_compatible
from django.utils.formats import localize
from django.utils.http import urlencode
from django.utils.six.moves.urllib import parse as urlparse
from django.utils.timezone import make_aware
from django.contrib.auth.models import User
from django.template.loader import render_to_string
@ -285,11 +286,15 @@ class Regie(models.Model):
notification_id = notification_reminder_id
if not Notification.objects.find(user, notification_id).exists():
self.notify_remote_invoice_by_email(user, invoice)
payment_limit_date = datetime.datetime(
invoice.payment_limit_date.year,
invoice.payment_limit_date.month,
invoice.payment_limit_date.day)
Notification.notify(user,
summary=message,
id=notification_id,
url=items_page_url,
end_timestamp=invoice.payment_limit_date)
end_timestamp=make_aware(payment_limit_date))
return notification_id
def notify_new_remote_invoices(self):

View File

@ -6,6 +6,7 @@ from django.contrib.auth.models import User
from django.db import connection
from django.test.utils import CaptureQueriesContext
from django.utils.timezone import now
from django.utils.timezone import make_aware
import mock
import pytest
@ -167,10 +168,10 @@ def test_download_transaction(app, admin_user, payment_backend):
trans2 = Transaction.objects.create(regie=regie, remote_items='remote items omg', order_id='2', user=user,
bank_transaction_id='136', status=eopayment.PAID)
trans1.items.set([b_item])
trans1.start_date = datetime.date(2019, 7, 29)
trans1.start_date = make_aware(datetime.datetime(2019, 7, 29))
trans1.save()
trans2.items.set([b_item])
trans2.start_date = datetime.date(2019, 10, 1)
trans2.start_date = make_aware(datetime.datetime(2019, 10, 1))
trans2.save()
app = login(app)