misc: remove compatibility code for old django versions (#74247) #40
|
@ -1,6 +1,5 @@
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import django
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from combo.utils import requests
|
from combo.utils import requests
|
||||||
|
@ -73,13 +72,7 @@ def update_available_statistics():
|
||||||
statistics_to_create.append(stat)
|
statistics_to_create.append(stat)
|
||||||
|
|
||||||
Statistic.objects.bulk_create(statistics_to_create)
|
Statistic.objects.bulk_create(statistics_to_create)
|
||||||
if django.VERSION < (2, 2, 0):
|
Statistic.objects.bulk_update(statistics_to_update.values(), update_fields)
|
||||||
for statistic in statistics_to_update.values():
|
|
||||||
Statistic.objects.filter(pk=statistic.pk).update(
|
|
||||||
**{field: getattr(statistic, field) for field in update_fields}
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
Statistic.objects.bulk_update(statistics_to_update.values(), update_fields)
|
|
||||||
|
|
||||||
available_stats = Statistic.objects.filter(available=True)
|
available_stats = Statistic.objects.filter(available=True)
|
||||||
for stat in results:
|
for stat in results:
|
||||||
|
|
|
@ -16,16 +16,10 @@
|
||||||
|
|
||||||
# Decorating URL includes, <https://djangosnippets.org/snippets/2532/>
|
# Decorating URL includes, <https://djangosnippets.org/snippets/2532/>
|
||||||
|
|
||||||
import django
|
|
||||||
from django.contrib.auth.decorators import user_passes_test
|
from django.contrib.auth.decorators import user_passes_test
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
from django.urls.resolvers import URLPattern, URLResolver
|
||||||
if django.VERSION < (2, 0, 0):
|
|
||||||
from django.urls.resolvers import RegexURLPattern as URLPattern # pylint: disable=no-name-in-module
|
|
||||||
from django.urls.resolvers import RegexURLResolver as URLResolver # pylint: disable=no-name-in-module
|
|
||||||
else:
|
|
||||||
from django.urls.resolvers import URLPattern, URLResolver
|
|
||||||
|
|
||||||
|
|
||||||
class DecoratedURLPattern(URLPattern):
|
class DecoratedURLPattern(URLPattern):
|
||||||
|
|
Loading…
Reference in New Issue