mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-23 06:38:40 +02:00
* Using django's orm to access amavis database * Many UI improvments * Better use of the RS field fixed #88 & #72 see #155
31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
class AmavisRouter(object):
|
|
"""A router to control all database operations on models in
|
|
the amavis_quarantine application"""
|
|
|
|
def db_for_read(self, model, **hints):
|
|
"Point all operations on amavis_quarantine models to 'amavis'"
|
|
if model._meta.app_label == 'amavis_quarantine':
|
|
return 'amavis'
|
|
return None
|
|
|
|
def db_for_write(self, model, **hints):
|
|
"Point all operations on amavis_quarantine models to 'amavis'"
|
|
if model._meta.app_label == 'amavis_quarantine':
|
|
return 'amavis'
|
|
return None
|
|
|
|
def allow_relation(self, obj1, obj2, **hints):
|
|
"Allow any relation if a model in amavis_quarantine is involved"
|
|
if obj1._meta.app_label == 'amavis_quarantine' \
|
|
or obj2._meta.app_label == 'amavis_quarantine':
|
|
return True
|
|
return None
|
|
|
|
def allow_syncdb(self, db, model):
|
|
"Make sure the amavis_quarantine app only appears on the 'amavis' db"
|
|
if db == 'amavis':
|
|
return model._meta.app_label == 'amavis_quarantine'
|
|
elif model._meta.app_label == 'amavis_quarantine':
|
|
return False
|
|
return None
|