From 0e08c4446e32872c3c524b397e0799b20223d549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Poulain?= Date: Sat, 1 Aug 2020 14:28:53 +0200 Subject: [PATCH] feat(spip): connecte la db spip --- drupal2spip_lal/base/routers.py | 6 ++++-- drupal2spip_lal/settings/base.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drupal2spip_lal/base/routers.py b/drupal2spip_lal/base/routers.py index 6d99423..618817d 100644 --- a/drupal2spip_lal/base/routers.py +++ b/drupal2spip_lal/base/routers.py @@ -2,6 +2,8 @@ class Drupal2SPIPRouter: def db_for_read(self, model, **hints): if model._meta.app_label == 'drupal': return 'drupal' + if model._meta.app_label == 'spip': + return 'spip' return None def db_for_write(self, model, **hints): @@ -12,7 +14,7 @@ class Drupal2SPIPRouter: We disallow cross db relations. """ app1, app2 = obj1._meta.app_label, obj2._meta.app_label - if 'drupal' in [app1, app2]: + if 'drupal' in [app1, app2] or 'spip' in [app1, app2]: return app1 == app2 return None @@ -20,6 +22,6 @@ class Drupal2SPIPRouter: """ We disallow migrations for those db. """ - if db == 'drupal': + if db in ['drupal', 'spip']: return False return None diff --git a/drupal2spip_lal/settings/base.py b/drupal2spip_lal/settings/base.py index 1f42c85..2c833f3 100644 --- a/drupal2spip_lal/settings/base.py +++ b/drupal2spip_lal/settings/base.py @@ -60,6 +60,10 @@ DATABASES = { 'DRUPAL_DATABASE_URL', default='sqlite:///{}'.format(base_dir('drupal.db')), ), + 'spip': env.db_url( + 'SPIP_DATABASE_URL', + default='sqlite:///{}'.format(base_dir('spip.db')), + ), } DATABASE_ROUTERS = ['drupal2spip_lal.base.routers.Drupal2SPIPRouter']