forked from CGM_Public/pretix_original
Fix #296 -- DST issues with expiry dates
This commit is contained in:
@@ -281,7 +281,7 @@ def _create_order(event: Event, email: str, positions: List[CartPosition], now_d
|
|||||||
|
|
||||||
tz = pytz.timezone(event.settings.timezone)
|
tz = pytz.timezone(event.settings.timezone)
|
||||||
exp_by_date = now_dt.astimezone(tz) + timedelta(days=event.settings.get('payment_term_days', as_type=int))
|
exp_by_date = now_dt.astimezone(tz) + timedelta(days=event.settings.get('payment_term_days', as_type=int))
|
||||||
exp_by_date = exp_by_date.replace(hour=23, minute=59, second=59, microsecond=0)
|
exp_by_date = exp_by_date.astimezone(tz).replace(hour=23, minute=59, second=59, microsecond=0)
|
||||||
if event.settings.get('payment_term_weekdays'):
|
if event.settings.get('payment_term_weekdays'):
|
||||||
if exp_by_date.weekday() == 5:
|
if exp_by_date.weekday() == 5:
|
||||||
exp_by_date += timedelta(days=2)
|
exp_by_date += timedelta(days=2)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from datetime import datetime, timedelta
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import pytz
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.utils.timezone import make_aware, now
|
from django.utils.timezone import make_aware, now
|
||||||
|
|
||||||
@@ -70,6 +71,19 @@ def test_expiry_last(event):
|
|||||||
assert (order.expires - today).days == 5
|
assert (order.expires - today).days == 5
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_expiry_dst(event):
|
||||||
|
event.settings.set('timezone', 'Europe/Berlin')
|
||||||
|
tz = pytz.timezone('Europe/Berlin')
|
||||||
|
utc = pytz.timezone('UTC')
|
||||||
|
today = tz.localize(datetime(2016, 10, 29, 12, 0, 0)).astimezone(utc)
|
||||||
|
order = _create_order(event, email='dummy@example.org', positions=[],
|
||||||
|
now_dt=today, payment_provider=FreeOrderProvider(event),
|
||||||
|
locale='de')
|
||||||
|
localex = order.expires.astimezone(tz)
|
||||||
|
assert (localex.hour, localex.minute) == (23, 59)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_expiring(event):
|
def test_expiring(event):
|
||||||
o1 = Order.objects.create(
|
o1 = Order.objects.create(
|
||||||
|
|||||||
Reference in New Issue
Block a user