mirror of
https://github.com/pretix/pretix.git
synced 2025-12-05 21:32:28 +00:00
Compare commits
4 Commits
fix-order-
...
event-date
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
feb2ec0d48 | ||
|
|
f3eb6b33e6 | ||
|
|
3a774db641 | ||
|
|
6245d1f286 |
@@ -60,7 +60,6 @@ from django.urls import reverse
|
||||
from django.utils.crypto import get_random_string
|
||||
from django.utils.formats import date_format
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.html import format_html
|
||||
from django.utils.timezone import make_aware, now
|
||||
from django.utils.translation import gettext, gettext_lazy as _
|
||||
from django_scopes import ScopedManager, scopes_disabled
|
||||
@@ -180,14 +179,10 @@ class EventMixin:
|
||||
"""
|
||||
tz = tz or self.timezone
|
||||
if (not self.settings.show_date_to and not force_show_end) or not self.date_to:
|
||||
if as_html:
|
||||
return format_html(
|
||||
"<time datetime=\"{}\">{}</time>",
|
||||
_date(self.date_from.astimezone(tz), "Y-m-d"),
|
||||
_date(self.date_from.astimezone(tz), "DATE_FORMAT"),
|
||||
)
|
||||
return _date(self.date_from.astimezone(tz), "DATE_FORMAT")
|
||||
return daterange(self.date_from.astimezone(tz), self.date_to.astimezone(tz), as_html)
|
||||
df, dt = self.date_from, self.date_from
|
||||
else:
|
||||
df, dt = self.date_from, self.date_to
|
||||
return daterange(df.astimezone(tz), dt.astimezone(tz), as_html)
|
||||
|
||||
def get_date_range_display_as_html(self, tz=None, force_show_end=False) -> str:
|
||||
return self.get_date_range_display(tz, force_show_end, as_html=True)
|
||||
|
||||
@@ -53,14 +53,14 @@ def daterange(df, dt, as_html=False):
|
||||
|
||||
if lng.startswith("de"):
|
||||
if df.year == dt.year and df.month == dt.month and df.day == dt.day:
|
||||
return format_html(base_format, _date(df, "j. F Y"))
|
||||
return format_html(base_format, _date(df, "D, j. F Y"))
|
||||
elif df.year == dt.year and df.month == dt.month:
|
||||
return format_html(base_format, _date(df, "j."), "–", _date(dt, "j. F Y"))
|
||||
elif df.year == dt.year:
|
||||
return format_html(base_format, _date(df, "j. F"), " – ", _date(dt, "j. F Y"))
|
||||
elif lng.startswith("en"):
|
||||
if df.year == dt.year and df.month == dt.month and df.day == dt.day:
|
||||
return format_html(base_format, _date(df, "N jS, Y"))
|
||||
return format_html(base_format, _date(df, "D, N jS, Y"))
|
||||
elif df.year == dt.year and df.month == dt.month:
|
||||
return format_html(base_format, _date(df, "N jS"), " – ", _date(dt, "jS, Y"))
|
||||
elif df.year == dt.year:
|
||||
|
||||
@@ -43,15 +43,15 @@ from pretix.helpers.daterange import daterange, datetimerange
|
||||
def test_same_day_german():
|
||||
with translation.override('de'):
|
||||
df = date(2003, 2, 1)
|
||||
assert daterange(df, df) == "1. Februar 2003"
|
||||
assert daterange(df, df, as_html=True) == '<time datetime="2003-02-01">1. Februar 2003</time>'
|
||||
assert daterange(df, df) == "Sa, 1. Februar 2003"
|
||||
assert daterange(df, df, as_html=True) == '<time datetime="2003-02-01">Sa, 1. Februar 2003</time>'
|
||||
|
||||
|
||||
def test_same_day_english():
|
||||
with translation.override('en'):
|
||||
df = date(2003, 2, 1)
|
||||
assert daterange(df, df) == "Feb. 1st, 2003"
|
||||
assert daterange(df, df, as_html=True) == '<time datetime="2003-02-01">Feb. 1st, 2003</time>'
|
||||
assert daterange(df, df) == "Sat, Feb. 1st, 2003"
|
||||
assert daterange(df, df, as_html=True) == '<time datetime="2003-02-01">Sat, Feb. 1st, 2003</time>'
|
||||
|
||||
|
||||
def test_same_day_spanish():
|
||||
|
||||
@@ -1599,7 +1599,7 @@ class EventLocaleTest(EventTestMixin, SoupTest):
|
||||
'/%s/%s/' % (self.orga.slug, self.event.slug)
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertIn('Dec. 26,', response.rendered_content)
|
||||
self.assertIn('Fri, Dec. 26th,', response.rendered_content)
|
||||
self.assertIn('14:00', response.rendered_content)
|
||||
|
||||
def test_english_region_US(self):
|
||||
@@ -1609,7 +1609,7 @@ class EventLocaleTest(EventTestMixin, SoupTest):
|
||||
'/%s/%s/' % (self.orga.slug, self.event.slug)
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertIn('Dec. 26,', response.rendered_content)
|
||||
self.assertIn('Fri, Dec. 26th,', response.rendered_content)
|
||||
self.assertIn('2 p.m.', response.rendered_content)
|
||||
|
||||
def test_german_region_US(self):
|
||||
@@ -1619,5 +1619,5 @@ class EventLocaleTest(EventTestMixin, SoupTest):
|
||||
'/%s/%s/' % (self.orga.slug, self.event.slug)
|
||||
)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertIn('26. Dezember', response.rendered_content)
|
||||
self.assertIn('Fr, 26. Dezember', response.rendered_content)
|
||||
self.assertIn('14:00', response.rendered_content)
|
||||
|
||||
@@ -169,7 +169,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"target_url": "http://example.com/ccc/30c3/",
|
||||
"subevent": None,
|
||||
"name": "30C3",
|
||||
"date_range": f"Dec. 26, {self.event.date_from.year} 00:00",
|
||||
"date_range": f"{self.event.date_from.strftime('%a')}, Dec. 26th, {self.event.date_from.year} 00:00",
|
||||
"frontpage_text": "",
|
||||
"location": "",
|
||||
"currency": "EUR",
|
||||
@@ -375,7 +375,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"target_url": "http://example.com/ccc/30c3/",
|
||||
"subevent": None,
|
||||
"name": "30C3",
|
||||
"date_range": f"Dec. 26, {self.event.date_from.year} 00:00",
|
||||
"date_range": f"{self.event.date_from.strftime('%a')}, Dec. 26th, {self.event.date_from.year} 00:00",
|
||||
"frontpage_text": "",
|
||||
"location": "",
|
||||
"currency": "EUR",
|
||||
@@ -435,7 +435,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"target_url": "http://example.com/ccc/30c3/",
|
||||
"subevent": None,
|
||||
"name": "30C3",
|
||||
"date_range": f"Dec. 26, {self.event.date_from.year} 00:00",
|
||||
"date_range": f"{self.event.date_from.strftime('%a')}, Dec. 26th, {self.event.date_from.year} 00:00",
|
||||
"frontpage_text": "",
|
||||
"location": "",
|
||||
"currency": "EUR",
|
||||
@@ -520,7 +520,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
"target_url": "http://example.com/ccc/30c3/",
|
||||
"subevent": None,
|
||||
"name": "30C3",
|
||||
"date_range": f"Dec. 26, {self.event.date_from.year} 00:00",
|
||||
"date_range": f"{self.event.date_from.strftime('%a')}, Dec. 26th, {self.event.date_from.year} 00:00",
|
||||
"frontpage_text": "",
|
||||
"location": "",
|
||||
"currency": "EUR",
|
||||
@@ -627,9 +627,9 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
'poweredby': '<a href="https://pretix.eu" target="_blank" rel="noopener">ticketing powered by pretix</a>',
|
||||
'has_more_events': False,
|
||||
'events': [
|
||||
{'name': 'Present', 'date_range': 'Jan. 1, 2019 11:00', 'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
{'name': 'Present', 'date_range': 'Tue, Jan. 1st, 2019 11:00', 'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
'event_url': 'http://example.com/ccc/30c3/', 'subevent': se1.pk, 'location': ''},
|
||||
{'name': 'Future', 'date_range': 'Jan. 4, 2019 11:00', 'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
{'name': 'Future', 'date_range': 'Fri, Jan. 4th, 2019 11:00', 'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
'event_url': 'http://example.com/ccc/30c3/', 'subevent': se2.pk, 'location': ''}
|
||||
]
|
||||
}
|
||||
@@ -659,14 +659,14 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
[
|
||||
None,
|
||||
{'day': 1, 'date': '2019-01-01', 'events': [
|
||||
{'name': 'Present', 'time': '11:00', 'continued': False, 'date_range': 'Jan. 1, 2019 11:00',
|
||||
{'name': 'Present', 'time': '11:00', 'continued': False, 'date_range': 'Tue, Jan. 1st, 2019 11:00',
|
||||
'location': '',
|
||||
'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
'event_url': 'http://example.com/ccc/30c3/', 'subevent': se1.pk}]},
|
||||
{'day': 2, 'date': '2019-01-02', 'events': []},
|
||||
{'day': 3, 'date': '2019-01-03', 'events': []},
|
||||
{'day': 4, 'date': '2019-01-04', 'events': [
|
||||
{'name': 'Future', 'time': '11:00', 'continued': False, 'date_range': 'Jan. 4, 2019 11:00',
|
||||
{'name': 'Future', 'time': '11:00', 'continued': False, 'date_range': 'Fri, Jan. 4th, 2019 11:00',
|
||||
'location': '',
|
||||
'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
'event_url': 'http://example.com/ccc/30c3/', 'subevent': se2.pk}]},
|
||||
@@ -734,14 +734,14 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
'days': [
|
||||
{'day_formatted': 'Mon, Dec 31st', 'date': '2018-12-31', 'events': [], 'today': False},
|
||||
{'day_formatted': 'Tue, Jan 1st', 'date': '2019-01-01', 'events': [
|
||||
{'name': 'Present', 'time': '11:00', 'continued': False, 'date_range': 'Jan. 1, 2019 11:00',
|
||||
{'name': 'Present', 'time': '11:00', 'continued': False, 'date_range': 'Tue, Jan. 1st, 2019 11:00',
|
||||
'location': '',
|
||||
'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
'event_url': 'http://example.com/ccc/30c3/', 'subevent': se1.pk}], 'today': True},
|
||||
{'day_formatted': 'Wed, Jan 2nd', 'date': '2019-01-02', 'events': [], 'today': False},
|
||||
{'day_formatted': 'Thu, Jan 3rd', 'date': '2019-01-03', 'events': [], 'today': False},
|
||||
{'day_formatted': 'Fri, Jan 4th', 'date': '2019-01-04', 'events': [
|
||||
{'name': 'Future', 'time': '11:00', 'continued': False, 'date_range': 'Jan. 4, 2019 11:00',
|
||||
{'name': 'Future', 'time': '11:00', 'continued': False, 'date_range': 'Fri, Jan. 4th, 2019 11:00',
|
||||
'location': '',
|
||||
'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
'event_url': 'http://example.com/ccc/30c3/', 'subevent': se2.pk}], 'today': False},
|
||||
@@ -778,12 +778,12 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
'location': '',
|
||||
'name': '30C3'},
|
||||
{'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
'date_range': 'Jan. 1, 2019 10:00',
|
||||
'date_range': 'Tue, Jan. 1st, 2019 10:00',
|
||||
'location': '',
|
||||
'event_url': 'http://example.com/ccc/present/',
|
||||
'name': 'Present'},
|
||||
{'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
'date_range': 'Jan. 4, 2019 10:00',
|
||||
'date_range': 'Fri, Jan. 4th, 2019 10:00',
|
||||
'location': '',
|
||||
'event_url': 'http://example.com/ccc/future/',
|
||||
'name': 'Future'}
|
||||
@@ -884,7 +884,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
'day': 1,
|
||||
'events': [{'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
'continued': False,
|
||||
'date_range': 'Jan. 1, 2019 10:00',
|
||||
'date_range': 'Tue, Jan. 1st, 2019 10:00',
|
||||
'event_url': 'http://example.com/ccc/present/',
|
||||
'name': 'Present',
|
||||
'location': '',
|
||||
@@ -892,7 +892,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
'time': '10:00'},
|
||||
{'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
'continued': False,
|
||||
'date_range': 'Jan. 1, 2019 11:00',
|
||||
'date_range': 'Tue, Jan. 1st, 2019 11:00',
|
||||
'event_url': 'http://example.com/ccc/30c3/',
|
||||
'name': 'Present',
|
||||
'location': '',
|
||||
@@ -904,7 +904,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
'day': 4,
|
||||
'events': [{'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
'continued': False,
|
||||
'date_range': 'Jan. 4, 2019 10:00',
|
||||
'date_range': 'Fri, Jan. 4th, 2019 10:00',
|
||||
'event_url': 'http://example.com/ccc/future/',
|
||||
'name': 'Future',
|
||||
'location': '',
|
||||
@@ -912,7 +912,7 @@ class WidgetCartTest(CartTestMixin, TestCase):
|
||||
'time': '10:00'},
|
||||
{'availability': {'color': 'none', 'text': 'More info', 'reason': 'unknown'},
|
||||
'continued': False,
|
||||
'date_range': 'Jan. 4, 2019 11:00',
|
||||
'date_range': 'Fri, Jan. 4th, 2019 11:00',
|
||||
'event_url': 'http://example.com/ccc/30c3/',
|
||||
'name': 'Future',
|
||||
'location': '',
|
||||
|
||||
Reference in New Issue
Block a user