mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-21 05:21:54 +00:00
Update *_chooser_panel.html templates so that they don't have to be passed an is_chosen flag
This commit is contained in:
parent
932f532b80
commit
55c585d03e
9 changed files with 9 additions and 27 deletions
|
|
@ -499,7 +499,7 @@ class BaseChooserPanel(BaseFieldPanel):
|
|||
context = {
|
||||
'field': self.bound_field,
|
||||
self.object_type_name: instance_obj,
|
||||
'is_chosen': bool(instance_obj),
|
||||
'is_chosen': bool(instance_obj), # DEPRECATED - passed to templates for backwards compatibility only
|
||||
}
|
||||
return mark_safe(render_to_string(self.field_template, context))
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
{% block form_field %}
|
||||
|
||||
<div id="{{ field.id_for_label }}-chooser" class="chooser {% block chooser_class %}page-chooser{% endblock %} {% if not is_chosen %}blank{% endif %}">
|
||||
<div id="{{ field.id_for_label }}-chooser" class="chooser {% block chooser_class %}page-chooser{% endblock %} {% if not field.value %}blank{% endif %}">
|
||||
|
||||
<div class="chosen">
|
||||
{% block chosen_state_view %}{% endblock %}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
{% include "wagtailadmin/shared/field_as_li.html" with field=form.new_slug %}
|
||||
|
||||
<li class="{% if form.new_parent_page.field.required %}required{% endif %}">
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.new_parent_page page=parent_page is_chosen=True only %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.new_parent_page page=parent_page only %}
|
||||
</li>
|
||||
|
||||
{% if form.copy_subpages %}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,7 @@
|
|||
<legend>{% trans "Promoted search result" %}</legend>
|
||||
<ul class="fields">
|
||||
<li class="model_choice_field">
|
||||
{% if form.instance.page %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.page page=form.instance.page is_chosen=True only %}
|
||||
{% else %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.page is_chosen=False only %}
|
||||
{% endif %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.page page=form.instance.page only %}
|
||||
</li>
|
||||
<li class="char_field">
|
||||
{% include "wagtailadmin/shared/field.html" with field=form.description only %}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,7 @@
|
|||
{% include "wagtailadmin/shared/field_as_li.html" with field=form.port %}
|
||||
|
||||
<li>
|
||||
{% if form.instance.root_page %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.root_page page=form.instance.root_page is_chosen=True only %}
|
||||
{% else %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.root_page is_chosen=False only %}
|
||||
{% endif %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.root_page page=form.instance.root_page only %}
|
||||
</li>
|
||||
|
||||
{% include "wagtailadmin/shared/field_as_li.html" with field=form.is_default_site %}
|
||||
|
|
|
|||
|
|
@ -18,11 +18,7 @@
|
|||
{% include "wagtailadmin/shared/field_as_li.html" with field=form.port %}
|
||||
|
||||
<li>
|
||||
{% if form.instance.root_page %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.root_page page=form.instance.root_page is_chosen=True only %}
|
||||
{% else %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.root_page is_chosen=False only %}
|
||||
{% endif %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.root_page page=form.instance.root_page only %}
|
||||
</li>
|
||||
|
||||
{% include "wagtailadmin/shared/field_as_li.html" with field=form.is_default_site %}
|
||||
|
|
|
|||
|
|
@ -28,14 +28,12 @@ class BaseSnippetChooserPanel(BaseChooserPanel):
|
|||
|
||||
return cls._content_type
|
||||
|
||||
def render_as_field(self, show_help_text=True):
|
||||
def render_as_field(self):
|
||||
instance_obj = self.get_chosen_item()
|
||||
return mark_safe(render_to_string(self.field_template, {
|
||||
'field': self.bound_field,
|
||||
self.object_type_name: instance_obj,
|
||||
'snippet_type_name': self.snippet_type_name,
|
||||
'is_chosen': bool(instance_obj),
|
||||
'show_help_text': show_help_text,
|
||||
}))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@
|
|||
{% block chooser_class %}snippet-chooser{% endblock %}
|
||||
|
||||
{% block chosen_state_view %}
|
||||
<span class="title">{% if is_chosen %}{{ item }}{% endif %}</span>
|
||||
<span class="title">{{ item }}</span>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
{% load i18n %}
|
||||
|
||||
<td>
|
||||
{% if form.instance.page %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.page page=form.instance.page is_chosen=True only %}
|
||||
{% else %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.page is_chosen=False only %}
|
||||
{% endif %}
|
||||
{% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.page page=form.instance.page only %}
|
||||
</td>
|
||||
<td>
|
||||
{% include "wagtailadmin/edit_handlers/field_panel_field.html" with field=form.permission_type only %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue