diff --git a/djangocms_link/fields.py b/djangocms_link/fields.py index d5e95e26..507f9a13 100644 --- a/djangocms_link/fields.py +++ b/djangocms_link/fields.py @@ -12,6 +12,8 @@ from cms.utils.urlutils import admin_reverse +from djangocms_link.helpers import get_manager + try: from filer.fields.file import AdminFileWidget, FilerFileField @@ -45,10 +47,7 @@ def get_internal_obj(self, values): if value: model_path, pk = value.split(":", 1) model = apps.get_model(*model_path.split(".", 1)) - if hasattr(model, "admin_manager"): - internal_obj.append(model.admin_manager.filter(pk=pk).first()) - else: - internal_obj.append(model.objects.filter(pk=pk).first()) + internal_obj.append(get_manager(model).filter(pk=pk).first()) else: internal_obj.append(None) return internal_obj diff --git a/tests/test_cms_config.py b/tests/test_cms_config.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/x_test_cms_config.py b/tests/x_test_cms_config.py new file mode 100644 index 00000000..281acd8e --- /dev/null +++ b/tests/x_test_cms_config.py @@ -0,0 +1,17 @@ +from django.apps import apps + +from cms.test_utils.testcases import CMSTestCase + + +class CMSConfigTestCase(CMSTestCase): + def setUp(self): + self.app = apps.get_app_config("djangocms_link") + + def test_config_recognized(self): + self.assertFalse(hasattr(self.app, "cms_config")) + self.assertTrue(hasattr(self.app, "cms_extension")) + + def test_cms_extension(self): + cms_ext = self.app.cms_extension + + self.assertEqual(cms_ext.link_url_endpoint, "/en/admin/djangocms_link/link/urls")