Merge branch 'feature/explorer-root-help'

This commit is contained in:
Matt Westcott 2015-09-03 12:00:25 +01:00
commit 5db2f36928
5 changed files with 122 additions and 11 deletions

View file

@ -14,7 +14,7 @@
{% csrf_token %}
{% page_permissions parent_page as parent_page_perms %}
{% include "wagtailadmin/pages/listing/_list_explore.html" with sortable=1 allow_navigation=1 full_width=1 parent_page=parent_page orderable=parent_page_perms.can_reorder_children %}
{% include "wagtailadmin/pages/listing/_list_explore.html" with sortable=1 allow_navigation=1 full_width=1 show_ordering_column=1 parent_page=parent_page orderable=parent_page_perms.can_reorder_children %}
{% url 'wagtailadmin_explore' parent_page.id as pagination_base_url %}
{% include "wagtailadmin/pages/listing/_pagination.html" with page=pages base_url=pagination_base_url query_params=pagination_query_params only %}

View file

@ -1,7 +1,7 @@
{% load i18n %}
{% load wagtailadmin_tags %}
<table class="listing {% if full_width %}full-width{% endif %} {% block table_classname %}{% endblock %}">
{% if orderable %}
{% if show_ordering_column %}
<col width="50px" />
{% endif %}
<col />
@ -19,7 +19,7 @@
{% if parent_page %}
{% page_permissions parent_page as parent_page_perms %}
<tr class="index {% if not parent_page.live %} unpublished{% endif %} {% block parent_page_row_classname %}{% endblock %}">
<td class="title" {% if orderable %}colspan="2"{% endif %}>
<td class="title" {% if show_ordering_column %}colspan="2"{% endif %}>
{% block parent_page_title %}
{% endblock %}
</td>
@ -46,8 +46,8 @@
{% for page in pages %}
{% page_permissions page as page_perms %}
<tr {% if ordering == "ord" %}id="page_{{ page.id }}" data-page-title="{{ page.title }}"{% endif %} class="{% if not page.live %}unpublished{% endif %} {% block page_row_classname %}{% endblock %}">
{% if orderable %}
<td class="ord">{% if ordering == "ord" %}<div class="handle icon icon-grip text-replace">{% trans 'Drag' %}</div>{% endif %}</td>
{% if show_ordering_column %}
<td class="ord">{% if orderable and ordering == "ord" %}<div class="handle icon icon-grip text-replace">{% trans 'Drag' %}</div>{% endif %}</td>
{% endif %}
<td class="title" valign="top">
{% block page_title %}

View file

@ -9,6 +9,50 @@
{% endblock %}
{% block post_parent_page_headers %}
{% if parent_page %}
{% if parent_page.is_root %}
<tr><td colspan="6"><div class="help-block help-info">
{% if perms.wagtailcore.add_site %}
{% url 'wagtailsites:index' as wagtailsites_index_url %}
<p>
{% blocktrans %}
The root level is where you can add new sites to your Wagtail installation. Pages created here will not be accessible at any URL until they are associated with a site.
{% endblocktrans %}
{% if wagtailsites_index_url %}
<a href="{{ wagtailsites_index_url }}">{% trans "Configure a site now." %}</a>
{% endif %}
</p>
<p>
{% blocktrans %}
If you just want to add pages to an existing site, create them as children of the homepage instead.
{% endblocktrans %}
</p>
{% else %}
{% blocktrans %}
Pages created here will not be accessible at any URL. To add pages to an existing site, create them as children of the homepage.
{% endblocktrans %}
{% endif %}
</div></td></tr>
{% elif not parent_page.url %}
<tr><td colspan="6"><div class="help-block help-warning">
{% if perms.wagtailcore.add_site %}
{% url 'wagtailsites:index' as wagtailsites_index_url %}
{% blocktrans %}
There is no site set up for this location. Pages created here will not be accessible at any URL until a site is associated with this location.
{% endblocktrans %}
{% if wagtailsites_index_url %}
<a href="{{ wagtailsites_index_url }}">{% trans "Configure a site now." %}</a>
{% endif %}
{% else %}
{% blocktrans %}
There is no site record for this location. Pages created here will not be accessible at any URL.
{% endblocktrans %}
{% endif %}
</div></td></tr>
{% endif %}
{% endif %}
{% include "wagtailadmin/pages/listing/_table_headers_explore.html" %}
{% endblock %}

View file

@ -5,7 +5,8 @@
Table headers for the page listing, when in 'explore' mode. Expects the following variables:
sortable: if true, headings are links to wagtailadmin_explore with sort parameters applied.
orderable: if true, an 'ordering' column is added (again with links to wagtailadmin_explore).
show_ordering_column: if true, an 'ordering' column is added.
orderable: if true, the 'ordering' column is populated (again with links to wagtailadmin_explore).
If either sortable or orderable is true, the following variables are also required:
@ -15,12 +16,14 @@ ordering: the current sort parameter
{% endcomment %}
<tr class="table-headers">
{% if orderable %}
{% if show_ordering_column %}
<th class="ord">
{% if ordering == "ord" %}
<a href="{% url 'wagtailadmin_explore' parent_page.id %}" class="icon icon-order text-replace" title="{% trans 'Disable ordering of child pages' %}">{% trans 'Order' %}</a></th>
{% else %}
<a href="{% url 'wagtailadmin_explore' parent_page.id %}?ordering=ord" class="icon icon-order text-replace" title="{% trans 'Enable ordering of child pages' %}">{% trans 'Order' %}</a></th>
{% if orderable %}
{% if ordering == "ord" %}
<a href="{% url 'wagtailadmin_explore' parent_page.id %}" class="icon icon-order text-replace" title="{% trans 'Disable ordering of child pages' %}">{% trans 'Order' %}</a></th>
{% else %}
<a href="{% url 'wagtailadmin_explore' parent_page.id %}?ordering=ord" class="icon icon-order text-replace" title="{% trans 'Enable ordering of child pages' %}">{% trans 'Order' %}</a></th>
{% endif %}
{% endif %}
</th>
{% endif %}

View file

@ -126,6 +126,70 @@ class TestPageExplorer(TestCase, WagtailTestUtils):
self.assertEqual(response.context['pages'].number, response.context['pages'].paginator.num_pages)
class TestPageExplorerSignposting(TestCase, WagtailTestUtils):
fixtures = ['test.json']
def setUp(self):
# Find root page
self.root_page = Page.objects.get(id=1)
# Find page with an associated site
self.site_page = Page.objects.get(id=2)
# Add another top-level page (which will have no corresponding site record)
self.no_site_page = SimplePage(
title="Hello world!",
slug="hello-world",
)
self.root_page.add_child(instance=self.no_site_page)
def test_admin_at_root(self):
self.client.login(username='superuser', password='password')
response = self.client.get(reverse('wagtailadmin_explore_root'))
self.assertEqual(response.status_code, 200)
# Administrator (or user with add_site permission) should get the full message
# about configuring sites
self.assertContains(response, "The root level is where you can add new sites to your Wagtail installation. Pages created here will not be accessible at any URL until they are associated with a site.")
self.assertContains(response, """<a href="/admin/sites/">Configure a site now.</a>""")
def test_admin_at_non_site_page(self):
self.client.login(username='superuser', password='password')
response = self.client.get(reverse('wagtailadmin_explore', args=(self.no_site_page.id, )))
self.assertEqual(response.status_code, 200)
# Administrator (or user with add_site permission) should get a warning about
# unroutable pages, and be directed to the site config area
self.assertContains(response, "There is no site set up for this location. Pages created here will not be accessible at any URL until a site is associated with this location.")
self.assertContains(response, """<a href="/admin/sites/">Configure a site now.</a>""")
def test_admin_at_site_page(self):
self.client.login(username='superuser', password='password')
response = self.client.get(reverse('wagtailadmin_explore', args=(self.site_page.id, )))
self.assertEqual(response.status_code, 200)
# There should be no warning message here
self.assertNotContains(response, "Pages created here will not be accessible")
def test_nonadmin_at_root(self):
self.client.login(username='siteeditor', password='password')
response = self.client.get(reverse('wagtailadmin_explore_root'))
self.assertEqual(response.status_code, 200)
# Non-admin should get a simple "create pages as children of the homepage" prompt
self.assertContains(response, "Pages created here will not be accessible at any URL. To add pages to an existing site, create them as children of the homepage.")
def test_nonadmin_at_non_site_page(self):
self.client.login(username='siteeditor', password='password')
response = self.client.get(reverse('wagtailadmin_explore', args=(self.no_site_page.id, )))
self.assertEqual(response.status_code, 200)
# Non-admin should get a warning about unroutable pages
self.assertContains(response, "There is no site record for this location. Pages created here will not be accessible at any URL.")
def test_nonadmin_at_site_page(self):
self.client.login(username='siteeditor', password='password')
response = self.client.get(reverse('wagtailadmin_explore', args=(self.site_page.id, )))
self.assertEqual(response.status_code, 200)
# There should be no warning message here
self.assertNotContains(response, "Pages created here will not be accessible")
class TestPageCreation(TestCase, WagtailTestUtils):
def setUp(self):
# Find root page