2020-08-01 11:18:41 +02:00
|
|
|
class Drupal2SPIPRouter:
|
|
|
|
def db_for_read(self, model, **hints):
|
|
|
|
if model._meta.app_label == 'drupal':
|
|
|
|
return 'drupal'
|
2020-08-01 14:28:53 +02:00
|
|
|
if model._meta.app_label == 'spip':
|
|
|
|
return 'spip'
|
2020-08-01 11:18:41 +02:00
|
|
|
return None
|
|
|
|
|
|
|
|
def db_for_write(self, model, **hints):
|
|
|
|
return self.db_for_read(model, **hints)
|
|
|
|
|
|
|
|
def allow_relation(self, obj1, obj2, **hints):
|
|
|
|
"""
|
|
|
|
We disallow cross db relations.
|
|
|
|
"""
|
|
|
|
app1, app2 = obj1._meta.app_label, obj2._meta.app_label
|
2020-08-01 14:28:53 +02:00
|
|
|
if 'drupal' in [app1, app2] or 'spip' in [app1, app2]:
|
2020-08-01 11:18:41 +02:00
|
|
|
return app1 == app2
|
|
|
|
return None
|
|
|
|
|
|
|
|
def allow_migrate(self, db, app_label, model_name=None, **hints):
|
|
|
|
"""
|
|
|
|
We disallow migrations for those db.
|
|
|
|
"""
|
2020-08-01 14:28:53 +02:00
|
|
|
if db in ['drupal', 'spip']:
|
2020-08-01 11:18:41 +02:00
|
|
|
return False
|
|
|
|
return None
|