mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-15 18:53:18 +00:00
Merge branch 'kaedroho-dj18warnings'
This commit is contained in:
commit
306276b4d7
22 changed files with 114 additions and 70 deletions
|
|
@ -26,11 +26,11 @@ Then, in urls.py, you need to add a link to the ``wagtail.contrib.wagtailsitemap
|
|||
|
||||
from wagtail.contrib.wagtailsitemaps.views import sitemap
|
||||
|
||||
urlpatterns = patterns('',
|
||||
urlpatterns = [
|
||||
...
|
||||
|
||||
url('^sitemap\.xml$', sitemap),
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
You should now be able to browse to "/sitemap.xml" and see the sitemap working. By default, all published pages in your website will be added to the site map.
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ URL Patterns
|
|||
from wagtail.wagtaildocs import urls as wagtaildocs_urls
|
||||
from wagtail.wagtailsearch import urls as wagtailsearch_urls
|
||||
|
||||
urlpatterns = patterns('',
|
||||
urlpatterns = [
|
||||
url(r'^django-admin/', include(admin.site.urls)),
|
||||
|
||||
url(r'^admin/', include(wagtailadmin_urls)),
|
||||
|
|
@ -275,7 +275,7 @@ URL Patterns
|
|||
# For anything not caught by a more specific rule above, hand over to
|
||||
# Wagtail's serving mechanism
|
||||
url(r'', include(wagtail_urls)),
|
||||
)
|
||||
]
|
||||
|
||||
This block of code for your project's ``urls.py`` does a few things:
|
||||
|
||||
|
|
|
|||
|
|
@ -17,13 +17,11 @@ Add an entry in your URLs configuration for ``wagtail.wagtailimages.urls``:
|
|||
from wagtail.wagtailimages import urls as wagtailimages_urls
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
urlpatterns = [
|
||||
...
|
||||
|
||||
url(r'^images/', include(wagtailimages_urls)),
|
||||
|
||||
...
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
Generating URLs for images
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ def get_api_data(obj, fields):
|
|||
|
||||
# Check django fields
|
||||
try:
|
||||
field = obj._meta.get_field_by_name(field_name)[0]
|
||||
field = obj._meta.get_field(field_name)
|
||||
|
||||
if field.rel and isinstance(field.rel, models.ManyToOneRel):
|
||||
# Foreign key
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import os
|
||||
|
||||
from django.conf.urls import patterns, include, url
|
||||
from django.conf.urls import include, url
|
||||
from django.conf.urls.static import static
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
|
|
@ -11,7 +11,7 @@ from wagtail.wagtaildocs import urls as wagtaildocs_urls
|
|||
from wagtail.wagtailcore import urls as wagtail_urls
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
urlpatterns = [
|
||||
url(r'^django-admin/', include(admin.site.urls)),
|
||||
|
||||
url(r'^admin/', include(wagtailadmin_urls)),
|
||||
|
|
@ -19,7 +19,7 @@ urlpatterns = patterns('',
|
|||
url(r'^documents/', include(wagtaildocs_urls)),
|
||||
|
||||
url(r'', include(wagtail_urls)),
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
if settings.DEBUG:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"""An alternative urlconf module where Wagtail front-end URLs
|
||||
are rooted at '/site/' rather than '/'"""
|
||||
|
||||
from django.conf.urls import patterns, include, url
|
||||
from django.conf.urls import include, url
|
||||
|
||||
from wagtail.wagtailcore import urls as wagtail_urls
|
||||
from wagtail.wagtailadmin import urls as wagtailadmin_urls
|
||||
|
|
@ -10,10 +10,10 @@ from wagtail.wagtailimages import urls as wagtailimages_urls
|
|||
from wagtail.wagtailsearch import urls as wagtailsearch_urls
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
urlpatterns = [
|
||||
url(r'^admin/', include(wagtailadmin_urls)),
|
||||
url(r'^search/', include(wagtailsearch_urls)),
|
||||
url(r'^documents/', include(wagtaildocs_urls)),
|
||||
url(r'^images/', include(wagtailimages_urls)),
|
||||
url(r'^site/', include(wagtail_urls)),
|
||||
)
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
|
||||
import django
|
||||
from django.conf import global_settings
|
||||
|
||||
|
||||
|
|
@ -34,9 +35,27 @@ STATICFILES_FINDERS = (
|
|||
|
||||
USE_TZ = True
|
||||
|
||||
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
|
||||
'django.core.context_processors.request',
|
||||
)
|
||||
if django.VERSION >= (1, 8):
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'django.template.context_processors.request',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
else:
|
||||
TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
|
||||
'django.core.context_processors.request',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from django.conf.urls import patterns, include, url
|
||||
from django.conf.urls import include, url
|
||||
|
||||
from wagtail.wagtailcore import urls as wagtail_urls
|
||||
from wagtail.wagtailadmin import urls as wagtailadmin_urls
|
||||
|
|
@ -9,7 +9,7 @@ from wagtail.contrib.wagtailsitemaps.views import sitemap
|
|||
from wagtail.contrib.wagtailapi import urls as wagtailapi_urls
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
urlpatterns = [
|
||||
url(r'^admin/', include(wagtailadmin_urls)),
|
||||
url(r'^search/', include(wagtailsearch_urls)),
|
||||
url(r'^documents/', include(wagtaildocs_urls)),
|
||||
|
|
@ -21,4 +21,4 @@ urlpatterns = patterns('',
|
|||
# For anything not caught by a more specific rule above, hand over to
|
||||
# Wagtail's serving mechanism
|
||||
url(r'', include(wagtail_urls)),
|
||||
)
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import django
|
||||
from django.template import loader
|
||||
|
||||
|
||||
def get_related_model(rel):
|
||||
|
|
@ -9,3 +10,22 @@ def get_related_model(rel):
|
|||
return rel.related_model
|
||||
else:
|
||||
return rel.model
|
||||
|
||||
|
||||
def render_to_string(template_name, context=None, request=None, **kwargs):
|
||||
if django.VERSION >= (1, 8):
|
||||
return loader.render_to_string(
|
||||
template_name,
|
||||
context=context,
|
||||
request=request,
|
||||
**kwargs
|
||||
)
|
||||
else:
|
||||
# Backwards compatibility for Django 1.7 and below
|
||||
from django.template.context import RequestContext
|
||||
return loader.render_to_string(
|
||||
template_name,
|
||||
dictionary=context,
|
||||
context_instance=RequestContext(request),
|
||||
**kwargs
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import django
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
|
|
@ -11,11 +12,18 @@ def create_admin_access_permissions(apps, schema_editor):
|
|||
|
||||
# Add a fake content type to hang the 'can access Wagtail admin' permission off.
|
||||
# The fact that this doesn't correspond to an actual defined model shouldn't matter, I hope...
|
||||
wagtailadmin_content_type = ContentType.objects.create(
|
||||
app_label='wagtailadmin',
|
||||
model='admin',
|
||||
name='Wagtail admin'
|
||||
)
|
||||
if django.VERSION >= (1, 8):
|
||||
wagtailadmin_content_type = ContentType.objects.create(
|
||||
app_label='wagtailadmin',
|
||||
model='admin'
|
||||
)
|
||||
else:
|
||||
# Django 1.7 and below require a content type name
|
||||
wagtailadmin_content_type = ContentType.objects.create(
|
||||
app_label='wagtailadmin',
|
||||
model='admin',
|
||||
name='Wagtail admin'
|
||||
)
|
||||
|
||||
# Create admin permission
|
||||
admin_permission = Permission.objects.create(
|
||||
|
|
|
|||
|
|
@ -1,24 +1,23 @@
|
|||
import json
|
||||
|
||||
from django.http import HttpResponse
|
||||
from django.template import RequestContext
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
from wagtail.utils.compat import render_to_string
|
||||
|
||||
|
||||
def render_modal_workflow(request, html_template, js_template, template_vars={}):
|
||||
def render_modal_workflow(request, html_template, js_template, template_vars=None):
|
||||
""""
|
||||
Render a response consisting of an HTML chunk and a JS onload chunk
|
||||
in the format required by the modal-workflow framework.
|
||||
"""
|
||||
response_keyvars = []
|
||||
context = RequestContext(request)
|
||||
|
||||
if html_template:
|
||||
html = render_to_string(html_template, template_vars, context)
|
||||
html = render_to_string(html_template, template_vars or {}, request=request)
|
||||
response_keyvars.append("'html': %s" % json.dumps(html))
|
||||
|
||||
if js_template:
|
||||
js = render_to_string(js_template, template_vars, context)
|
||||
js = render_to_string(js_template, template_vars or {}, request=request)
|
||||
response_keyvars.append("'onload': %s" % js)
|
||||
|
||||
response_text = "{%s}" % ','.join(response_keyvars)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
from django.template import RequestContext
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
from wagtail.wagtailcore import hooks
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail.utils.compat import render_to_string
|
||||
|
||||
|
||||
class SummaryItem(object):
|
||||
|
|
@ -15,8 +13,7 @@ class SummaryItem(object):
|
|||
return {}
|
||||
|
||||
def render(self):
|
||||
return render_to_string(self.template, self.get_context(),
|
||||
RequestContext(self.request))
|
||||
return render_to_string(self.template, self.get_context(), request=self.request)
|
||||
|
||||
|
||||
class PagesSummaryItem(SummaryItem):
|
||||
|
|
@ -46,4 +43,4 @@ class SiteSummaryPanel(object):
|
|||
def render(self):
|
||||
return render_to_string('wagtailadmin/home/site_summary.html', {
|
||||
'summary_items': sorted(self.summary_items, key=lambda p: p.order),
|
||||
}, RequestContext(self.request))
|
||||
}, request=self.request)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
from django.conf.urls import url
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
from django.contrib.auth import views as django_auth_views
|
||||
from django.views.decorators.cache import cache_control
|
||||
|
||||
from wagtail.wagtailadmin.forms import PasswordResetForm
|
||||
|
|
@ -92,7 +93,7 @@ urlpatterns += [
|
|||
|
||||
# Password reset
|
||||
url(
|
||||
r'^password_reset/$', 'django.contrib.auth.views.password_reset', {
|
||||
r'^password_reset/$', django_auth_views.password_reset, {
|
||||
'template_name': 'wagtailadmin/account/password_reset/form.html',
|
||||
'email_template_name': 'wagtailadmin/account/password_reset/email.txt',
|
||||
'subject_template_name': 'wagtailadmin/account/password_reset/email_subject.txt',
|
||||
|
|
@ -101,19 +102,19 @@ urlpatterns += [
|
|||
}, name='wagtailadmin_password_reset'
|
||||
),
|
||||
url(
|
||||
r'^password_reset/done/$', 'django.contrib.auth.views.password_reset_done', {
|
||||
r'^password_reset/done/$', django_auth_views.password_reset_done, {
|
||||
'template_name': 'wagtailadmin/account/password_reset/done.html'
|
||||
}, name='wagtailadmin_password_reset_done'
|
||||
),
|
||||
url(
|
||||
r'^password_reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
|
||||
'django.contrib.auth.views.password_reset_confirm', {
|
||||
django_auth_views.password_reset_confirm, {
|
||||
'template_name': 'wagtailadmin/account/password_reset/confirm.html',
|
||||
'post_reset_redirect': 'wagtailadmin_password_reset_complete',
|
||||
}, name='wagtailadmin_password_reset_confirm',
|
||||
),
|
||||
url(
|
||||
r'^password_reset/complete/$', 'django.contrib.auth.views.password_reset_complete', {
|
||||
r'^password_reset/complete/$', django_auth_views.password_reset_complete, {
|
||||
'template_name': 'wagtailadmin/account/password_reset/complete.html'
|
||||
}, name='wagtailadmin_password_reset_complete'
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
from django.template import RequestContext
|
||||
from django.template.loader import render_to_string
|
||||
from wagtail.utils.compat import render_to_string
|
||||
|
||||
|
||||
class BaseItem(object):
|
||||
template = 'wagtailadmin/userbar/item_base.html'
|
||||
|
||||
def render(self, request):
|
||||
return render_to_string(self.template, dict(self=self, request=request), context_instance=RequestContext(request))
|
||||
return render_to_string(self.template, dict(self=self, request=request), request=request)
|
||||
|
||||
|
||||
class AddPageItem(BaseItem):
|
||||
template = 'wagtailadmin/userbar/item_page_add.html'
|
||||
|
|
@ -30,6 +31,7 @@ class AddPageItem(BaseItem):
|
|||
|
||||
return super(AddPageItem, self).render(request)
|
||||
|
||||
|
||||
class EditPageItem(BaseItem):
|
||||
template = 'wagtailadmin/userbar/item_page_edit.html'
|
||||
|
||||
|
|
@ -52,8 +54,8 @@ class EditPageItem(BaseItem):
|
|||
|
||||
return super(EditPageItem, self).render(request)
|
||||
|
||||
class ModeratePageItem(BaseItem):
|
||||
|
||||
class ModeratePageItem(BaseItem):
|
||||
def __init__(self, revision):
|
||||
self.revision = revision
|
||||
|
||||
|
|
@ -72,8 +74,10 @@ class ModeratePageItem(BaseItem):
|
|||
|
||||
return super(ModeratePageItem, self).render(request)
|
||||
|
||||
|
||||
class ApproveModerationEditPageItem(ModeratePageItem):
|
||||
template = 'wagtailadmin/userbar/item_page_approve.html'
|
||||
|
||||
|
||||
class RejectModerationEditPageItem(ModeratePageItem):
|
||||
template = 'wagtailadmin/userbar/item_page_reject.html'
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
from django.shortcuts import render
|
||||
from django.conf import settings
|
||||
from django.template import RequestContext
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
from wagtail.wagtailcore import hooks
|
||||
from wagtail.wagtailcore.models import PageRevision, UserPagePermissionsProxy
|
||||
from wagtail.utils.compat import render_to_string
|
||||
|
||||
from wagtail.wagtailadmin.site_summary import SiteSummaryPanel
|
||||
|
||||
|
|
@ -22,7 +21,7 @@ class PagesForModerationPanel(object):
|
|||
def render(self):
|
||||
return render_to_string('wagtailadmin/home/pages_for_moderation.html', {
|
||||
'page_revisions_for_moderation': self.page_revisions_for_moderation,
|
||||
}, RequestContext(self.request))
|
||||
}, request=self.request)
|
||||
|
||||
|
||||
class RecentEditsPanel(object):
|
||||
|
|
@ -43,7 +42,7 @@ class RecentEditsPanel(object):
|
|||
def render(self):
|
||||
return render_to_string('wagtailadmin/home/recent_edits.html', {
|
||||
'last_edits': self.last_edits,
|
||||
}, RequestContext(self.request))
|
||||
}, request=self.request)
|
||||
|
||||
|
||||
def home(request):
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
from django.conf.urls import patterns, url
|
||||
from django.conf.urls import url
|
||||
|
||||
from wagtail.wagtailforms import views
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'wagtail.wagtailforms.views',
|
||||
url(r'^$', 'index', name='wagtailforms_index'),
|
||||
url(r'^submissions/(\d+)/$', 'list_submissions', name='wagtailforms_list_submissions'),
|
||||
|
||||
)
|
||||
urlpatterns = [
|
||||
url(r'^$', views.index, name='wagtailforms_index'),
|
||||
url(r'^submissions/(\d+)/$', views.list_submissions, name='wagtailforms_list_submissions'),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ from django.views.decorators.http import require_POST
|
|||
from django.core.exceptions import PermissionDenied
|
||||
from django.views.decorators.vary import vary_on_headers
|
||||
from django.http import HttpResponse, HttpResponseBadRequest
|
||||
from django.template import RequestContext
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
from wagtail.wagtailsearch.backends import get_search_backends
|
||||
|
|
@ -21,6 +19,7 @@ from wagtail.wagtailimages.fields import (
|
|||
ALLOWED_EXTENSIONS,
|
||||
FILE_TOO_LARGE_ERROR,
|
||||
)
|
||||
from wagtail.utils.compat import render_to_string
|
||||
|
||||
|
||||
def json_response(document):
|
||||
|
|
@ -78,7 +77,7 @@ def add(request):
|
|||
'form': render_to_string('wagtailimages/multiple/edit_form.html', {
|
||||
'image': image,
|
||||
'form': get_image_edit_form(Image)(instance=image, prefix='image-%d' % image.id),
|
||||
}, context_instance=RequestContext(request)),
|
||||
}, request=request),
|
||||
})
|
||||
else:
|
||||
# Validation error
|
||||
|
|
@ -131,7 +130,7 @@ def edit(request, image_id, callback=None):
|
|||
'form': render_to_string('wagtailimages/multiple/edit_form.html', {
|
||||
'image': image,
|
||||
'form': form,
|
||||
}, context_instance=RequestContext(request)),
|
||||
}, request=request),
|
||||
})
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@
|
|||
{{ redirect.link }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="type"><div class="status-tag {% if redirect.get_is_permanent_display = "permanent" %}{% trans "primary" %}{% endif %}">{{ redirect.get_is_permanent_display }}</div></td>
|
||||
<td class="type"><div class="status-tag {% if redirect.get_is_permanent_display == "permanent" %}{% trans "primary" %}{% endif %}">{{ redirect.get_is_permanent_display }}</div></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
{% else %}
|
||||
{% if query_string %}
|
||||
<p>{% blocktrans %}Sorry, no redirects match "<em>{{ query_string }}</em>"{% endblocktrans %}
|
||||
{% else %}
|
||||
{% else %}
|
||||
{% url 'wagtailredirects_add_redirect' as wagtailredirects_add_redirect_url %}
|
||||
<p>{% blocktrans %}No redirects have been created. Why not <a href="{{ wagtailredirects_add_redirect_url }}">add one</a>?{% endblocktrans %}</p>
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ class DBSearchQuery(BaseSearchQuery):
|
|||
for field_name in fields:
|
||||
# Check if the field exists (this will filter out indexed callables)
|
||||
try:
|
||||
model._meta.get_field_by_name(field_name)
|
||||
except:
|
||||
model._meta.get_field(field_name)
|
||||
except models.fields.FieldDoesNotExist:
|
||||
continue
|
||||
|
||||
# Filter on this field
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class BaseField(object):
|
|||
self.kwargs = kwargs
|
||||
|
||||
def get_field(self, cls):
|
||||
return cls._meta.get_field_by_name(self.field_name)[0]
|
||||
return cls._meta.get_field(self.field_name)
|
||||
|
||||
def get_attname(self, cls):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
from django.core.management.base import NoArgsCommand
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from wagtail.wagtailsearch import models
|
||||
|
||||
|
||||
class Command(NoArgsCommand):
|
||||
def handle_noargs(self, **options):
|
||||
class Command(BaseCommand):
|
||||
def handle(self, **options):
|
||||
# Clean daily hits
|
||||
self.stdout.write("Cleaning daily hits records... ")
|
||||
models.QueryDailyHits.garbage_collect()
|
||||
|
|
|
|||
Loading…
Reference in a new issue