1
Fork 0

Rename current Snippet feature snippet to snippet-link

This commit is contained in:
Parbhat Puri 2020-04-03 20:02:17 +05:30
parent c50800ff84
commit df521783f8
4 changed files with 9 additions and 9 deletions

View file

@ -6,7 +6,7 @@ from wagtail.admin.rich_text.converters.contentstate_models import Entity
from wagtail.admin.rich_text.converters.html_to_contentstate import LinkElementHandler, AtomicBlockEntityElementHandler
from wagtail.core.rich_text import EmbedHandler, LinkHandler
from .utils import get_snippet_frontend_template, get_snippet_embed_frontend_template
from .utils import get_snippet_link_frontend_template, get_snippet_embed_frontend_template
# Snippet Link
@ -22,7 +22,7 @@ class SnippetLinkHandler(LinkHandler):
@classmethod
def get_template(cls, attrs):
return get_snippet_frontend_template(
return get_snippet_link_frontend_template(
attrs["data-app-name"], attrs["data-model-name"]
)

View file

@ -1,8 +1,8 @@
from wagtail.core.utils import camelcase_to_underscore
def get_snippet_frontend_template(app_name, model_name):
return "%s/%s_snippet.html" % (app_name, camelcase_to_underscore(model_name))
def get_snippet_link_frontend_template(app_name, model_name):
return "%s/%s_snippet_link.html" % (app_name, camelcase_to_underscore(model_name))
def get_snippet_embed_frontend_template(app_name, model_name):

View file

@ -3,7 +3,7 @@ from django.template.loader import TemplateDoesNotExist, get_template
from wagtail.admin.modal_workflow import render_modal_workflow
from wagtail.snippets.models import get_snippet_models
from .utils import get_snippet_frontend_template, get_snippet_embed_frontend_template
from .utils import get_snippet_link_frontend_template, get_snippet_embed_frontend_template
def choose_snippet_link_model(request):
@ -11,7 +11,7 @@ def choose_snippet_link_model(request):
# Only display those snippet models which have snippet link frontend template
for snippet_model in get_snippet_models():
snippet_frontend_template = get_snippet_frontend_template(
snippet_frontend_template = get_snippet_link_frontend_template(
snippet_model._meta.app_label, snippet_model._meta.model_name
)

View file

@ -14,8 +14,8 @@ from .richtext import (
@hooks.register("register_rich_text_features")
def register_snippet_feature(features):
feature_name = "snippet"
def register_snippet_link_feature(features):
feature_name = "snippet-link"
type_ = "SNIPPET"
features.register_link_type(SnippetLinkHandler)
@ -24,7 +24,7 @@ def register_snippet_feature(features):
"draftail",
feature_name,
draftail_features.EntityFeature(
{"type": type_, "icon": "snippet", "description": ugettext("Snippet")},
{"type": type_, "icon": "snippet", "description": ugettext("Snippet Link")},
js=[
"wagtailsnippets/js/snippet-chooser-modal.js",
"wagtail_draftail_snippet/js/snippet-model-chooser-modal.js",