Rename current Snippet feature snippet to snippet-link
This commit is contained in:
parent
c50800ff84
commit
df521783f8
4 changed files with 9 additions and 9 deletions
|
@ -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.admin.rich_text.converters.html_to_contentstate import LinkElementHandler, AtomicBlockEntityElementHandler
|
||||||
from wagtail.core.rich_text import EmbedHandler, LinkHandler
|
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
|
# Snippet Link
|
||||||
|
@ -22,7 +22,7 @@ class SnippetLinkHandler(LinkHandler):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_template(cls, attrs):
|
def get_template(cls, attrs):
|
||||||
return get_snippet_frontend_template(
|
return get_snippet_link_frontend_template(
|
||||||
attrs["data-app-name"], attrs["data-model-name"]
|
attrs["data-app-name"], attrs["data-model-name"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
from wagtail.core.utils import camelcase_to_underscore
|
from wagtail.core.utils import camelcase_to_underscore
|
||||||
|
|
||||||
|
|
||||||
def get_snippet_frontend_template(app_name, model_name):
|
def get_snippet_link_frontend_template(app_name, model_name):
|
||||||
return "%s/%s_snippet.html" % (app_name, camelcase_to_underscore(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):
|
def get_snippet_embed_frontend_template(app_name, model_name):
|
||||||
|
|
|
@ -3,7 +3,7 @@ from django.template.loader import TemplateDoesNotExist, get_template
|
||||||
from wagtail.admin.modal_workflow import render_modal_workflow
|
from wagtail.admin.modal_workflow import render_modal_workflow
|
||||||
from wagtail.snippets.models import get_snippet_models
|
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):
|
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
|
# Only display those snippet models which have snippet link frontend template
|
||||||
for snippet_model in get_snippet_models():
|
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
|
snippet_model._meta.app_label, snippet_model._meta.model_name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ from .richtext import (
|
||||||
|
|
||||||
|
|
||||||
@hooks.register("register_rich_text_features")
|
@hooks.register("register_rich_text_features")
|
||||||
def register_snippet_feature(features):
|
def register_snippet_link_feature(features):
|
||||||
feature_name = "snippet"
|
feature_name = "snippet-link"
|
||||||
type_ = "SNIPPET"
|
type_ = "SNIPPET"
|
||||||
|
|
||||||
features.register_link_type(SnippetLinkHandler)
|
features.register_link_type(SnippetLinkHandler)
|
||||||
|
@ -24,7 +24,7 @@ def register_snippet_feature(features):
|
||||||
"draftail",
|
"draftail",
|
||||||
feature_name,
|
feature_name,
|
||||||
draftail_features.EntityFeature(
|
draftail_features.EntityFeature(
|
||||||
{"type": type_, "icon": "snippet", "description": ugettext("Snippet")},
|
{"type": type_, "icon": "snippet", "description": ugettext("Snippet Link")},
|
||||||
js=[
|
js=[
|
||||||
"wagtailsnippets/js/snippet-chooser-modal.js",
|
"wagtailsnippets/js/snippet-chooser-modal.js",
|
||||||
"wagtail_draftail_snippet/js/snippet-model-chooser-modal.js",
|
"wagtail_draftail_snippet/js/snippet-model-chooser-modal.js",
|
||||||
|
|
Reference in a new issue