0001-django4-fix-default-AppConfig-deprecation-warnings-6.patch
welco/kb/__init__.py | ||
---|---|---|
13 | 13 |
# |
14 | 14 |
# You should have received a copy of the GNU Affero General Public License |
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | ||
17 |
default_app_config = 'welco.kb.apps.KbAppConfig' |
welco/settings.py | ||
---|---|---|
42 | 42 |
'haystack', |
43 | 43 |
'taggit', |
44 | 44 |
'welco.sources.counter', |
45 |
'welco.sources.mail', |
|
45 |
'welco.sources.mail.apps.AppConfig',
|
|
46 | 46 |
'welco.sources.phone', |
47 | 47 |
'welco.qualif', |
48 | 48 |
'welco.kb', |
welco/sources/mail/__init__.py | ||
---|---|---|
1 |
# welco - multichannel request processing |
|
2 |
# Copyright (C) 2018 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 | ||
19 | ||
20 |
class AppConfig(django.apps.AppConfig): |
|
21 |
name = 'welco.sources.mail' |
|
22 | ||
23 |
def get_before_urls(self): |
|
24 |
from . import urls |
|
25 | ||
26 |
return urls.urlpatterns |
|
27 | ||
28 |
def ready(self): |
|
29 |
from django.db.models import signals |
|
30 | ||
31 |
from welco.qualif.models import Association |
|
32 | ||
33 |
signals.post_save.connect(self.association_post_save, sender=Association) |
|
34 | ||
35 |
def association_post_save(self, sender, instance, **kwargs): |
|
36 |
from .utils import get_maarch |
|
37 | ||
38 |
if not instance.formdata_id: |
|
39 |
return |
|
40 |
source = instance.source |
|
41 |
if not getattr(source, 'external_id', None): |
|
42 |
return |
|
43 |
external_id = source.external_id |
|
44 |
if not external_id.startswith('maarch-'): |
|
45 |
return |
|
46 |
maarch_pk = int(external_id.split('-', 1)[-1]) |
|
47 |
maarch = get_maarch() |
|
48 |
maarch.set_grc_sent_status( |
|
49 |
mail_pk=maarch_pk, |
|
50 |
formdata_id=instance.formdata_id, |
|
51 |
formdata_url_backoffice=instance.formdata_url_backoffice, |
|
52 |
) |
|
53 | ||
54 | ||
55 |
default_app_config = 'welco.sources.mail.AppConfig' |
welco/sources/mail/apps.py | ||
---|---|---|
1 |
# welco - multichannel request processing |
|
2 |
# Copyright (C) 2018 Entr'ouvert |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify it |
|
5 |
# under the terms of the GNU Affero General Public License as published |
|
6 |
# by the Free Software Foundation, either version 3 of the License, or |
|
7 |
# (at your option) any later version. |
|
8 |
# |
|
9 |
# This program is distributed in the hope that it will be useful, |
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
# GNU Affero General Public License for more details. |
|
13 |
# |
|
14 |
# You should have received a copy of the GNU Affero General Public License |
|
15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | ||
17 |
import django.apps |
|
18 | ||
19 | ||
20 |
class AppConfig(django.apps.AppConfig): |
|
21 |
name = 'welco.sources.mail' |
|
22 | ||
23 |
def get_before_urls(self): |
|
24 |
from . import urls |
|
25 | ||
26 |
return urls.urlpatterns |
|
27 | ||
28 |
def ready(self): |
|
29 |
from django.db.models import signals |
|
30 | ||
31 |
from welco.qualif.models import Association |
|
32 | ||
33 |
signals.post_save.connect(self.association_post_save, sender=Association) |
|
34 | ||
35 |
def association_post_save(self, sender, instance, **kwargs): |
|
36 |
from .utils import get_maarch |
|
37 | ||
38 |
if not instance.formdata_id: |
|
39 |
return |
|
40 |
source = instance.source |
|
41 |
if not getattr(source, 'external_id', None): |
|
42 |
return |
|
43 |
external_id = source.external_id |
|
44 |
if not external_id.startswith('maarch-'): |
|
45 |
return |
|
46 |
maarch_pk = int(external_id.split('-', 1)[-1]) |
|
47 |
maarch = get_maarch() |
|
48 |
maarch.set_grc_sent_status( |
|
49 |
mail_pk=maarch_pk, |
|
50 |
formdata_id=instance.formdata_id, |
|
51 |
formdata_url_backoffice=instance.formdata_url_backoffice, |
|
52 |
) |
|
0 |
- |