Remember tree location in page chooser when switching between Internal / External / Email link

Fixes #2640
pull/2694/head
Matt Westcott 2016-06-03 17:00:23 +01:00 zatwierdzone przez Mikalai Radchuk
rodzic ba220d58ca
commit 594470182a
2 zmienionych plików z 13 dodań i 3 usunięć

Wyświetl plik

@ -4,19 +4,23 @@
{% if current == 'internal' %}
<b>{% trans "Internal link" %}</b>
{% else %}
<a href="{% url 'wagtailadmin_choose_page' %}{% querystring p=None %}">{% trans "Internal link" %}</a>
{% if parent_page_id %}
<a href="{% url 'wagtailadmin_choose_page_child' parent_page_id %}{% querystring p=None parent_page_id=None %}">{% trans "Internal link" %}</a>
{% else %}
<a href="{% url 'wagtailadmin_choose_page' %}{% querystring p=None parent_page_id=None %}">{% trans "Internal link" %}</a>
{% endif %}
{% endif %}
{% if current == 'external' %}
| <b>{% trans "External link" %}</b>
{% elif allow_external_link %}
| <a href="{% url 'wagtailadmin_choose_page_external_link' %}{% querystring p=None %}">{% trans "External link" %}</a>
| <a href="{% url 'wagtailadmin_choose_page_external_link' %}{% querystring p=None parent_page_id=parent_page_id %}">{% trans "External link" %}</a>
{% endif %}
{% if current == 'email' %}
| <b>{% trans "Email link" %}</b>
{% elif allow_email_link %}
| <a href="{% url 'wagtailadmin_choose_page_email_link' %}{% querystring p=None %}">{% trans "Email link" %}</a>
| <a href="{% url 'wagtailadmin_choose_page_email_link' %}{% querystring p=None parent_page_id=parent_page_id %}">{% trans "Email link" %}</a>
{% endif %}
</p>
{% endif %}

Wyświetl plik

@ -12,6 +12,11 @@ from wagtail.wagtailcore.utils import resolve_model_string
def shared_context(request, extra_context={}):
context = {
# parent_page ID is passed as a GET parameter on the external_link and email_link views
# so that it's remembered when browsing from 'Internal link' to another link type
# and back again. On the 'browse' / 'internal link' view this will be overridden to be
# sourced from the standard URL path parameter instead.
'parent_page_id': request.GET.get('parent_page_id'),
'allow_external_link': request.GET.get('allow_external_link'),
'allow_email_link': request.GET.get('allow_email_link'),
}
@ -98,6 +103,7 @@ def browse(request, parent_page_id=None):
'wagtailadmin/chooser/browse.html', 'wagtailadmin/chooser/browse.js',
shared_context(request, {
'parent_page': parent_page,
'parent_page_id': parent_page.pk,
'pages': pages,
'search_form': SearchForm(),
'page_type_string': page_type_string,