0004-django4-fix-default-AppConfig-deprecation-warnings-6.patch
passerelle/apps/cmis/__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 = 'passerelle.apps.cmis.apps.CmisAppConfig' |
passerelle/apps/csvdatasource/__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 |
import django.apps |
|
18 | ||
19 | ||
20 |
class AppConfig(django.apps.AppConfig): |
|
21 |
name = 'passerelle.apps.csvdatasource' |
|
22 |
label = 'csvdatasource' |
|
23 | ||
24 |
def get_connector_model(self): |
|
25 |
from . import models |
|
26 | ||
27 |
return models.CsvDataSource |
|
28 | ||
29 | ||
30 |
default_app_config = 'passerelle.apps.csvdatasource.AppConfig' |
passerelle/apps/csvdatasource/apps.py | ||
---|---|---|
1 |
import django.apps |
|
2 | ||
3 | ||
4 |
class AppConfig(django.apps.AppConfig): |
|
5 |
name = 'passerelle.apps.csvdatasource' |
|
6 |
label = 'csvdatasource' |
|
7 | ||
8 |
def get_connector_model(self): |
|
9 |
from . import models |
|
10 | ||
11 |
return models.CsvDataSource |
passerelle/base/__init__.py | ||
---|---|---|
15 | 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 | 17 |
import django.apps |
18 |
from django.apps import apps |
|
19 | 18 |
from django.utils.module_loading import import_string |
20 | 19 | |
21 | 20 | |
... | ... | |
38 | 37 | |
39 | 38 |
class ConnectorAppConfig(ConnectorAppMixin, django.apps.AppConfig): |
40 | 39 |
pass |
41 | ||
42 | ||
43 |
class AppConfig(django.apps.AppConfig): |
|
44 |
name = 'passerelle.base' |
|
45 | ||
46 |
def ready(self): |
|
47 |
# once all applications are ready, go through them and mark them as |
|
48 |
# connectors if they have a get_connector_model() method or a model |
|
49 |
# that inherits from BaseResource. |
|
50 |
from .models import BaseResource |
|
51 | ||
52 |
for app in apps.get_app_configs(): |
|
53 |
connector_model = None |
|
54 |
if hasattr(app, 'get_connector_model'): |
|
55 |
connector_model = app.get_connector_model() |
|
56 |
else: |
|
57 |
for model in app.get_models(): |
|
58 |
if issubclass(model, BaseResource): |
|
59 |
connector_model = model |
|
60 |
app._connector_model = model |
|
61 |
break |
|
62 |
if not connector_model: |
|
63 |
continue |
|
64 |
if app.__class__ is django.apps.AppConfig: |
|
65 |
# switch class if it's an application without a custom |
|
66 |
# appconfig. |
|
67 |
app.__class__ = ConnectorAppConfig |
|
68 |
else: |
|
69 |
# add mixin to base classes if it's an application with a |
|
70 |
# custom appconfig. |
|
71 |
app.__class__.__bases__ = (ConnectorAppMixin,) + app.__class__.__bases__ |
|
72 | ||
73 | ||
74 |
default_app_config = 'passerelle.base.AppConfig' |
passerelle/base/apps.py | ||
---|---|---|
1 |
import django.apps |
|
2 | ||
3 |
from . import ConnectorAppConfig, ConnectorAppMixin |
|
4 | ||
5 | ||
6 |
class AppConfig(django.apps.AppConfig): |
|
7 |
name = 'passerelle.base' |
|
8 | ||
9 |
def ready(self): |
|
10 |
# once all applications are ready, go through them and mark them as |
|
11 |
# connectors if they have a get_connector_model() method or a model |
|
12 |
# that inherits from BaseResource. |
|
13 |
from .models import BaseResource |
|
14 | ||
15 |
for app in django.apps.apps.get_app_configs(): |
|
16 |
connector_model = None |
|
17 |
if hasattr(app, 'get_connector_model'): |
|
18 |
connector_model = app.get_connector_model() |
|
19 |
else: |
|
20 |
for model in app.get_models(): |
|
21 |
if issubclass(model, BaseResource): |
|
22 |
connector_model = model |
|
23 |
app._connector_model = model |
|
24 |
break |
|
25 |
if not connector_model: |
|
26 |
continue |
|
27 |
if app.__class__ is django.apps.AppConfig: |
|
28 |
# switch class if it's an application without a custom |
|
29 |
# appconfig. |
|
30 |
app.__class__ = ConnectorAppConfig |
|
31 |
else: |
|
32 |
# add mixin to base classes if it's an application with a |
|
33 |
# custom appconfig. |
|
34 |
app.__class__.__bases__ = (ConnectorAppMixin,) + app.__class__.__bases__ |
|
35 | ||
36 | ||
37 |
default_app_config = 'passerelle.base.AppConfig' |
passerelle/settings.py | ||
---|---|---|
116 | 116 |
'django.contrib.admin', |
117 | 117 |
'django.contrib.postgres', |
118 | 118 |
# base app |
119 |
'passerelle.base', |
|
119 |
'passerelle.base.apps.AppConfig',
|
|
120 | 120 |
'passerelle.address', |
121 | 121 |
'passerelle.sms', |
122 | 122 |
# connectors |
... | ... | |
138 | 138 |
'passerelle.apps.choosit', |
139 | 139 |
'passerelle.apps.cityweb', |
140 | 140 |
'passerelle.apps.clicrdv', |
141 |
'passerelle.apps.cmis', |
|
141 |
'passerelle.apps.cmis.apps.CmisAppConfig',
|
|
142 | 142 |
'passerelle.apps.cryptor', |
143 |
'passerelle.apps.csvdatasource', |
|
143 |
'passerelle.apps.csvdatasource.apps.AppConfig',
|
|
144 | 144 |
'passerelle.apps.esabora', |
145 | 145 |
'passerelle.apps.esirius', |
146 | 146 |
'passerelle.apps.family', |
147 |
- |