kopia lustrzana https://github.com/wagtail/wagtail
Use media for privacy switch JS
rodzic
a5a24f9ee6
commit
d5fdff57f9
|
@ -20,6 +20,7 @@ from modelcluster.models import get_serializable_data_for_fields
|
||||||
|
|
||||||
from wagtail.admin import compare
|
from wagtail.admin import compare
|
||||||
from wagtail.admin.forms.comments import CommentForm
|
from wagtail.admin.forms.comments import CommentForm
|
||||||
|
from wagtail.admin.staticfiles import versioned_static
|
||||||
from wagtail.admin.templatetags.wagtailadmin_tags import avatar_url, user_display_name
|
from wagtail.admin.templatetags.wagtailadmin_tags import avatar_url, user_display_name
|
||||||
from wagtail.admin.ui.components import Component
|
from wagtail.admin.ui.components import Component
|
||||||
from wagtail.admin.widgets import AdminPageChooser
|
from wagtail.admin.widgets import AdminPageChooser
|
||||||
|
@ -1004,19 +1005,15 @@ class PrivacyModalPanel(Panel):
|
||||||
class BoundPanel(Panel.BoundPanel):
|
class BoundPanel(Panel.BoundPanel):
|
||||||
template_name = "wagtailadmin/pages/privacy_switch_panel.html"
|
template_name = "wagtailadmin/pages/privacy_switch_panel.html"
|
||||||
|
|
||||||
def render_html(self):
|
def get_context_data(self, parent_context=None):
|
||||||
content = render_to_string(
|
context = super().get_context_data(parent_context)
|
||||||
self.template_name,
|
context["page"] = self.instance
|
||||||
{"self": self, "page": self.instance, "request": self.request},
|
context["request"] = self.request
|
||||||
)
|
return context
|
||||||
|
|
||||||
from wagtail.admin.staticfiles import versioned_static
|
@cached_property
|
||||||
|
def media(self):
|
||||||
return mark_safe(
|
return Media(js=[versioned_static("wagtailadmin/js/privacy-switch.js")])
|
||||||
'{0}<script type="text/javascript" src="{1}"></script>'.format(
|
|
||||||
content, versioned_static("wagtailadmin/js/privacy-switch.js")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class CommentPanel(Panel):
|
class CommentPanel(Panel):
|
||||||
|
|
Ładowanie…
Reference in New Issue