Skip to content

Commit

Permalink
Fix extra char in admin custom urlconf (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
yakky authored Nov 16, 2020
1 parent 31a7ccc commit 25d4827
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions changes/648.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix admin urlconf not matching path syntax
2 changes: 1 addition & 1 deletion djangocms_blog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def get_urls(self):
"""
urls = [
path(
"publish/<int:pk>/$",
"publish/<int:pk>/",
self.admin_site.admin_view(self.publish_post),
name="djangocms_blog_publish_article",
),
Expand Down
3 changes: 1 addition & 2 deletions djangocms_blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

try:
from knocker.mixins import KnockerModel
except ImportError:
except ImportError: # pragma: no cover

class KnockerModel:
"""
Expand Down Expand Up @@ -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):
Expand Down
14 changes: 14 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
15 changes: 15 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 25d4827

Please sign in to comment.