utils.py 562 B

1234567891011121314151617181920
  1. from importlib import import_module
  2. from jet.dashboard import settings
  3. def get_current_dashboard(location):
  4. if location == 'index':
  5. path = settings.JET_INDEX_DASHBOARD
  6. elif location == 'app_index':
  7. path = settings.JET_APP_INDEX_DASHBOARD
  8. else:
  9. raise ValueError('Unknown dashboard location: %s' % location)
  10. module, cls = path.rsplit('.', 1)
  11. try:
  12. module = import_module(module)
  13. index_dashboard_cls = getattr(module, cls)
  14. return index_dashboard_cls
  15. except ImportError:
  16. return None