Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performed upgrade changes for wagtail 2.0 and django 2.0 #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 41 additions & 15 deletions wagtail_calendar/tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
def get_wagtail_major_version():
import wagtail
return wagtail.VERSION[0]


SECRET_KEY = 'secret'

ROOT_URLCONF = 'wagtail_calendar.tests.urls'
Expand All @@ -10,35 +15,56 @@
}
}

MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)

INSTALLED_APPS = (

INSTALLED_APPS = [
'wagtail_calendar',
'wagtail.contrib.wagtailroutablepage',
'wagtail.wagtailforms',
'wagtail.wagtailredirects',
'wagtail.wagtailembeds',
'wagtail.wagtailsites',
'wagtail.wagtailusers',
'wagtail.wagtailsnippets',
'wagtail.wagtaildocs',
'wagtail.wagtailimages',
'wagtail.wagtailsearch',
'wagtail.wagtailadmin',
'wagtail.wagtailcore',
'modelcluster',
'taggit',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.staticfiles',
)
]

if get_wagtail_major_version() >= 2:
INSTALLED_APPS += [
'wagtail.contrib.routable_page',
'wagtail.contrib.forms',
'wagtail.contrib.redirects',
'wagtail.embeds',
'wagtail.sites',
'wagtail.users',
'wagtail.snippets',
'wagtail.documents',
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
]
else:
INSTALLED_APPS += [
'wagtail.contrib.wagtailroutablepage',
'wagtail.wagtailforms',
'wagtail.wagtailredirects',
'wagtail.wagtailembeds',
'wagtail.wagtailsites',
'wagtail.wagtailusers',
'wagtail.wagtailsnippets',
'wagtail.wagtaildocs',
'wagtail.wagtailimages',
'wagtail.wagtailsearch',
'wagtail.wagtailadmin',
'wagtail.wagtailcore',
]

TEMPLATES = [
{
Expand Down
5 changes: 4 additions & 1 deletion wagtail_calendar/tests/test_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

from django.test import TestCase
from django.utils import timezone
from wagtail.wagtailcore.hooks import get_hooks
try:
from wagtail.core.hooks import get_hooks
except:
from wagtail.wagtailcore.hooks import get_hooks

from wagtail_calendar.tests.utils import TestEventsMixin

Expand Down
6 changes: 5 additions & 1 deletion wagtail_calendar/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
from django.urls import reverse
from django.utils import timezone
from wagtail.tests.utils import WagtailTestUtils
from wagtail.wagtailcore.models import Page

try:
from wagtail.core.models import Page
except ImportError:
from wagtail.wagtailcore.models import Page

from wagtail_calendar.tests.utils import TestEventsMixin

Expand Down
26 changes: 18 additions & 8 deletions wagtail_calendar/tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
from __future__ import absolute_import, unicode_literals

from django.conf.urls import include, url
from wagtail.contrib.wagtailapi import urls as wagtailapi_urls
from wagtail.wagtailadmin import urls as wagtailadmin_urls
from wagtail.wagtailcore import urls as wagtail_urls
from wagtail.wagtaildocs import urls as wagtaildocs_urls
from wagtail.wagtailimages import urls as wagtailimages_urls
from wagtail.wagtailimages.tests import urls as wagtailimages_test_urls
from wagtail.wagtailsearch import urls as wagtailsearch_urls

#try:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you comment those?

from wagtail.admin import urls as wagtailadmin_urls
from wagtail.core import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls
from wagtail.images import urls as wagtailimages_urls
from wagtail.images.tests import urls as wagtailimages_test_urls
from wagtail.search import urls as wagtailsearch_urls
"""
except ImportError:
#from wagtail.contrib.wagtailapi import urls as wagtailapi_urls
from wagtail.wagtailadmin import urls as wagtailadmin_urls
from wagtail.wagtailcore import urls as wagtail_urls
from wagtail.wagtaildocs import urls as wagtaildocs_urls
from wagtail.wagtailimages import urls as wagtailimages_urls
from wagtail.wagtailimages.tests import urls as wagtailimages_test_urls
from wagtail.wagtailsearch import urls as wagtailsearch_urls
"""
urlpatterns = [
url(r'^admin/', include(wagtailadmin_urls)),
url(r'^search/', include(wagtailsearch_urls)),
url(r'^documents/', include(wagtaildocs_urls)),
url(r'^testimages/', include(wagtailimages_test_urls)),
url(r'^images/', include(wagtailimages_urls)),

url(r'^api/', include(wagtailapi_urls)),
# url(r'^api/', include(wagtailapi_urls)),

url(r'', include(wagtail_urls)),
]
5 changes: 4 additions & 1 deletion wagtail_calendar/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from django.contrib.auth.models import User
from django.test import RequestFactory
from django.utils import timezone
from wagtail.wagtailcore.models import Page
try:
from wagtail.core.models import Page
except ImportError:
from wagtail.wagtailcore.models import Page


class TestEventsMixin(object):
Expand Down
11 changes: 8 additions & 3 deletions wagtail_calendar/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
from django.http import JsonResponse
from django.views.generic import TemplateView
from django.views.generic.edit import BaseUpdateView
from wagtail.wagtailadmin.edit_handlers import get_form_for_model
from wagtail.wagtailcore.hooks import get_hooks
from wagtail.wagtailcore.models import Page

try:
from wagtail.admin.edit_handlers import get_form_for_model
from wagtail.core.hooks import get_hooks
from wagtail.core.models import Page
except ImportError:
from wagtail.wagtailadmin.edit_handlers import get_form_for_model
from wagtail.wagtailcore.hooks import get_hooks
from wagtail.wagtailcore.models import Page

class PlanningCalendarView(TemplateView):
template_name = 'wagtail_calendar/planning_calendar.html'
Expand Down
25 changes: 18 additions & 7 deletions wagtail_calendar/wagtail_hooks.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
from django.conf.urls import url, include
from django.core.exceptions import ImproperlyConfigured
from django.urls import reverse
from django.utils.dateparse import parse_datetime
from django.utils.translation import ugettext_lazy as _
from wagtail.wagtailadmin.menu import MenuItem
from wagtail.wagtailcore import hooks
from wagtail.wagtailcore.models import Page, PageRevision, UserPagePermissionsProxy

try:
from wagtail.admin.menu import MenuItem
from wagtail.core import hooks
from wagtail.core.models import Page, PageRevision, UserPagePermissionsProxy
except:
from wagtail.wagtailadmin.menu import MenuItem
from wagtail.wagtailcore import hooks
from wagtail.wagtailcore.models import Page, PageRevision, UserPagePermissionsProxy

from wagtail_calendar import urls
from wagtail_calendar.utils import get_page_event_data


@hooks.register('register_admin_urls')
def register_admin_urls():
return [
url(r'^calendar/', include(urls, namespace='wagtail_calendar')),
]

try:
return [
url(r'^calendar/', include(urls, namespace='wagtail_calendar')),
]
except ImproperlyConfigured:

This comment was marked as resolved.

return [
url(r'^calendar/', include((urls,'wagtail_calendar'), namespace='wagtail_calendar')),

This comment was marked as resolved.

This comment was marked as resolved.

]

@hooks.register('register_admin_menu_item')
def register_styleguide_menu_item():
Expand Down