From a30c737920cea34682b55603387a33a78a853523 Mon Sep 17 00:00:00 2001 From: Parbhat Puri Date: Fri, 3 Apr 2020 20:29:55 +0530 Subject: [PATCH] Rename JS file, use code icon and other fixes --- ...tail_snippet.js => wagtail-draftail-snippet.js} | 0 wagtail_draftail_snippet/urls.py | 4 ++-- wagtail_draftail_snippet/utils.py | 5 ++--- wagtail_draftail_snippet/wagtail_hooks.py | 14 +++++++------- 4 files changed, 11 insertions(+), 12 deletions(-) rename wagtail_draftail_snippet/static/wagtail_draftail_snippet/js/{wagtail_draftail_snippet.js => wagtail-draftail-snippet.js} (100%) diff --git a/wagtail_draftail_snippet/static/wagtail_draftail_snippet/js/wagtail_draftail_snippet.js b/wagtail_draftail_snippet/static/wagtail_draftail_snippet/js/wagtail-draftail-snippet.js similarity index 100% rename from wagtail_draftail_snippet/static/wagtail_draftail_snippet/js/wagtail_draftail_snippet.js rename to wagtail_draftail_snippet/static/wagtail_draftail_snippet/js/wagtail-draftail-snippet.js diff --git a/wagtail_draftail_snippet/urls.py b/wagtail_draftail_snippet/urls.py index 4d0707d..495edd6 100644 --- a/wagtail_draftail_snippet/urls.py +++ b/wagtail_draftail_snippet/urls.py @@ -6,6 +6,6 @@ from .views import choose_snippet_link_model, choose_snippet_embed_model app_name = "wagtaildraftailsnippet" urlpatterns = [ - url(r"^choose-link-model/$", choose_snippet_link_model, name="choose_snippet_link_model"), - url(r"^choose-embed-model/$", choose_snippet_embed_model, name="choose_snippet_embed_model"), + url(r"^choose-link-model/$", choose_snippet_link_model, name="choose-snippet-link-model"), + url(r"^choose-embed-model/$", choose_snippet_embed_model, name="choose-snippet-embed-model"), ] diff --git a/wagtail_draftail_snippet/utils.py b/wagtail_draftail_snippet/utils.py index 74c5514..6e2b3fc 100644 --- a/wagtail_draftail_snippet/utils.py +++ b/wagtail_draftail_snippet/utils.py @@ -1,9 +1,8 @@ -from wagtail.core.utils import camelcase_to_underscore def get_snippet_link_frontend_template(app_name, model_name): - return "%s/%s_snippet_link.html" % (app_name, camelcase_to_underscore(model_name)) + return "%s/%s_snippet_link.html" % (app_name, model_name) def get_snippet_embed_frontend_template(app_name, model_name): - return "%s/%s_snippet_embed.html" % (app_name, camelcase_to_underscore(model_name)) + return "%s/%s_snippet_embed.html" % (app_name, model_name) diff --git a/wagtail_draftail_snippet/wagtail_hooks.py b/wagtail_draftail_snippet/wagtail_hooks.py index 4b7814e..479c7a8 100644 --- a/wagtail_draftail_snippet/wagtail_hooks.py +++ b/wagtail_draftail_snippet/wagtail_hooks.py @@ -3,13 +3,13 @@ from django.urls import reverse from django.utils.html import format_html from django.utils.translation import ugettext -import wagtail.admin.rich_text.editors.draftail.features as draftail_features +from wagtail.admin.rich_text.editors.draftail import features as draftail_features from wagtail.core import hooks from . import urls from .richtext import ( ContentstateSnippetLinkConversionRule, ContentstateSnippetEmbedConversionRule, - SnippetEmbedHandler, SnippetLinkHandler + SnippetLinkHandler, SnippetEmbedHandler, ) @@ -28,7 +28,7 @@ def register_snippet_link_feature(features): js=[ "wagtailsnippets/js/snippet-chooser-modal.js", "wagtail_draftail_snippet/js/snippet-model-chooser-modal.js", - "wagtail_draftail_snippet/js/wagtail_draftail_snippet.js", + "wagtail_draftail_snippet/js/wagtail-draftail-snippet.js", ], ), ) @@ -49,11 +49,11 @@ def register_snippet_embed_feature(features): "draftail", feature_name, draftail_features.EntityFeature( - {"type": type_, "icon": "media", "description": ugettext("Snippet Embed")}, + {"type": type_, "icon": "code", "description": ugettext("Snippet Embed")}, js=[ "wagtailsnippets/js/snippet-chooser-modal.js", "wagtail_draftail_snippet/js/snippet-model-chooser-modal.js", - "wagtail_draftail_snippet/js/wagtail_draftail_snippet.js", + "wagtail_draftail_snippet/js/wagtail-draftail-snippet.js", ], ), ) @@ -72,8 +72,8 @@ def editor_js(): window.chooserUrls.snippetEmbedModelChooser = '{1}'; """, - reverse("wagtaildraftailsnippet:choose_snippet_link_model"), - reverse("wagtaildraftailsnippet:choose_snippet_embed_model"), + reverse("wagtaildraftailsnippet:choose-snippet-link-model"), + reverse("wagtaildraftailsnippet:choose-snippet-embed-model"), )