Renamed wagtail.contrib.wagtailroutablepage to

wagtail.contrib.routable_page

Conflicts:
	docs/reference/contrib/routablepage.rst
pull/4068/head
Karl Hobley 2017-11-17 11:47:10 +00:00 zatwierdzone przez Matt Westcott
rodzic 7f1b60abca
commit 394274b0a1
13 zmienionych plików z 18 dodań i 18 usunięć

Wyświetl plik

@ -4,7 +4,7 @@
``RoutablePageMixin``
=====================
.. module:: wagtail.contrib.wagtailroutablepage
.. module:: wagtail.contrib.routable_page
The ``RoutablePageMixin`` mixin provides a convenient way for a page to respond on multiple sub-URLs with different views. For example, a blog section on a site might provide several different types of index page at URLs like ``/blog/2013/06/``, ``/blog/authors/bob/``, ``/blog/tagged/python/``, all served by the same page instance.
@ -16,28 +16,28 @@ By default a route for ``r'^$'`` exists, which serves the content exactly like a
Installation
============
Add ``"wagtail.contrib.wagtailroutablepage"`` to your INSTALLED_APPS:
Add ``"wagtail.contrib.routable_page"`` to your INSTALLED_APPS:
.. code-block:: python
INSTALLED_APPS = [
...
"wagtail.contrib.wagtailroutablepage",
"wagtail.contrib.routable_page",
]
The basics
==========
To use ``RoutablePageMixin``, you need to make your class inherit from both :class:`wagtail.contrib.wagtailroutablepage.models.RoutablePageMixin` and :class:`wagtail.core.models.Page`, then define some view methods and decorate them with ``wagtail.contrib.wagtailroutablepage.models.route``.
To use ``RoutablePageMixin``, you need to make your class inherit from both :class:`wagtail.contrib.routable_page.models.RoutablePageMixin` and :class:`wagtail.core.models.Page`, then define some view methods and decorate them with ``wagtail.contrib.routable_page.models.route``.
Here's an example of an ``EventPage`` with three views:
.. code-block:: python
from wagtail.core.models import Page
from wagtail.contrib.wagtailroutablepage.models import RoutablePageMixin, route
from wagtail.contrib.routable_page.models import RoutablePageMixin, route
class EventPage(RoutablePageMixin, Page):
@ -95,7 +95,7 @@ The route name defaults to the name of the view. You can override this name with
.. code-block:: python
from wagtail.core.models import Page
from wagtail.contrib.wagtailroutablepage.models import RoutablePageMixin, route
from wagtail.contrib.routable_page.models import RoutablePageMixin, route
class EventPage(RoutablePageMixin, Page):
@ -116,7 +116,7 @@ The route name defaults to the name of the view. You can override this name with
The ``RoutablePageMixin`` class
===============================
.. automodule:: wagtail.contrib.wagtailroutablepage.models
.. automodule:: wagtail.contrib.routable_page.models
.. autoclass:: RoutablePageMixin
.. automethod:: get_subpage_urls
@ -144,7 +144,7 @@ The ``RoutablePageMixin`` class
The ``routablepageurl`` template tag
====================================
.. currentmodule:: wagtail.contrib.wagtailroutablepage.templatetags.wagtailroutablepage_tags
.. currentmodule:: wagtail.contrib.routable_page.templatetags.wagtailroutablepage_tags
.. autofunction:: routablepageurl
Example:

Wyświetl plik

@ -46,7 +46,7 @@ Adding Endpoints with Custom :meth:`~wagtail.core.models.Page.route` Methods
.. note::
A much simpler way of adding more endpoints to pages is provided by the :mod:`~wagtail.contrib.wagtailroutablepage` module.
A much simpler way of adding more endpoints to pages is provided by the :mod:`~wagtail.contrib.routable_page` module.
Wagtail routes requests by iterating over the path components (separated with a forward slash ``/``), finding matching objects based on their slug, and delegating further routing to that object's model class. The Wagtail source is very instructive in figuring out what's happening. This is the default ``route()`` method of the ``Page`` class:

Wyświetl plik

@ -0,0 +1 @@
default_app_config = 'wagtail.contrib.routable_page.apps.WagtailRoutablePageAppConfig'

Wyświetl plik

@ -4,6 +4,6 @@ from django.apps import AppConfig
class WagtailRoutablePageAppConfig(AppConfig):
name = 'wagtail.contrib.wagtailroutablepage'
name = 'wagtail.contrib.routable_page'
label = 'wagtailroutablepage'
verbose_name = "Wagtail routablepage"

Wyświetl plik

@ -4,7 +4,7 @@ import mock
from django.test import RequestFactory, TestCase
from django.urls.exceptions import NoReverseMatch
from wagtail.contrib.wagtailroutablepage.templatetags.wagtailroutablepage_tags import \
from wagtail.contrib.routable_page.templatetags.wagtailroutablepage_tags import \
routablepageurl
from wagtail.tests.routablepage.models import (
RoutablePageTest, RoutablePageWithOverriddenIndexRouteTest)

Wyświetl plik

@ -1 +0,0 @@
default_app_config = 'wagtail.contrib.wagtailroutablepage.apps.WagtailRoutablePageAppConfig'

Wyświetl plik

@ -5,7 +5,7 @@ from __future__ import unicode_literals
import django.db.models.deletion
from django.db import migrations, models
import wagtail.contrib.wagtailroutablepage.models
import wagtail.contrib.routable_page.models
class Migration(migrations.Migration):
@ -25,6 +25,6 @@ class Migration(migrations.Migration):
options={
'abstract': False,
},
bases=(wagtail.contrib.wagtailroutablepage.models.RoutablePageMixin, 'wagtailcore.page'),
bases=(wagtail.contrib.routable_page.models.RoutablePageMixin, 'wagtailcore.page'),
),
]

Wyświetl plik

@ -4,7 +4,7 @@ from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import wagtail.contrib.wagtailroutablepage.models
import wagtail.contrib.routable_page.models
class Migration(migrations.Migration):
@ -23,6 +23,6 @@ class Migration(migrations.Migration):
options={
'abstract': False,
},
bases=(wagtail.contrib.wagtailroutablepage.models.RoutablePageMixin, 'wagtailcore.page'),
bases=(wagtail.contrib.routable_page.models.RoutablePageMixin, 'wagtailcore.page'),
),
]

Wyświetl plik

@ -2,7 +2,7 @@ from __future__ import absolute_import, unicode_literals
from django.http import HttpResponse
from wagtail.contrib.wagtailroutablepage.models import RoutablePage, route
from wagtail.contrib.routable_page.models import RoutablePage, route
def routable_page_external_view(request, arg="ARG NOT SET"):

Wyświetl plik

@ -112,7 +112,7 @@ INSTALLED_APPS = (
'wagtail.tests.search',
'wagtail.tests.modeladmintest',
'wagtail.contrib.wagtailstyleguide',
'wagtail.contrib.wagtailroutablepage',
'wagtail.contrib.routable_page',
'wagtail.contrib.frontend_cache',
'wagtail.contrib.wagtailsearchpromotions',
'wagtail.contrib.settings',