misc: change django-upgrade target version to 3.2 (#75442)

This commit is contained in:
Valentin Deniaud 2023-03-15 17:37:26 +01:00 committed by Gitea
parent a6b7634787
commit 66b12b846a
54 changed files with 38 additions and 103 deletions

View File

@ -7,10 +7,10 @@ repos:
- id: pyupgrade - id: pyupgrade
args: ['--keep-percent-format', '--py37-plus'] args: ['--keep-percent-format', '--py37-plus']
- repo: https://github.com/adamchainz/django-upgrade - repo: https://github.com/adamchainz/django-upgrade
rev: 1.10.0 rev: 1.13.0
hooks: hooks:
- id: django-upgrade - id: django-upgrade
args: ['--target-version', '2.2'] args: ['--target-version', '3.2']
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 22.3.0 rev: 22.3.0
hooks: hooks:

2
README
View File

@ -110,7 +110,7 @@ djhtml is used to automatically indent html files, using those parameters:
django-upgrade is used to automatically upgrade Django syntax, using those parameters: django-upgrade is used to automatically upgrade Django syntax, using those parameters:
django-upgrade --target-version 2.2 django-upgrade --target-version 3.2
There is .pre-commit-config.yaml to use pre-commit to automatically run these tools There is .pre-commit-config.yaml to use pre-commit to automatically run these tools
before commits. (execute `pre-commit install` to install the git hook.) before commits. (execute `pre-commit install` to install the git hook.)

View File

@ -30,6 +30,3 @@ class AppConfig(django.apps.AppConfig):
def get_extra_manager_actions(self): def get_extra_manager_actions(self):
return [{'href': reverse('combo-manager-assets'), 'text': _('Assets')}] return [{'href': reverse('combo-manager-assets'), 'text': _('Assets')}]
default_app_config = 'combo.apps.assets.AppConfig'

View File

@ -26,6 +26,3 @@ class AppConfig(django.apps.AppConfig):
from . import urls from . import urls
return urls.urlpatterns return urls.urlpatterns
default_app_config = 'combo.apps.calendar.AppConfig'

View File

@ -34,6 +34,3 @@ class AppConfig(django.apps.AppConfig):
ConfigJsonCell.objects.filter( ConfigJsonCell.objects.filter(
placeholder='_auto_tile', last_update_timestamp__lte=now() - timedelta(days=2) placeholder='_auto_tile', last_update_timestamp__lte=now() - timedelta(days=2)
).delete() ).delete()
default_app_config = 'combo.apps.dashboard.AppConfig'

View File

@ -34,6 +34,3 @@ class AppConfig(django.apps.AppConfig):
update_available_statistics() update_available_statistics()
for cell in ChartNgCell.objects.all(): for cell in ChartNgCell.objects.all():
cell.check_validity() cell.check_validity()
default_app_config = 'combo.apps.dataviz.AppConfig'

View File

@ -1,8 +1,8 @@
# Generated by Django 1.11.12 on 2019-03-28 10:11 # Generated by Django 1.11.12 on 2019-03-28 10:11
import django.db.models.deletion import django.db.models.deletion
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,7 +1,7 @@
# Generated by Django 1.11.29 on 2020-12-02 13:24 # Generated by Django 1.11.29 on 2020-12-02 13:24
from django.contrib.postgres.fields import JSONField
from django.db import migrations from django.db import migrations
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -24,8 +24,8 @@ import pygal
import pygal.util import pygal.util
from dateutil.relativedelta import MO, relativedelta from dateutil.relativedelta import MO, relativedelta
from django.conf import settings from django.conf import settings
from django.contrib.postgres.fields import JSONField
from django.db import models, transaction from django.db import models, transaction
from django.db.models import JSONField
from django.template import RequestContext, Template, TemplateSyntaxError, VariableDoesNotExist from django.template import RequestContext, Template, TemplateSyntaxError, VariableDoesNotExist
from django.template.defaultfilters import date as format_date from django.template.defaultfilters import date as format_date
from django.urls import reverse from django.urls import reverse

View File

@ -1,4 +1,3 @@
import django
from django import forms from django import forms
@ -23,15 +22,8 @@ class MultiSelectWidget(forms.MultiWidget):
self.widgets.append(forms.Select(attrs=self.attrs, choices=self.choices)) self.widgets.append(forms.Select(attrs=self.attrs, choices=self.choices))
# all subwidgets must have the same name # all subwidgets must have the same name
if django.VERSION >= (3, 1): self.widgets_names = [''] * len(self.widgets)
self.widgets_names = [''] * len(self.widgets) return super().get_context(name, value, attrs)
return super().get_context(name, value, attrs)
else:
context = super().get_context(name, value, attrs)
subwidgets = context['widget']['subwidgets']
for widget in subwidgets:
widget['name'] = widget['name'].rsplit('_', 1)[0]
return context
def decompress(self, value): def decompress(self, value):
return value or [] return value or []

View File

@ -21,6 +21,3 @@ from django.utils.translation import gettext_lazy as _
class AppConfig(django.apps.AppConfig): class AppConfig(django.apps.AppConfig):
name = 'combo.apps.family' name = 'combo.apps.family'
verbose_name = _('Family') verbose_name = _('Family')
default_app_config = 'combo.apps.family.AppConfig'

View File

@ -21,6 +21,3 @@ from django.utils.translation import gettext_lazy as _
class AppConfig(django.apps.AppConfig): class AppConfig(django.apps.AppConfig):
name = 'combo.apps.fargo' name = 'combo.apps.fargo'
verbose_name = _('Portfolio') verbose_name = _('Portfolio')
default_app_config = 'combo.apps.fargo.AppConfig'

View File

@ -26,6 +26,3 @@ class AppConfig(django.apps.AppConfig):
from . import urls from . import urls
return urls.urlpatterns return urls.urlpatterns
default_app_config = 'combo.apps.gallery.AppConfig'

View File

@ -21,6 +21,3 @@ from django.utils.translation import gettext_lazy as _
class AppConfig(django.apps.AppConfig): class AppConfig(django.apps.AppConfig):
name = 'combo.apps.kb' name = 'combo.apps.kb'
verbose_name = _('Knowledge Base') verbose_name = _('Knowledge Base')
default_app_config = 'combo.apps.kb.AppConfig'

View File

@ -100,6 +100,3 @@ class AppConfig(django.apps.AppConfig):
item.notify_payment() item.notify_payment()
except Exception: except Exception:
logger.exception('error in async notification for basket item %s', item.id) logger.exception('error in async notification for basket item %s', item.id)
default_app_config = 'combo.apps.lingo.AppConfig'

View File

@ -19,8 +19,6 @@ from django.contrib import admin
from .models import Regie from .models import Regie
@admin.register(Regie)
class RegieAdmin(admin.ModelAdmin): class RegieAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug': ('label',)} prepopulated_fields = {'slug': ('label',)}
admin.site.register(Regie, RegieAdmin)

View File

@ -1,6 +1,6 @@
from django.conf import settings from django.conf import settings
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,5 +1,5 @@
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,5 +1,5 @@
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,5 +1,5 @@
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,8 +1,8 @@
# Generated by Django 1.11.18 on 2019-04-26 09:59 # Generated by Django 1.11.18 on 2019-04-26 09:59
import django.db.models.deletion import django.db.models.deletion
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,7 +1,7 @@
# Generated by Django 1.11.18 on 2019-05-14 12:02 # Generated by Django 1.11.18 on 2019-05-14 12:02
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
from combo.apps.lingo.models import SERVICES from combo.apps.lingo.models import SERVICES

View File

@ -27,11 +27,11 @@ import eopayment
from dateutil import parser from dateutil import parser
from django import template from django import template
from django.conf import settings from django.conf import settings
from django.contrib.postgres.fields import JSONField
from django.core import serializers from django.core import serializers
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
from django.core.mail import EmailMultiAlternatives from django.core.mail import EmailMultiAlternatives
from django.db import models from django.db import models
from django.db.models import JSONField
from django.db.transaction import atomic from django.db.transaction import atomic
from django.forms import Select from django.forms import Select
from django.forms import models as model_forms from django.forms import models as model_forms

View File

@ -30,6 +30,3 @@ class AppConfig(django.apps.AppConfig):
def get_extra_manager_actions(self): def get_extra_manager_actions(self):
return [{'href': reverse('maps-manager-homepage'), 'text': _('Maps')}] return [{'href': reverse('maps-manager-homepage'), 'text': _('Maps')}]
default_app_config = 'combo.apps.maps.AppConfig'

View File

@ -26,6 +26,3 @@ class AppConfig(django.apps.AppConfig):
from . import urls from . import urls
return urls.urlpatterns return urls.urlpatterns
default_app_config = 'combo.apps.notifications.AppConfig'

View File

@ -24,6 +24,3 @@ class AppConfig(django.apps.AppConfig):
from . import urls from . import urls
return urls.urlpatterns return urls.urlpatterns
default_app_config = 'combo.apps.publik.AppConfig'

View File

@ -36,6 +36,3 @@ class AppConfig(django.apps.AppConfig):
if settings.TEMPLATE_VARS.get('pwa_display') == 'standalone': if settings.TEMPLATE_VARS.get('pwa_display') == 'standalone':
return [{'href': reverse('pwa-manager-homepage'), 'text': _('Mobile Application (PWA)')}] return [{'href': reverse('pwa-manager-homepage'), 'text': _('Mobile Application (PWA)')}]
return [] return []
default_app_config = 'combo.apps.pwa.AppConfig'

View File

@ -2,8 +2,8 @@
import django.db.models.deletion import django.db.models.deletion
from django.conf import settings from django.conf import settings
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,7 +1,7 @@
# Generated by Django 1.11.12 on 2019-06-28 08:42 # Generated by Django 1.11.12 on 2019-06-28 08:42
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -20,11 +20,11 @@ import json
import os import os
from django.conf import settings from django.conf import settings
from django.contrib.postgres.fields import JSONField
from django.core import serializers from django.core import serializers
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
from django.core.files.storage import default_storage from django.core.files.storage import default_storage
from django.db import models from django.db import models
from django.db.models import JSONField
from django.utils.encoding import force_bytes, force_str from django.utils.encoding import force_bytes, force_str
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from py_vapid import Vapid from py_vapid import Vapid

View File

@ -48,6 +48,3 @@ class AppConfig(django.apps.AppConfig):
'label': _('Page Contents'), 'label': _('Page Contents'),
} }
} }
default_app_config = 'combo.apps.search.AppConfig'

View File

@ -1,5 +1,5 @@
from django.contrib.postgres.fields import JSONField
from django.db import migrations from django.db import migrations
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -18,9 +18,9 @@ from django import template
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from django.contrib.contenttypes import fields from django.contrib.contenttypes import fields
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.fields import JSONField
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
from django.db import models from django.db import models
from django.db.models import JSONField
from django.http import HttpResponse, HttpResponseBadRequest from django.http import HttpResponse, HttpResponseBadRequest
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.template import RequestContext, Template from django.template import RequestContext, Template

View File

@ -135,6 +135,3 @@ class AppConfig(django.apps.AppConfig):
] ]
for cell in CellBase.get_cells(cell_filter=lambda x: x in models_to_update): for cell in CellBase.get_cells(cell_filter=lambda x: x in models_to_update):
cell.save() cell.save()
default_app_config = 'combo.apps.wcs.AppConfig'

View File

@ -1,5 +1,5 @@
from django.contrib.postgres.fields import JSONField
from django.db import migrations from django.db import migrations
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,5 +1,5 @@
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,7 +1,7 @@
# Generated by Django 1.11.8 on 2018-01-21 12:50 # Generated by Django 1.11.8 on 2018-01-21 12:50
from django.contrib.postgres.fields import JSONField
from django.db import migrations from django.db import migrations
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,5 +1,5 @@
from django.contrib.postgres.fields import JSONField
from django.db import migrations from django.db import migrations
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,6 +1,6 @@
import django.db.models.deletion import django.db.models.deletion
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
import combo.apps.wcs.models import combo.apps.wcs.models

View File

@ -1,5 +1,5 @@
from django.contrib.postgres.fields import JSONField
from django.db import migrations from django.db import migrations
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,5 +1,5 @@
from django.contrib.postgres.fields import JSONField
from django.db import migrations from django.db import migrations
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -20,8 +20,8 @@ import copy
import logging import logging
from django.conf import settings from django.conf import settings
from django.contrib.postgres.fields import JSONField
from django.db import models from django.db import models
from django.db.models import JSONField
from django.forms import Select from django.forms import Select
from django.forms import models as model_forms from django.forms import models as model_forms
from django.template import Context, RequestContext, Template, TemplateSyntaxError, VariableDoesNotExist from django.template import Context, RequestContext, Template, TemplateSyntaxError, VariableDoesNotExist

View File

@ -16,13 +16,13 @@
import re import re
import urllib.parse import urllib.parse
from urllib.parse import quote
import ratelimit.utils import ratelimit.utils
from django.conf import settings from django.conf import settings
from django.contrib import messages from django.contrib import messages
from django.core.exceptions import DisallowedRedirect, PermissionDenied from django.core.exceptions import DisallowedRedirect, PermissionDenied
from django.http import HttpResponseBadRequest, HttpResponseForbidden, HttpResponseRedirect, JsonResponse from django.http import HttpResponseBadRequest, HttpResponseForbidden, HttpResponseRedirect, JsonResponse
from django.utils.http import urlquote
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.views.decorators.csrf import csrf_exempt from django.views.decorators.csrf import csrf_exempt
from django.views.generic import View from django.views.generic import View
@ -63,7 +63,7 @@ class TrackingCodeView(View):
for wcs_site in wcs_sites: for wcs_site in wcs_sites:
if not wcs_site: if not wcs_site:
continue continue
response = requests.get('/api/code/' + urlquote(code), remote_service=wcs_site, log_errors=False) response = requests.get('/api/code/' + quote(code), remote_service=wcs_site, log_errors=False)
if response.status_code == 200 and response.json().get('err') == 0: if response.status_code == 200 and response.json().get('err') == 0:
return response.json().get('load_url') return response.json().get('load_url')

View File

@ -1 +0,0 @@
default_app_config = 'combo.data.apps.DataConfig'

View File

@ -15,9 +15,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.apps import apps from django.apps import apps
from django.contrib.postgres.fields import JSONField
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.db import connection from django.db import connection
from django.db.models import JSONField
class Command(BaseCommand): class Command(BaseCommand):

View File

@ -1,5 +1,5 @@
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,5 +1,5 @@
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -2,8 +2,8 @@
import django.db.models.deletion import django.db.models.deletion
from django.conf import settings from django.conf import settings
from django.contrib.postgres.fields import JSONField
from django.db import migrations, models from django.db import migrations, models
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -1,7 +1,7 @@
# Generated by Django 1.11.12 on 2018-06-02 11:03 # Generated by Django 1.11.12 on 2018-06-02 11:03
from django.contrib.postgres.fields import JSONField
from django.db import migrations from django.db import migrations
from django.db.models import JSONField
class Migration(migrations.Migration): class Migration(migrations.Migration):

View File

@ -35,12 +35,11 @@ from django.contrib import messages
from django.contrib.auth.models import Group from django.contrib.auth.models import Group
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.fields import JSONField
from django.core import serializers from django.core import serializers
from django.core.cache import cache from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist, PermissionDenied, ValidationError from django.core.exceptions import ObjectDoesNotExist, PermissionDenied, ValidationError
from django.db import models, transaction from django.db import models, transaction
from django.db.models import Max, Q from django.db.models import JSONField, Max, Q
from django.db.models.base import ModelBase from django.db.models.base import ModelBase
from django.db.models.signals import post_delete, post_save, pre_save from django.db.models.signals import post_delete, post_save, pre_save
from django.dispatch import receiver from django.dispatch import receiver

View File

@ -13,5 +13,3 @@
# #
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
default_app_config = 'combo.manager.apps.ManagerAppConfig'

View File

@ -76,6 +76,3 @@ class AppConfig(django.apps.AppConfig):
'hit_description_template': default_description_template, 'hit_description_template': default_description_template,
} }
} }
default_app_config = 'combo.profile.AppConfig'

View File

@ -141,7 +141,7 @@ WSGI_APPLICATION = 'combo.wsgi.application'
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.postgresql',
} }
} }

View File

@ -1,9 +1,6 @@
#! /usr/bin/env python #! /usr/bin/env python
import glob
import itertools
import os import os
import re
import subprocess import subprocess
import sys import sys
from distutils.cmd import Command from distutils.cmd import Command