mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-14 20:10:59 +00:00
Merge branch 'edrex-694_userbar_add_child_page'
This commit is contained in:
commit
c87802b68b
13 changed files with 97 additions and 80 deletions
|
|
@ -40,6 +40,7 @@ Changelog
|
|||
* Added hooks `register_rich_text_embed_handler` and `register_rich_text_link_handler` for customising link / embed handling within rich text fields
|
||||
* Added hook `construct_homepage_summary_items` for customising the site summary panel on the admin homepage
|
||||
* No longer automatically tries to use Celery for sending notification emails
|
||||
* Added "Add child page" button to admin userbar (Eric Drechsel)
|
||||
|
||||
|
||||
0.8.6 (10.03.2015)
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ Admin
|
|||
* Added pagination to the snippets listing and chooser
|
||||
* Page / document / image / snippet choosers now include a link to edit the chosen item
|
||||
* Plain text fields in the page editor now use auto-expanding text areas
|
||||
* Added "Add child page" button to admin userbar
|
||||
|
||||
|
||||
**Page editor**
|
||||
|
|
|
|||
13
wagtail/tests/templates/tests/base.html
Normal file
13
wagtail/tests/templates/tests/base.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{% load wagtailuserbar %}
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>{% block html_title %}{{ self.title }}{% endblock %}</title>
|
||||
</head>
|
||||
<body>
|
||||
{% wagtailuserbar %}
|
||||
<h1>{{ self.title }}</h1>
|
||||
{% block content %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
5
wagtail/tests/templates/tests/business_child.html
Normal file
5
wagtail/tests/templates/tests/business_child.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{% extends "tests/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Business Child</h2>
|
||||
{% endblock %}
|
||||
|
|
@ -1,10 +1,5 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ self.title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ self.title }}</h1>
|
||||
{% include "tests/includes/event_listing.html" %}
|
||||
</body>
|
||||
</html>
|
||||
{% extends "tests/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
{% include "tests/includes/event_listing.html" %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,12 @@
|
|||
{% extends "tests/base.html" %}
|
||||
{% load wagtailcore_tags wagtailimages_tags %}
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Event: {{ self.title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ self.title }}</h1>
|
||||
<h2>Event</h2>
|
||||
{% if self.feed_image %}
|
||||
{% image self.feed_image width-200 class="feed-image" %}
|
||||
{% endif %}
|
||||
{{ self.body|richtext }}
|
||||
<p><a href="{% slugurl 'events' %}">Back to events index</a></p>
|
||||
</body>
|
||||
</html>
|
||||
{% block html_title %}Event: {{ self.title }}{% endblock %}
|
||||
{% block content %}
|
||||
<h2>Event</h2>
|
||||
{% if self.feed_image %}
|
||||
{% image self.feed_image width-200 class="feed-image" %}
|
||||
{% endif %}
|
||||
{{ self.body|richtext }}
|
||||
<p><a href="{% slugurl 'events' %}">Back to events index</a></p>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,10 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ self.title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ self.title }}</h1>
|
||||
<p>This event is invitation only. Please enter your password to see the details.</p>
|
||||
<form action="{{ action_url }}" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="Continue" />
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
{% extends "tests/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<p>This event is invitation only. Please enter your password to see the details.</p>
|
||||
<form action="{{ action_url }}" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit" value="Continue" />
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,10 @@
|
|||
{% extends "tests/base.html" %}
|
||||
{% load wagtailcore_tags %}
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ self.title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ self.title }}</h1>
|
||||
<form action="{% pageurl self %}" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
{% block content %}
|
||||
<form action="{% pageurl self %}" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input type="submit">
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,5 @@
|
|||
{% load wagtailcore_tags %}
|
||||
{% extends "tests/base.html" %}
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ self.title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ self.title }}</h1>
|
||||
<p>Thank you for your feedback.</p>
|
||||
</body>
|
||||
</html>
|
||||
{% block content %}
|
||||
<p>Thank you for your feedback.</p>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,5 @@
|
|||
{% load wagtailcore_tags %}
|
||||
{% extends "tests/base.html" %}
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>{{ self.title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{ self.title }}</h1>
|
||||
<h2>Simple page</h2>
|
||||
</body>
|
||||
</html>
|
||||
{% block content %}
|
||||
<h2>Simple page</h2>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block item_content %}
|
||||
<a href="{% url 'wagtailadmin_pages_add_subpage' self.parent_page.id %}" target="_parent" class="action icon icon-plus" title="{% trans 'Add another page at this level' %}">{% trans 'Add' %}</a>
|
||||
{% endblock %}
|
||||
<a href="{% url 'wagtailadmin_pages_add_subpage' self.page.id %}" target="_parent" class="action icon icon-plus" title="{% trans 'Add a child page' %}">{% trans 'Add' %}</a>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from django.contrib.auth.models import AnonymousUser
|
|||
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail.tests.models import BusinessIndex, BusinessChild
|
||||
|
||||
|
||||
class TestUserbarTag(TestCase):
|
||||
|
|
@ -60,6 +61,37 @@ class TestUserbarFrontend(TestCase, WagtailTestUtils):
|
|||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
|
||||
class TestUserbarAddLink(TestCase, WagtailTestUtils):
|
||||
fixtures = ['test.json']
|
||||
|
||||
def setUp(self):
|
||||
self.login()
|
||||
self.homepage = Page.objects.get(url_path='/home/')
|
||||
self.event_index = Page.objects.get(url_path='/home/events/')
|
||||
|
||||
self.business_index = BusinessIndex(title='Business', slug='business', live=True)
|
||||
self.homepage.add_child(instance=self.business_index)
|
||||
|
||||
self.business_child = BusinessChild(title='Business Child', slug='child', live=True)
|
||||
self.business_index.add_child(instance=self.business_child)
|
||||
|
||||
def test_page_allowing_subpages(self):
|
||||
response = self.client.get(reverse('wagtailadmin_userbar_frontend', args=(self.event_index.id, )))
|
||||
|
||||
# page allows subpages, so the 'add page' button should show
|
||||
expected_url = reverse('wagtailadmin_pages_add_subpage', args=(self.event_index.id, ))
|
||||
expected_link = '<a href="%s" target="_parent" class="action icon icon-plus" title="Add a child page">Add</a>' % expected_url
|
||||
self.assertContains(response, expected_link)
|
||||
|
||||
def test_page_disallowing_subpages(self):
|
||||
response = self.client.get(reverse('wagtailadmin_userbar_frontend', args=(self.business_child.id, )))
|
||||
|
||||
# page disallows subpages, so the 'add page' button shouldn't show
|
||||
expected_url = reverse('wagtailadmin_pages_add_subpage', args=(self.business_index.id, ))
|
||||
expected_link = '<a href="%s" target="_parent" class="action icon icon-plus" title="Add a child page">Add</a>' % expected_url
|
||||
self.assertNotContains(response, expected_link)
|
||||
|
||||
|
||||
class TestUserbarModeration(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
self.login()
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ class AddPageItem(BaseItem):
|
|||
if not request.user.has_perm('wagtailadmin.access_admin'):
|
||||
return ""
|
||||
|
||||
# Don't render if user doesn't have ability to add siblings
|
||||
permission_checker = self.page.get_parent().permissions_for_user(request.user)
|
||||
# Don't render if user doesn't have ability to add children here
|
||||
permission_checker = self.page.permissions_for_user(request.user)
|
||||
if not permission_checker.can_add_subpage():
|
||||
return ""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue