Upgrade to Django 4.2 (#3497)

This commit is contained in:
Raphael Michel
2023-08-09 14:47:41 +02:00
committed by GitHub
parent 0853296663
commit b51c9f7552
12 changed files with 76 additions and 52 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ dependencies = [
"css-inline==0.8.*",
"defusedcsv>=1.1.0",
"dj-static",
"Django==4.1.*",
"Django==4.2.*",
"django-bootstrap3==23.1.*",
"django-compressor==4.3.*",
"django-countries==7.5.*",
+8 -1
View File
@@ -196,7 +196,14 @@ STATICFILES_DIRS = [
STATICI18N_ROOT = os.path.join(BASE_DIR, "pretix/static")
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STORAGES = {
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage",
},
}
# if os.path.exists(os.path.join(DATA_DIR, 'static')):
# STATICFILES_DIRS.insert(0, os.path.join(DATA_DIR, 'static'))
+1 -1
View File
@@ -97,7 +97,7 @@ def _transactions_mark_order_dirty(order_id, using=None):
if getattr(dirty_transactions, 'order_ids', None) is None:
dirty_transactions.order_ids = set()
if _check_for_dirty_orders not in [func for savepoint_id, func in conn.run_on_commit]:
if _check_for_dirty_orders not in [func for (savepoint_id, func, *__) in conn.run_on_commit]:
transaction.on_commit(_check_for_dirty_orders, using)
dirty_transactions.order_ids.clear() # This is necessary to clean up after old threads with rollbacked transactions
+1 -3
View File
@@ -88,9 +88,7 @@ class LogEntry(models.Model):
class Meta:
ordering = ('-datetime', '-id')
index_together = [
['datetime', 'id']
]
indexes = [models.Index(fields=["datetime", "id"])]
def display(self):
from ..signals import logentry_display
+4 -1
View File
@@ -121,7 +121,10 @@ class ReusableMedium(LoggedModel):
class Meta:
unique_together = (("identifier", "type", "organizer"),)
index_together = (("identifier", "type", "organizer"), ("updated", "id"))
indexes = [
models.Index(fields=("identifier", "type", "organizer")),
models.Index(fields=("updated", "id")),
]
ordering = "identifier", "type", "organizer"
+5 -5
View File
@@ -270,9 +270,9 @@ class Order(LockModel, LoggedModel):
verbose_name = _("Order")
verbose_name_plural = _("Orders")
ordering = ("-datetime", "-pk")
index_together = [
["datetime", "id"],
["last_modified", "id"],
indexes = [
models.Index(fields=["datetime", "id"]),
models.Index(fields=["last_modified", "id"]),
]
def __str__(self):
@@ -2756,8 +2756,8 @@ class Transaction(models.Model):
class Meta:
ordering = 'datetime', 'pk'
index_together = [
['datetime', 'id']
indexes = [
models.Index(fields=['datetime', 'id'])
]
def save(self, *args, **kwargs):
+9 -1
View File
@@ -80,7 +80,15 @@
"DATE_INPUT_FORMATS": [
"%Y-%m-%d",
"%m/%d/%Y",
"%m/%d/%y"
"%m/%d/%y",
"%b %d %Y",
"%b %d, %Y",
"%d %b %Y",
"%d %b, %Y",
"%B %d %Y",
"%B %d, %Y",
"%d %B %Y",
"%d %B, %Y"
],
"DECIMAL_SEPARATOR": ".",
"FIRST_DAY_OF_WEEK": 0,
+1 -1
View File
@@ -42,7 +42,7 @@ EMAIL_BACKEND = EMAIL_CUSTOM_SMTP_BACKEND = 'django.core.mail.backends.locmem.Em
COMPRESS_ENABLED = COMPRESS_OFFLINE = False
COMPRESS_CACHE_BACKEND = 'testcache'
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
STORAGES["staticfiles"]["BACKEND"] = 'django.contrib.staticfiles.storage.StaticFilesStorage'
PRETIX_INSTANCE_NAME = 'pretix.eu'
COMPRESS_PRECOMPILERS_ORIGINAL = COMPRESS_PRECOMPILERS
+2
View File
@@ -21,6 +21,8 @@ addopts = --reruns 3 -rw
filterwarnings =
error
ignore:The 'warn' method is deprecated:DeprecationWarning
ignore::django.utils.deprecation.RemovedInDjango51Warning:django.core.files.storage
ignore:.*index_together.*:django.utils.deprecation.RemovedInDjango51Warning:
ignore::DeprecationWarning:mt940
ignore::DeprecationWarning:cbor2
ignore::DeprecationWarning:markdown
+2 -2
View File
@@ -940,8 +940,8 @@ def test_rules_reasoning_prefer_number_over_date(event, position, clist):
@pytest.mark.django_db(transaction=True)
def test_position_queries(django_assert_num_queries, position, clist):
with django_assert_num_queries(12 if 'sqlite' in settings.DATABASES['default']['ENGINE'] else 11) as captured:
def test_position_queries(django_assert_max_num_queries, position, clist):
with django_assert_max_num_queries(13) as captured:
perform_checkin(position, clist, {})
if 'sqlite' not in settings.DATABASES['default']['ENGINE']:
assert any('FOR UPDATE' in s['sql'] for s in captured)
+36 -36
View File
@@ -38,10 +38,10 @@ class I18nStringTest(TestCase):
'en': 'Hello'
}
s = LazyI18nString(data)
translation.activate('en')
self.assertEqual(str(s), 'Hello')
translation.activate('de')
self.assertEqual(str(s), 'Hallo')
with translation.override('en'):
self.assertEqual(str(s), 'Hello')
with translation.override('de'):
self.assertEqual(str(s), 'Hallo')
def test_similar_translations(self):
data = {
@@ -50,57 +50,57 @@ class I18nStringTest(TestCase):
'de-informal': 'Du'
}
s = LazyI18nString(data)
translation.activate('de')
self.assertEqual(str(s), 'Sie')
translation.activate('de-informal')
self.assertEqual(str(s), 'Du')
with translation.override('de'):
self.assertEqual(str(s), 'Sie')
with translation.override('de-informal'):
self.assertEqual(str(s), 'Du')
data = {
'en': 'You',
'de-informal': 'Du'
}
s = LazyI18nString(data)
translation.activate('de')
self.assertEqual(str(s), 'Du')
translation.activate('de-informal')
self.assertEqual(str(s), 'Du')
with translation.override('de'):
self.assertEqual(str(s), 'Du')
with translation.override('de-informal'):
self.assertEqual(str(s), 'Du')
data = {
'en': 'You',
'de': 'Sie'
}
s = LazyI18nString(data)
translation.activate('de')
self.assertEqual(str(s), 'Sie')
translation.activate('de-informal')
self.assertEqual(str(s), 'Sie')
with translation.override('de'):
self.assertEqual(str(s), 'Sie')
with translation.override('de-informal'):
self.assertEqual(str(s), 'Sie')
def test_missing_default_translation(self):
data = {
'de': 'Hallo',
}
s = LazyI18nString(data)
translation.activate('en')
self.assertEqual(str(s), 'Hallo')
translation.activate('de')
self.assertEqual(str(s), 'Hallo')
with translation.override('en'):
self.assertEqual(str(s), 'Hallo')
with translation.override('de'):
self.assertEqual(str(s), 'Hallo')
def test_missing_translation(self):
data = {
'en': 'Hello',
}
s = LazyI18nString(data)
translation.activate('en')
self.assertEqual(str(s), 'Hello')
translation.activate('de')
self.assertEqual(str(s), 'Hello')
with translation.override('en'):
self.assertEqual(str(s), 'Hello')
with translation.override('de'):
self.assertEqual(str(s), 'Hello')
def test_legacy_string(self):
s = LazyI18nString("Hello")
translation.activate('en')
self.assertEqual(str(s), 'Hello')
translation.activate('de')
self.assertEqual(str(s), 'Hello')
with translation.override('en'):
self.assertEqual(str(s), 'Hello')
with translation.override('de'):
self.assertEqual(str(s), 'Hello')
def test_none(self):
s = LazyI18nString(None)
@@ -124,10 +124,10 @@ class I18nFieldTest(TestCase):
obj = ItemCategory.objects.create(event=self.event, name="Hello")
obj = ItemCategory.objects.get(id=obj.id)
self.assertIsInstance(obj.name, LazyI18nString)
translation.activate('en')
self.assertEqual(str(obj.name), "Hello")
translation.activate('de')
self.assertEqual(str(obj.name), "Hello")
with translation.override('en'):
self.assertEqual(str(obj.name), "Hello")
with translation.override('de'):
self.assertEqual(str(obj.name), "Hello")
def test_save_load_cycle_i18n_string(self):
obj = ItemCategory.objects.create(event=self.event,
@@ -139,7 +139,7 @@ class I18nFieldTest(TestCase):
))
obj = ItemCategory.objects.get(id=obj.id)
self.assertIsInstance(obj.name, LazyI18nString)
translation.activate('en')
self.assertEqual(str(obj.name), "Hello")
translation.activate('de')
self.assertEqual(str(obj.name), "Hallo")
with translation.override('en'):
self.assertEqual(str(obj.name), "Hello")
with translation.override('de'):
self.assertEqual(str(obj.name), "Hallo")
+6
View File
@@ -22,6 +22,7 @@
import inspect
import pytest
from django.utils import translation
from django_scopes import scopes_disabled
from xdist.dsession import DSession
@@ -68,3 +69,8 @@ def pytest_fixture_setup(fixturedef, request):
else:
with scopes_disabled():
yield
@pytest.fixture(autouse=True)
def reset_locale():
translation.activate("en")