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:
parent
89f540f823
commit
5c3b0b5da2
@ -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
|
||||
|
||||
|
||||
|
1
wagtail/tests/routablepage/__init__.py
Normal file
1
wagtail/tests/routablepage/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
default_app_config = 'wagtail.tests.routablepage.apps.WagtailRoutablePageTestsAppConfig'
|
7
wagtail/tests/routablepage/apps.py
Normal file
7
wagtail/tests/routablepage/apps.py
Normal 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"
|
25
wagtail/tests/routablepage/migrations/0001_initial.py
Normal file
25
wagtail/tests/routablepage/migrations/0001_initial.py
Normal 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'),
|
||||
),
|
||||
]
|
0
wagtail/tests/routablepage/migrations/__init__.py
Normal file
0
wagtail/tests/routablepage/migrations/__init__.py
Normal file
26
wagtail/tests/routablepage/models.py
Normal file
26
wagtail/tests/routablepage/models.py
Normal 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")
|
@ -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
|
||||
|
21
wagtail/tests/testapp/migrations/0013_auto_20150330_0717.py
Normal file
21
wagtail/tests/testapp/migrations/0013_auto_20150330_0717.py
Normal 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',
|
||||
),
|
||||
]
|
@ -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')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user