0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Moved routablepage test model into its own app

This commit is contained in:
Karl Hobley 2015-03-30 13:24:18 +01:00
parent 89f540f823
commit 5c3b0b5da2
9 changed files with 82 additions and 25 deletions

View File

@ -1,7 +1,7 @@
from django.test import TestCase, RequestFactory
from wagtail.wagtailcore.models import Page, Site
from wagtail.tests.testapp.models import RoutablePageTest, routable_page_external_view
from wagtail.tests.routablepage.models import RoutablePageTest, routable_page_external_view
from wagtail.contrib.wagtailroutablepage.templatetags.wagtailroutablepage_tags import routablepageurl

View File

@ -0,0 +1 @@
default_app_config = 'wagtail.tests.routablepage.apps.WagtailRoutablePageTestsAppConfig'

View File

@ -0,0 +1,7 @@
from django.apps import AppConfig
class WagtailRoutablePageTestsAppConfig(AppConfig):
name = 'wagtail.tests.routablepage'
label = 'routablepagetests'
verbose_name = "Wagtail routable page tests"

View File

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import wagtail.contrib.wagtailroutablepage.models
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '0013_update_golive_expire_help_text'),
]
operations = [
migrations.CreateModel(
name='RoutablePageTest',
fields=[
('page_ptr', models.OneToOneField(to='wagtailcore.Page', serialize=False, auto_created=True, primary_key=True, parent_link=True)),
],
options={
'abstract': False,
},
bases=(wagtail.contrib.wagtailroutablepage.models.RoutablePageMixin, 'wagtailcore.page'),
),
]

View File

@ -0,0 +1,26 @@
from django.db import models
from django.http import HttpResponse
from django.conf.urls import url
from wagtail.contrib.wagtailroutablepage.models import RoutablePage
def routable_page_external_view(request, arg):
return HttpResponse("EXTERNAL VIEW: " + arg)
class RoutablePageTest(RoutablePage):
subpage_urls = (
url(r'^$', 'main', name='main'),
url(r'^archive/year/(\d+)/$', 'archive_by_year', name='archive_by_year'),
url(r'^archive/author/(?P<author_slug>.+)/$', 'archive_by_author', name='archive_by_author'),
url(r'^external/(.+)/$', routable_page_external_view, name='external_view')
)
def archive_by_year(self, request, year):
return HttpResponse("ARCHIVE BY YEAR: " + str(year))
def archive_by_author(self, request, author_slug):
return HttpResponse("ARCHIVE BY AUTHOR: " + author_slug)
def main(self, request):
return HttpResponse("MAIN VIEW")

View File

@ -79,6 +79,7 @@ INSTALLED_APPS = (
'wagtail.tests.testapp',
'wagtail.tests.customuser',
'wagtail.tests.snippets',
'wagtail.tests.routablepage',
# Install wagtailredirects with its appconfig
# Theres nothing special about wagtailredirects, we just need to have one

View File

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '0013_update_golive_expire_help_text'),
('wagtailforms', '0001_initial'),
('wagtailredirects', '0001_initial'),
('wagtailsearch', '0001_initial'),
('tests', '0012_auto_20150330_0709'),
]
operations = [
migrations.DeleteModel(
name='RoutablePageTest',
),
]

View File

@ -3,8 +3,6 @@ from __future__ import unicode_literals
from django.db import models
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.utils.encoding import python_2_unicode_compatible
from django.conf.urls import url
from django.http import HttpResponse
from taggit.models import TaggedItemBase
@ -20,7 +18,6 @@ from wagtail.wagtailsnippets.models import register_snippet
from wagtail.wagtailforms.models import AbstractEmailForm, AbstractFormField
from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel
from wagtail.wagtailsearch import index
from wagtail.contrib.wagtailroutablepage.models import RoutablePage
from wagtail.wagtailimages.models import AbstractImage, Image
@ -414,27 +411,6 @@ class SearchTestChild(SearchTest):
]
def routable_page_external_view(request, arg):
return HttpResponse("EXTERNAL VIEW: " + arg)
class RoutablePageTest(RoutablePage):
subpage_urls = (
url(r'^$', 'main', name='main'),
url(r'^archive/year/(\d+)/$', 'archive_by_year', name='archive_by_year'),
url(r'^archive/author/(?P<author_slug>.+)/$', 'archive_by_author', name='archive_by_author'),
url(r'^external/(.+)/$', routable_page_external_view, name='external_view')
)
def archive_by_year(self, request, year):
return HttpResponse("ARCHIVE BY YEAR: " + str(year))
def archive_by_author(self, request, author_slug):
return HttpResponse("ARCHIVE BY AUTHOR: " + author_slug)
def main(self, request):
return HttpResponse("MAIN VIEW")
class TaggedPageTag(TaggedItemBase):
content_object = ParentalKey('tests.TaggedPage', related_name='tagged_items')