diff --git a/changes/648.bugfix b/changes/648.bugfix new file mode 100644 index 00000000..f6693697 --- /dev/null +++ b/changes/648.bugfix @@ -0,0 +1 @@ +Fix admin urlconf not matching path syntax diff --git a/djangocms_blog/admin.py b/djangocms_blog/admin.py index f10bf69e..5a4d7ea9 100644 --- a/djangocms_blog/admin.py +++ b/djangocms_blog/admin.py @@ -283,7 +283,7 @@ def get_urls(self): """ urls = [ path( - "publish//$", + "publish//", self.admin_site.admin_view(self.publish_post), name="djangocms_blog_publish_article", ), diff --git a/djangocms_blog/models.py b/djangocms_blog/models.py index eb19d598..f4e691f5 100644 --- a/djangocms_blog/models.py +++ b/djangocms_blog/models.py @@ -40,7 +40,7 @@ try: from knocker.mixins import KnockerModel -except ImportError: +except ImportError: # pragma: no cover class KnockerModel: """ @@ -73,7 +73,6 @@ def get_meta_attribute(self, param): Retrieves django-meta attributes from apphook config instance :param param: django-meta attribute passed as key """ - print(param, getattr(self.app_config, param)) return self._get_meta_value(param, getattr(self.app_config, param)) or "" def get_locale(self): diff --git a/tests/test_models.py b/tests/test_models.py index 664c9ebe..526afff8 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -688,6 +688,20 @@ def test_admin_post_text(self): modified_post = Post.objects.language("en").get(pk=post.pk) self.assertEqual(modified_post.safe_translation_getter("post_text"), data["post_text"]) + def test_admin_publish_post_view(self): + self.get_pages() + post = self._get_post(self._post_data[0]["en"]) + + with pause_knocks(post): + post.publish = False + post.save() + self.client.force_login(self.user) + response = self.client.post(reverse("admin:djangocms_blog_publish_article", args=(post.pk,))) + post.refresh_from_db() + self.assertEqual(response.status_code, 302) + self.assertEqual(response["Location"], post.get_absolute_url()) + self.assertTrue(post.publish) + def test_admin_site(self): pages = self.get_pages() post = self._get_post(self._post_data[0]["en"]) diff --git a/tests/test_views.py b/tests/test_views.py index 9256e91e..cdf3dc43 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -1,11 +1,13 @@ import os.path from aldryn_apphooks_config.utils import get_app_instance +from app_helper.utils import captured_output from cms.api import add_plugin from cms.toolbar.items import ModalItem from cms.utils.apphook_reload import reload_urlconf from django.contrib.auth.models import AnonymousUser from django.core.exceptions import ImproperlyConfigured +from django.core.management import call_command from django.http import Http404 from django.test import override_settings from django.urls import reverse @@ -39,8 +41,21 @@ def test_post_list_view_custom_urlconf(self): self.get_request(pages[1], "en", AnonymousUser()) self.assertEqual(reverse("sample_app:posts-latest"), "/en/page-two/latests/") + @override_settings(BLOG_URLCONF="tests.test_utils.blog_urls") + def test_check_custom_urlconf(self): + """No django check fails with custom urlconf.""" + with captured_output() as (out, err): + call_command("check", fail_level="DEBUG") + self.assertEqual(out.getvalue().strip(), "System check identified no issues (0 silenced).") + class ViewTest(BaseTest): + def test_check_plain_urlconf(self): + """No django check fails with plain urlconf.""" + with captured_output() as (out, err): + call_command("check", fail_level="DEBUG") + self.assertEqual(out.getvalue().strip(), "System check identified no issues (0 silenced).") + def test_post_list_view_base_urlconf(self): pages = self.get_pages() self.get_posts()