From e1f969f8130d070638ae0395bdb2899e08897f68 Mon Sep 17 00:00:00 2001 From: Agate Berriot Date: Wed, 31 Aug 2022 09:31:35 +0200 Subject: [PATCH 1/4] django4: fix default AppConfig deprecation warnings (#68573) --- welco/kb/__init__.py | 2 -- welco/settings.py | 2 +- welco/sources/mail/__init__.py | 55 ---------------------------------- welco/sources/mail/apps.py | 52 ++++++++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 58 deletions(-) create mode 100644 welco/sources/mail/apps.py diff --git a/welco/kb/__init__.py b/welco/kb/__init__.py index 06dc027..adda67f 100644 --- a/welco/kb/__init__.py +++ b/welco/kb/__init__.py @@ -13,5 +13,3 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - -default_app_config = 'welco.kb.apps.KbAppConfig' diff --git a/welco/settings.py b/welco/settings.py index cfe3dc0..83451ae 100644 --- a/welco/settings.py +++ b/welco/settings.py @@ -42,7 +42,7 @@ INSTALLED_APPS = ( 'haystack', 'taggit', 'welco.sources.counter', - 'welco.sources.mail', + 'welco.sources.mail.apps.AppConfig', 'welco.sources.phone', 'welco.qualif', 'welco.kb', diff --git a/welco/sources/mail/__init__.py b/welco/sources/mail/__init__.py index 94c300e..e69de29 100644 --- a/welco/sources/mail/__init__.py +++ b/welco/sources/mail/__init__.py @@ -1,55 +0,0 @@ -# welco - multichannel request processing -# Copyright (C) 2018 Entr'ouvert -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU Affero General Public License as published -# by the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -import django.apps - - -class AppConfig(django.apps.AppConfig): - name = 'welco.sources.mail' - - def get_before_urls(self): - from . import urls - - return urls.urlpatterns - - def ready(self): - from django.db.models import signals - - from welco.qualif.models import Association - - signals.post_save.connect(self.association_post_save, sender=Association) - - def association_post_save(self, sender, instance, **kwargs): - from .utils import get_maarch - - if not instance.formdata_id: - return - source = instance.source - if not getattr(source, 'external_id', None): - return - external_id = source.external_id - if not external_id.startswith('maarch-'): - return - maarch_pk = int(external_id.split('-', 1)[-1]) - maarch = get_maarch() - maarch.set_grc_sent_status( - mail_pk=maarch_pk, - formdata_id=instance.formdata_id, - formdata_url_backoffice=instance.formdata_url_backoffice, - ) - - -default_app_config = 'welco.sources.mail.AppConfig' diff --git a/welco/sources/mail/apps.py b/welco/sources/mail/apps.py new file mode 100644 index 0000000..7aaf541 --- /dev/null +++ b/welco/sources/mail/apps.py @@ -0,0 +1,52 @@ +# welco - multichannel request processing +# Copyright (C) 2018 Entr'ouvert +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import django.apps + + +class AppConfig(django.apps.AppConfig): + name = 'welco.sources.mail' + + def get_before_urls(self): + from . import urls + + return urls.urlpatterns + + def ready(self): + from django.db.models import signals + + from welco.qualif.models import Association + + signals.post_save.connect(self.association_post_save, sender=Association) + + def association_post_save(self, sender, instance, **kwargs): + from .utils import get_maarch + + if not instance.formdata_id: + return + source = instance.source + if not getattr(source, 'external_id', None): + return + external_id = source.external_id + if not external_id.startswith('maarch-'): + return + maarch_pk = int(external_id.split('-', 1)[-1]) + maarch = get_maarch() + maarch.set_grc_sent_status( + mail_pk=maarch_pk, + formdata_id=instance.formdata_id, + formdata_url_backoffice=instance.formdata_url_backoffice, + ) -- 2.37.2