Skip to content

Commit

Permalink
Small simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Oct 27, 2024
1 parent 1be3cea commit 2252643
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
7 changes: 3 additions & 4 deletions djangocms_link/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Empty file removed tests/test_cms_config.py
Empty file.
17 changes: 17 additions & 0 deletions tests/x_test_cms_config.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 2252643

Please sign in to comment.