Synchronize cart countdown with server time

This commit is contained in:
Raphael Michel
2017-11-01 20:46:37 +01:00
parent 2678100149
commit 10103b58f0
3 changed files with 24 additions and 5 deletions

View File

@@ -36,7 +36,7 @@
<link rel="icon" href="{% static "pretixbase/img/favicon.ico" %}">
{% block custom_header %}{% endblock %}
</head>
<body data-locale="{{ request.LANGUAGE_CODE }}">
<body data-locale="{{ request.LANGUAGE_CODE }}" data-now="{% now "U.u" %}">
{% block above %}
{% endblock %}
<div class="container">

View File

@@ -133,8 +133,9 @@ class CartMixin:
try:
first_expiry = min(p.expires for p in positions) if positions else now()
minutes_left = max(first_expiry - now(), timedelta()).seconds // 60
seconds_left = max(first_expiry - now(), timedelta()).seconds % 60
total_seconds_left = max(first_expiry - now(), timedelta()).total_seconds()
minutes_left = total_seconds_left // 60
seconds_left = total_seconds_left % 60
except AttributeError:
first_expiry = None
minutes_left = None