kopia lustrzana https://github.com/wagtail/wagtail
Merge branch 'flake8' of https://github.com/kaedroho/wagtail into kaedroho-flake8
Conflicts: wagtail/wagtailadmin/views/account.pypull/1137/merge
commit
43d1261c2f
|
@ -21,6 +21,7 @@ matrix:
|
|||
- env: TOXENV=py34-dj18-postgres
|
||||
- env: TOXENV=py34-dj18-sqlite
|
||||
- env: TOXENV=py34-dj18-mysql
|
||||
- env: TOXENV=flake8
|
||||
|
||||
# Services
|
||||
services:
|
||||
|
|
10
tox.ini
10
tox.ini
|
@ -2,8 +2,11 @@
|
|||
skipsdist = True
|
||||
usedevelop = True
|
||||
|
||||
envlist = py{27,33,34}-dj{17,18}-{sqlite,postgres,mysql}
|
||||
envlist = py{27,33,34}-dj{17,18}-{sqlite,postgres,mysql}, flake8
|
||||
|
||||
[flake8]
|
||||
ignore = E501,E128,E261,E302,E303,E124,E126
|
||||
exclude = wagtail/project_template/*
|
||||
|
||||
[testenv]
|
||||
commands=coverage run runtests.py
|
||||
|
@ -47,3 +50,8 @@ setenv =
|
|||
mysql: DATABASE_USER=wagtail
|
||||
mysql: DATABASE_HOST=localhost
|
||||
mysql: DATABASE_USER=root
|
||||
|
||||
[testenv:flake8]
|
||||
basepython=python3.4
|
||||
deps=flake8>=2.2.0
|
||||
commands=flake8 wagtail
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import urllib
|
||||
from collections import OrderedDict
|
||||
|
||||
from modelcluster.models import get_all_child_relations
|
||||
|
@ -8,9 +7,7 @@ from taggit.managers import _TaggableManager
|
|||
|
||||
from django.db import models
|
||||
from django.utils.encoding import force_text
|
||||
from django.http import Http404
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.core.paginator import Paginator, EmptyPage
|
||||
from django.conf.urls import url
|
||||
from django.conf import settings
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from django.core.urlresolvers import reverse
|
||||
from django.db.models.signals import post_save, post_delete
|
||||
from django.conf import settings
|
||||
|
||||
from wagtail.wagtailcore.signals import page_published, page_unpublished
|
||||
from wagtail.wagtailcore.models import PAGE_MODEL_CLASSES
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
import json
|
||||
import unittest
|
||||
import mock
|
||||
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.conf import settings
|
||||
|
||||
from wagtail.wagtaildocs.models import Document
|
||||
|
||||
from wagtail.contrib.wagtailapi import signal_handlers
|
||||
|
||||
from wagtail.tests.demosite import models
|
||||
|
||||
|
||||
class TestDocumentListing(TestCase):
|
||||
fixtures = ['demosite.json']
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
import json
|
||||
import unittest
|
||||
import mock
|
||||
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.conf import settings
|
||||
|
||||
from wagtail.wagtailimages.models import get_image_model
|
||||
|
||||
from wagtail.contrib.wagtailapi import signal_handlers
|
||||
|
||||
from wagtail.tests.demosite import models
|
||||
|
||||
|
||||
class TestImageListing(TestCase):
|
||||
fixtures = ['demosite.json']
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import json
|
||||
import unittest
|
||||
import mock
|
||||
import collections
|
||||
|
||||
from django.test import TestCase
|
||||
from django.test.utils import override_settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.conf import settings
|
||||
|
||||
from wagtail.wagtailcore.models import Page
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import logging
|
||||
|
||||
from django.utils import six
|
||||
from django.conf import settings
|
||||
from django.utils.module_loading import import_string
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
@ -55,7 +54,7 @@ def get_backends(backend_settings=None, backends=None):
|
|||
return backend_objects
|
||||
|
||||
|
||||
def purge_url_from_cache(url, backend_settings=None, backends=None):
|
||||
def purge_url_from_cache(url, backend_settings=None, backends=None):
|
||||
for backend_name, backend in get_backends(backend_settings=backend_settings, backends=backends).items():
|
||||
logger.info("[%s] Purging URL: %s", backend_name, url)
|
||||
backend.purge(url)
|
||||
|
|
|
@ -49,7 +49,7 @@ class TestSitemapGenerator(TestCase):
|
|||
|
||||
def test_get_urls_uses_specific(self):
|
||||
# Add an event page which has an extra url in the sitemap
|
||||
events_page = self.home_page.add_child(instance=EventIndex(
|
||||
self.home_page.add_child(instance=EventIndex(
|
||||
title="Events",
|
||||
slug='events',
|
||||
live=True,
|
||||
|
@ -87,7 +87,7 @@ class TestSitemapView(TestCase):
|
|||
cache_key = 'wagtail-sitemap:%d' % Site.objects.get(is_default_site=True).id
|
||||
|
||||
# Check that the key is not in the cache
|
||||
self.assertFalse(cache.has_key(cache_key))
|
||||
self.assertNotIn(cache_key, cache)
|
||||
|
||||
# Hit the view
|
||||
first_response = self.client.get('/sitemap.xml')
|
||||
|
@ -96,7 +96,7 @@ class TestSitemapView(TestCase):
|
|||
self.assertTemplateUsed(first_response, 'wagtailsitemaps/sitemap.xml')
|
||||
|
||||
# Check that the key is in the cache
|
||||
self.assertTrue(cache.has_key(cache_key))
|
||||
self.assertIn(cache_key, cache)
|
||||
|
||||
# Hit the view again. Should come from the cache this time
|
||||
second_response = self.client.get('/sitemap.xml')
|
||||
|
|
|
@ -6,7 +6,7 @@ from wagtail.tests.utils import WagtailTestUtils
|
|||
|
||||
class TestStyleGuide(TestCase, WagtailTestUtils):
|
||||
def setUp(self):
|
||||
self.login();
|
||||
self.login()
|
||||
|
||||
def test_styleguide(self):
|
||||
response = self.client.get(reverse('wagtailstyleguide'))
|
||||
|
|
|
@ -10,7 +10,6 @@ from wagtail.wagtailimages.widgets import AdminImageChooser
|
|||
from wagtail.wagtaildocs.widgets import AdminDocumentChooser
|
||||
|
||||
class ExampleForm(forms.Form):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ExampleForm, self).__init__(*args, **kwargs)
|
||||
self.fields['page_chooser'].widget = AdminPageChooser()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def create_homepage(apps, schema_editor):
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from datetime import date
|
||||
|
||||
from django.db import models
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
|
||||
from modelcluster.fields import ParentalKey
|
||||
from modelcluster.tags import ClusterTaggableManager
|
||||
from taggit.models import Tag, TaggedItemBase
|
||||
from taggit.models import TaggedItemBase
|
||||
|
||||
from wagtail.wagtailcore.models import Page, Orderable
|
||||
from wagtail.wagtailcore.fields import RichTextField
|
||||
|
@ -11,8 +13,6 @@ from wagtail.wagtailadmin.edit_handlers import FieldPanel, MultiFieldPanel, \
|
|||
InlinePanel, PageChooserPanel
|
||||
from wagtail.wagtailimages.edit_handlers import ImageChooserPanel
|
||||
from wagtail.wagtaildocs.edit_handlers import DocumentChooserPanel
|
||||
from wagtail.wagtailsnippets.models import register_snippet
|
||||
from wagtail.wagtailforms.models import AbstractEmailForm, AbstractFormField
|
||||
from wagtail.wagtailsearch import index
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from django.db import models
|
||||
from django.http import HttpResponse
|
||||
from django.conf.urls import url
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ DATABASES = {
|
|||
|
||||
SECRET_KEY = 'not needed'
|
||||
|
||||
ROOT_URLCONF='wagtail.tests.urls'
|
||||
ROOT_URLCONF = 'wagtail.tests.urls'
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = STATIC_ROOT
|
||||
|
@ -121,7 +121,7 @@ AUTH_USER_MODEL = 'customuser.CustomUser'
|
|||
|
||||
try:
|
||||
# Only add Elasticsearch backend if the elasticsearch-py library is installed
|
||||
import elasticsearch
|
||||
import elasticsearch # noqa
|
||||
|
||||
# Import succeeded, add an Elasticsearch backend
|
||||
WAGTAILSEARCH_BACKENDS['elasticsearch'] = {
|
||||
|
|
|
@ -36,4 +36,3 @@ register_snippet(RegisterFunction)
|
|||
@register_snippet
|
||||
class RegisterDecorator(models.Model):
|
||||
pass
|
||||
|
||||
|
|
|
@ -2,4 +2,4 @@ import warnings
|
|||
|
||||
warnings.warn("wagtail.wagtailadmin.blocks has moved to wagtail.wagtailcore.blocks", UserWarning, stacklevel=2)
|
||||
|
||||
from wagtail.wagtailcore.blocks import *
|
||||
from wagtail.wagtailcore.blocks import * # noqa
|
||||
|
|
|
@ -724,13 +724,12 @@ Page.settings_panels = [
|
|||
|
||||
|
||||
class BaseStreamFieldPanel(BaseFieldPanel):
|
||||
|
||||
def classes(self):
|
||||
classes = super(BaseStreamFieldPanel, self).classes()
|
||||
classes.append("stream-field")
|
||||
|
||||
|
||||
# BaseFieldPanel is essentially for single fields, which are rendered on the front end
|
||||
# with the assumption that the label (singular) will always be promoted to the full-width
|
||||
# with the assumption that the label (singular) will always be promoted to the full-width
|
||||
# divider bar thing.
|
||||
# This results in all the other labels being promoted similarly, so it's better not to
|
||||
# treat this as a single field, and remove the "single-field" class.
|
||||
|
|
|
@ -63,7 +63,7 @@ class EmailLinkChooserWithLinkTextForm(forms.Form):
|
|||
class LoginForm(AuthenticationForm):
|
||||
username = forms.CharField(
|
||||
max_length=254,
|
||||
widget=forms.TextInput(attrs={'tabindex': '1',}),
|
||||
widget=forms.TextInput(attrs={'tabindex': '1'}),
|
||||
)
|
||||
password = forms.CharField(
|
||||
widget=forms.PasswordInput(attrs={'placeholder': ugettext_lazy("Enter password"),
|
||||
|
@ -133,7 +133,7 @@ class CopyForm(forms.Form):
|
|||
help_text=ungettext(
|
||||
"This will copy %(count)s subpage.",
|
||||
"This will copy %(count)s subpages.",
|
||||
subpage_count) % {'count': subpage_count})
|
||||
subpage_count) % {'count': subpage_count})
|
||||
|
||||
if can_publish:
|
||||
pages_to_publish_count = pages_to_copy.live().count()
|
||||
|
@ -147,7 +147,7 @@ class CopyForm(forms.Form):
|
|||
help_text = ungettext(
|
||||
"%(count)s of the pages being copied is live. Would you like to publish its copy?",
|
||||
"%(count)s of the pages being copied are live. Would you like to publish their copies?",
|
||||
pages_to_publish_count) % {'count': pages_to_publish_count}
|
||||
pages_to_publish_count) % {'count': pages_to_publish_count}
|
||||
|
||||
self.fields['publish_copies'] = forms.BooleanField(
|
||||
required=False, initial=True, label=label, help_text=help_text
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def create_admin_access_permissions(apps, schema_editor):
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
### gravatar.py ###############
|
||||
### place inside a 'templatetags' directory inside the top level of a Django app (not project, must be inside an app)
|
||||
### at the top of your page template include this:
|
||||
### {% load gravatar %}
|
||||
### and to use the url do this:
|
||||
### <img src="{% gravatar_url 'someone@somewhere.com' %}">
|
||||
### or
|
||||
### <img src="{% gravatar_url sometemplatevariable %}">
|
||||
### just make sure to update the "default" image path below
|
||||
# place inside a 'templatetags' directory inside the top level of a Django app (not project, must be inside an app)
|
||||
# at the top of your page template include this:
|
||||
# {% load gravatar %}
|
||||
# and to use the url do this:
|
||||
# <img src="{% gravatar_url 'someone@somewhere.com' %}">
|
||||
# or
|
||||
# <img src="{% gravatar_url sometemplatevariable %}">
|
||||
# just make sure to update the "default" image path below
|
||||
|
||||
import hashlib
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ def main_nav_js():
|
|||
def ellipsistrim(value, max_length):
|
||||
if len(value) > max_length:
|
||||
truncd_val = value[:max_length]
|
||||
if not len(value) == max_length+1 and value[max_length+1] != " ":
|
||||
if not len(value) == (max_length + 1) and value[max_length + 1] != " ":
|
||||
truncd_val = truncd_val[:truncd_val.rfind(" ")]
|
||||
return truncd_val + "..."
|
||||
return value
|
||||
|
@ -70,7 +70,7 @@ def widgettype(bound_field):
|
|||
except AttributeError:
|
||||
try:
|
||||
return camelcase_to_underscore(bound_field.widget.__class__.__name__)
|
||||
except AttributeError:
|
||||
except AttributeError:
|
||||
return ""
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import warnings
|
||||
|
||||
from django import template
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
|
@ -13,7 +11,7 @@ register = template.Library()
|
|||
def wagtailuserbar(context):
|
||||
# Find request object
|
||||
request = context['request']
|
||||
|
||||
|
||||
# Don't render if user doesn't have permission to access the admin area
|
||||
if not request.user.has_perm('wagtailadmin.access_admin'):
|
||||
return ''
|
||||
|
|
|
@ -32,7 +32,7 @@ class TestAuthentication(TestCase, WagtailTestUtils):
|
|||
the user was logged in successfully
|
||||
"""
|
||||
# Create user to log in with
|
||||
user = get_user_model().objects.create_superuser(username='test', email='test@email.com', password='password')
|
||||
get_user_model().objects.create_superuser(username='test', email='test@email.com', password='password')
|
||||
|
||||
# Post credentials to the login page
|
||||
response = self.client.post(reverse('wagtailadmin_login'), {
|
||||
|
|
|
@ -109,7 +109,6 @@ class TestExtractPanelDefinitionsFromModelClass(TestCase):
|
|||
# A class with a 'panels' property defined should return that list
|
||||
result = extract_panel_definitions_from_model_class(EventPageSpeaker)
|
||||
self.assertEqual(len(result), 4)
|
||||
#print repr(result)
|
||||
self.assertTrue(any([isinstance(panel, ImageChooserPanel) for panel in result]))
|
||||
|
||||
def test_exclude(self):
|
||||
|
@ -260,7 +259,7 @@ class TestObjectList(TestCase):
|
|||
|
||||
class TestFieldPanel(TestCase):
|
||||
def setUp(self):
|
||||
self.EventPageForm = get_form_for_model(EventPage, formsets = [])
|
||||
self.EventPageForm = get_form_for_model(EventPage, formsets=[])
|
||||
self.event = EventPage(title='Abergavenny sheepdog trials',
|
||||
date_from=date(2014, 7, 20), date_to=date(2014, 7, 21))
|
||||
|
||||
|
@ -357,8 +356,7 @@ class TestPageChooserPanel(TestCase):
|
|||
self.test_instance = model.objects.create(page=self.christmas_page)
|
||||
|
||||
self.form = self.PageChooserForm(instance=self.test_instance)
|
||||
self.page_chooser_panel = self.MyPageChooserPanel(instance=self.test_instance,
|
||||
form=self.form)
|
||||
self.page_chooser_panel = self.MyPageChooserPanel(instance=self.test_instance, form=self.form)
|
||||
|
||||
def test_page_chooser_uses_correct_widget(self):
|
||||
self.assertEqual(type(self.form.fields['page'].widget), AdminPageChooser)
|
||||
|
@ -386,8 +384,7 @@ class TestPageChooserPanel(TestCase):
|
|||
form = self.PageChooserForm({'page': ''}, instance=self.test_instance)
|
||||
self.assertFalse(form.is_valid())
|
||||
|
||||
page_chooser_panel = self.MyPageChooserPanel(instance=self.test_instance,
|
||||
form=form)
|
||||
page_chooser_panel = self.MyPageChooserPanel(instance=self.test_instance, form=form)
|
||||
self.assertIn('<span>This field is required.</span>', page_chooser_panel.render_as_field())
|
||||
|
||||
def test_override_page_type(self):
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from datetime import timedelta
|
||||
import unittest
|
||||
import mock
|
||||
|
||||
from django.test import TestCase
|
||||
|
@ -340,7 +339,7 @@ class TestPageCreation(TestCase, WagtailTestUtils):
|
|||
|
||||
def test_create_simplepage_post_submit(self):
|
||||
# Create a moderator user for testing email
|
||||
moderator = get_user_model().objects.create_superuser('moderator', 'moderator@email.com', 'password')
|
||||
get_user_model().objects.create_superuser('moderator', 'moderator@email.com', 'password')
|
||||
|
||||
# Submit
|
||||
post_data = {
|
||||
|
@ -694,7 +693,7 @@ class TestPageEdit(TestCase, WagtailTestUtils):
|
|||
|
||||
def test_page_edit_post_submit(self):
|
||||
# Create a moderator user for testing email
|
||||
moderator = get_user_model().objects.create_superuser('moderator', 'moderator@email.com', 'password')
|
||||
get_user_model().objects.create_superuser('moderator', 'moderator@email.com', 'password')
|
||||
|
||||
# Tests submitting from edit page
|
||||
post_data = {
|
||||
|
@ -965,18 +964,20 @@ class TestPageDelete(TestCase, WagtailTestUtils):
|
|||
def test_subpage_deletion(self):
|
||||
# Connect mock signal handlers to page_unpublished, pre_delete and post_delete signals
|
||||
unpublish_signals_received = []
|
||||
pre_delete_signals_received = []
|
||||
post_delete_signals_received = []
|
||||
|
||||
def page_unpublished_handler(sender, instance, **kwargs):
|
||||
unpublish_signals_received.append((sender, instance.id))
|
||||
page_unpublished.connect(page_unpublished_handler)
|
||||
|
||||
pre_delete_signals_received = []
|
||||
def pre_delete_handler(sender, instance, **kwargs):
|
||||
pre_delete_signals_received.append((sender, instance.id))
|
||||
pre_delete.connect(pre_delete_handler)
|
||||
|
||||
post_delete_signals_received = []
|
||||
def post_delete_handler(sender, instance, **kwargs):
|
||||
post_delete_signals_received.append((sender, instance.id))
|
||||
|
||||
page_unpublished.connect(page_unpublished_handler)
|
||||
pre_delete.connect(pre_delete_handler)
|
||||
post_delete.connect(post_delete_handler)
|
||||
|
||||
# Post
|
||||
|
@ -1951,7 +1952,7 @@ class TestLocking(TestCase, WagtailTestUtils):
|
|||
# Check that the page is locked
|
||||
self.assertTrue(Page.objects.get(id=self.child_page.id).locked)
|
||||
|
||||
def test_unlock_post_with_bad_redirect(self):
|
||||
def test_lock_post_with_bad_redirect(self):
|
||||
response = self.client.post(reverse('wagtailadmin_pages_lock', args=(self.child_page.id, )), {
|
||||
'next': 'http://www.google.co.uk'
|
||||
})
|
||||
|
@ -1960,7 +1961,7 @@ class TestLocking(TestCase, WagtailTestUtils):
|
|||
self.assertRedirects(response, reverse('wagtailadmin_explore', args=(self.root_page.id, )))
|
||||
|
||||
# Check that the page is locked
|
||||
self.assertTrue(page.objects.get(id=self.child_page.id).locked)
|
||||
self.assertTrue(Page.objects.get(id=self.child_page.id).locked)
|
||||
|
||||
def test_lock_post_bad_page(self):
|
||||
response = self.client.post(reverse('wagtailadmin_pages_lock', args=(9999, )))
|
||||
|
@ -2104,7 +2105,7 @@ class TestIssue197(TestCase, WagtailTestUtils):
|
|||
# Add some tags and publish using edit view
|
||||
post_data = {
|
||||
'title': "Tagged page",
|
||||
'slug':'tagged-page',
|
||||
'slug': 'tagged-page',
|
||||
'tags': "hello, world",
|
||||
'action-publish': "Publish",
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ from django.test import TestCase, override_settings
|
|||
from django.core import mail
|
||||
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
from wagtail.wagtailcore.models import Site
|
||||
|
||||
|
||||
class TestUserPasswordReset(TestCase, WagtailTestUtils):
|
||||
|
|
|
@ -113,7 +113,7 @@ urlpatterns += [
|
|||
}, name='wagtailadmin_password_reset_confirm',
|
||||
),
|
||||
url(
|
||||
r'^password_reset/complete/$', 'django.contrib.auth.views.password_reset_complete',{
|
||||
r'^password_reset/complete/$', 'django.contrib.auth.views.password_reset_complete', {
|
||||
'template_name': 'wagtailadmin/account/password_reset/complete.html'
|
||||
}, name='wagtailadmin_password_reset_complete'
|
||||
),
|
||||
|
|
|
@ -44,7 +44,7 @@ class EditPageItem(BaseItem):
|
|||
# Don't render if user doesn't have permission to access the admin area
|
||||
if not request.user.has_perm('wagtailadmin.access_admin'):
|
||||
return ""
|
||||
|
||||
|
||||
# Don't render if the user doesn't have permission to edit this page
|
||||
permission_checker = self.page.permissions_for_user(request.user)
|
||||
if not permission_checker.can_edit():
|
||||
|
@ -69,7 +69,7 @@ class ModeratePageItem(BaseItem):
|
|||
|
||||
if not self.revision.page.permissions_for_user(request.user).can_publish():
|
||||
return ""
|
||||
|
||||
|
||||
return super(ModeratePageItem, self).render(request)
|
||||
|
||||
class ApproveModerationEditPageItem(ModeratePageItem):
|
||||
|
|
|
@ -29,8 +29,8 @@ def get_object_usage(obj):
|
|||
}).values_list('id', flat=True)
|
||||
)
|
||||
else:
|
||||
# if the relation is between obj and an object that has a page as a
|
||||
# property, return the page
|
||||
# if the relation is between obj and an object that has a page as a
|
||||
# property, return the page
|
||||
for f in relation.model._meta.fields:
|
||||
if isinstance(f, ParentalKey) and issubclass(f.rel.to, Page):
|
||||
pages |= Page.objects.filter(
|
||||
|
@ -74,7 +74,7 @@ def send_mail(email_subject, email_content, email_addresses, from_email=None):
|
|||
def send_notification(page_revision_id, notification, excluded_user_id):
|
||||
# Get revision
|
||||
revision = PageRevision.objects.get(id=page_revision_id)
|
||||
|
||||
|
||||
# Get list of recipients
|
||||
if notification == 'submitted':
|
||||
# Get list of publishers
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.contrib import messages
|
|||
from django.contrib.auth.forms import SetPasswordForm
|
||||
from django.contrib.auth.views import logout as auth_logout, login as auth_login
|
||||
from django.contrib.auth import update_session_auth_hash
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views.decorators.debug import sensitive_post_parameters
|
||||
from django.views.decorators.cache import never_cache
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ from django.contrib.contenttypes.models import ContentType
|
|||
from django.shortcuts import get_object_or_404, render
|
||||
from django.http import Http404
|
||||
from django.utils.http import urlencode
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
|
||||
from wagtail.wagtailadmin.modal_workflow import render_modal_workflow
|
||||
from wagtail.wagtailadmin.forms import SearchForm, ExternalLinkChooserForm, ExternalLinkChooserWithLinkTextForm, EmailLinkChooserForm, EmailLinkChooserWithLinkTextForm
|
||||
|
|
|
@ -36,9 +36,10 @@ class RecentEditsPanel(object):
|
|||
"""
|
||||
select wp.* FROM
|
||||
wagtailcore_pagerevision wp JOIN (
|
||||
SELECT max(created_at) as max_created_at, page_id FROM wagtailcore_pagerevision group by page_id
|
||||
SELECT max(created_at) as max_created_at, page_id FROM wagtailcore_pagerevision group by page_id
|
||||
) as max_rev on max_rev.max_created_at = wp.created_at and wp.user_id = %s order by wp.created_at desc
|
||||
""", [request.user.id])[:5]
|
||||
|
||||
def render(self):
|
||||
return render_to_string('wagtailadmin/home/recent_edits.html', {
|
||||
'last_edits': self.last_edits,
|
||||
|
|
|
@ -35,7 +35,7 @@ def set_privacy(request, page_id):
|
|||
else:
|
||||
# create a new restriction object
|
||||
PageViewRestriction.objects.create(
|
||||
page=page, password = form.cleaned_data['password'])
|
||||
page=page, password=form.cleaned_data['password'])
|
||||
|
||||
return render_modal_workflow(
|
||||
request, None, 'wagtailadmin/page_privacy/set_privacy_done.js', {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import warnings
|
||||
|
||||
from django.http import Http404, HttpResponse
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.core.exceptions import ValidationError, PermissionDenied
|
||||
|
@ -794,7 +792,7 @@ def reject_moderation(request, revision_id):
|
|||
raise PermissionDenied
|
||||
|
||||
if not revision.submitted_for_moderation:
|
||||
messages.error(request, _("The page '{0}' is not currently awaiting moderation.").format( revision.page.title))
|
||||
messages.error(request, _("The page '{0}' is not currently awaiting moderation.").format(revision.page.title))
|
||||
return redirect('wagtailadmin_home')
|
||||
|
||||
if request.method == 'POST':
|
||||
|
|
|
@ -5,7 +5,6 @@ import json
|
|||
from django.core.urlresolvers import reverse
|
||||
from django.forms import widgets
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ class TextBlock(FieldBlock):
|
|||
@cached_property
|
||||
def field(self):
|
||||
from wagtail.wagtailadmin.widgets import AdminAutoHeightTextInput
|
||||
field_kwargs = {'widget': AdminAutoHeightTextInput(attrs={'rows':self.rows})}
|
||||
field_kwargs = {'widget': AdminAutoHeightTextInput(attrs={'rows': self.rows})}
|
||||
field_kwargs.update(self.field_options)
|
||||
return forms.CharField(**field_kwargs)
|
||||
|
||||
|
@ -227,7 +227,7 @@ class RawHTMLBlock(FieldBlock):
|
|||
def __init__(self, required=True, help_text=None, max_length=None, min_length=None, **kwargs):
|
||||
self.field = forms.CharField(
|
||||
required=required, help_text=help_text, max_length=max_length, min_length=min_length,
|
||||
widget = forms.Textarea)
|
||||
widget=forms.Textarea)
|
||||
super(RawHTMLBlock, self).__init__(**kwargs)
|
||||
|
||||
def render_basic(self, value):
|
||||
|
@ -239,7 +239,7 @@ class RawHTMLBlock(FieldBlock):
|
|||
|
||||
class ChooserBlock(FieldBlock):
|
||||
def __init__(self, required=True, **kwargs):
|
||||
self.required=required
|
||||
self.required = required
|
||||
super(ChooserBlock, self).__init__(**kwargs)
|
||||
|
||||
"""Abstract superclass for fields that implement a chooser interface (page, image, snippet etc)"""
|
||||
|
|
|
@ -147,8 +147,8 @@ class BaseStreamBlock(Block):
|
|||
|
||||
values_with_indexes.sort()
|
||||
return StreamValue(self, [
|
||||
(block_type_name, value)
|
||||
for (index, block_type_name, value) in values_with_indexes
|
||||
(child_block_type_name, value)
|
||||
for (index, child_block_type_name, value) in values_with_indexes
|
||||
])
|
||||
|
||||
def clean(self, value):
|
||||
|
|
|
@ -9,4 +9,4 @@ try:
|
|||
AUTH_USER_APP_LABEL, AUTH_USER_MODEL_NAME = AUTH_USER_MODEL.rsplit('.', 1)
|
||||
except ValueError:
|
||||
raise ImproperlyConfigured("AUTH_USER_MODEL must be of the form"
|
||||
" 'app_label.model_name'")
|
||||
" 'app_label.model_name'")
|
||||
|
|
|
@ -83,7 +83,7 @@ class Command(BaseCommand):
|
|||
deletion_count = len(pages_to_delete)
|
||||
pages_to_delete.delete()
|
||||
self.stdout.write(
|
||||
"%d orphaned page%s deleted." % (deletion_count, "s"[deletion_count==1:])
|
||||
"%d orphaned page%s deleted." % (deletion_count, "s" if deletion_count != 1 else "")
|
||||
)
|
||||
any_problems_fixed = True
|
||||
|
||||
|
|
|
@ -27,8 +27,9 @@ class Command(BaseCommand):
|
|||
action='store_true',
|
||||
dest='dryrun',
|
||||
default=False,
|
||||
help='Dry run -- don\'t change anything.'),
|
||||
)
|
||||
help='Dry run -- don\'t change anything.'
|
||||
),
|
||||
)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
dryrun = False
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def initial_data(apps, schema_editor):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def add_page_lock_permission_to_moderators(apps, schema_editor):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def populate_latest_revision_created_at(apps, schema_editor):
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import warnings
|
||||
import json
|
||||
|
||||
import six
|
||||
|
@ -974,6 +973,7 @@ class Page(six.with_metaclass(PageBase, MP_Node, ClusterableModel, index.Indexed
|
|||
return PageViewRestriction.objects.filter(page__in=self.get_ancestors(inclusive=True))
|
||||
|
||||
password_required_template = getattr(settings, 'PASSWORD_REQUIRED_TEMPLATE', 'wagtailcore/password_required.html')
|
||||
|
||||
def serve_password_required_response(self, request, form, action_url):
|
||||
"""
|
||||
Serve a response indicating that the user has been denied access to view this page,
|
||||
|
|
|
@ -514,8 +514,7 @@ class TestListBlock(unittest.TestCase):
|
|||
'title': "Django",
|
||||
'link': 'http://www.djangoproject.com',
|
||||
},
|
||||
]
|
||||
, prefix='links')
|
||||
], prefix='links')
|
||||
|
||||
return html
|
||||
|
||||
|
@ -743,7 +742,7 @@ class TestStreamBlock(unittest.TestCase):
|
|||
'value': 'My second paragraph',
|
||||
},
|
||||
])
|
||||
return block.render_form(value, prefix='myarticle')
|
||||
return block.render_form(value, prefix='myarticle')
|
||||
|
||||
def test_render_form_wrapper_class(self):
|
||||
html = self.render_form()
|
||||
|
|
|
@ -163,9 +163,11 @@ class TestPublishScheduledPagesCommand(TestCase):
|
|||
# Connect a mock signal handler to page_published signal
|
||||
signal_fired = [False]
|
||||
signal_page = [None]
|
||||
|
||||
def page_published_handler(sender, instance, **kwargs):
|
||||
signal_fired[0] = True
|
||||
signal_page[0] = instance
|
||||
|
||||
page_published.connect(page_published_handler)
|
||||
|
||||
|
||||
|
@ -244,11 +246,12 @@ class TestPublishScheduledPagesCommand(TestCase):
|
|||
# Connect a mock signal handler to page_unpublished signal
|
||||
signal_fired = [False]
|
||||
signal_page = [None]
|
||||
|
||||
def page_unpublished_handler(sender, instance, **kwargs):
|
||||
signal_fired[0] = True
|
||||
signal_page[0] = instance
|
||||
page_unpublished.connect(page_unpublished_handler)
|
||||
|
||||
page_unpublished.connect(page_unpublished_handler)
|
||||
|
||||
page = SimplePage(
|
||||
title="Hello world!",
|
||||
|
|
|
@ -11,7 +11,7 @@ from django.db.migrations.autodetector import MigrationAutodetector
|
|||
from django.db.migrations.state import ProjectState
|
||||
from django.db.migrations.questioner import MigrationQuestioner
|
||||
|
||||
|
||||
|
||||
class TestForMigrations(TransactionTestCase):
|
||||
def test__migrations(self):
|
||||
app_labels = set(app.label for app in apps.get_app_configs()
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import warnings
|
||||
import datetime
|
||||
import json
|
||||
|
||||
|
@ -11,7 +10,7 @@ from django.contrib.contenttypes.models import ContentType
|
|||
from django.contrib.auth import get_user_model
|
||||
|
||||
from wagtail.wagtailcore.models import Page, Site
|
||||
from wagtail.tests.testapp.models import EventPage, EventIndex, SimplePage, PageWithOldStyleRouteMethod, BusinessIndex, BusinessSubIndex, BusinessChild, StandardIndex
|
||||
from wagtail.tests.testapp.models import EventPage, EventIndex, SimplePage, BusinessIndex, BusinessSubIndex, BusinessChild, StandardIndex
|
||||
|
||||
|
||||
class TestSiteRouting(TestCase):
|
||||
|
|
|
@ -87,7 +87,6 @@ class TestPageQuerySet(TestCase):
|
|||
self.assertTrue(pages.filter(id=events_index.id).exists())
|
||||
|
||||
def test_not_descendant_of(self):
|
||||
homepage = Page.objects.get(url_path='/home/')
|
||||
events_index = Page.objects.get(url_path='/home/events/')
|
||||
pages = Page.objects.not_descendant_of(events_index)
|
||||
|
||||
|
@ -99,7 +98,6 @@ class TestPageQuerySet(TestCase):
|
|||
self.assertTrue(pages.filter(id=events_index.id).exists())
|
||||
|
||||
def test_not_descendant_of_inclusive(self):
|
||||
homepage = Page.objects.get(url_path='/home/')
|
||||
events_index = Page.objects.get(url_path='/home/events/')
|
||||
pages = Page.objects.not_descendant_of(events_index, inclusive=True)
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class TestSiteRootPathsCache(TestCase):
|
|||
homepage = Page.objects.get(url_path='/home/')
|
||||
|
||||
# Warm up the cache by getting the url
|
||||
_ = homepage.url
|
||||
_ = homepage.url # noqa
|
||||
|
||||
# Check that the cache has been set correctly
|
||||
self.assertEqual(cache.get('wagtail_site_root_paths'), [(1, '/home/', 'http://localhost')])
|
||||
|
@ -50,7 +50,7 @@ class TestSiteRootPathsCache(TestCase):
|
|||
homepage = Page.objects.get(url_path='/home/')
|
||||
|
||||
# Warm up the cache by getting the url
|
||||
_ = homepage.url
|
||||
_ = homepage.url # noqa
|
||||
|
||||
# Check that the cache has been set
|
||||
self.assertTrue(cache.get('wagtail_site_root_paths'))
|
||||
|
@ -69,7 +69,7 @@ class TestSiteRootPathsCache(TestCase):
|
|||
homepage = Page.objects.get(url_path='/home/')
|
||||
|
||||
# Warm up the cache by getting the url
|
||||
_ = homepage.url
|
||||
_ = homepage.url # noqa
|
||||
|
||||
# Check that the cache has been set
|
||||
self.assertTrue(cache.get('wagtail_site_root_paths'))
|
||||
|
@ -107,7 +107,7 @@ class TestSiteRootPathsCache(TestCase):
|
|||
default_site.save()
|
||||
|
||||
# Warm up the cache by getting the url
|
||||
_ = homepage.url
|
||||
_ = homepage.url # noqa
|
||||
|
||||
# Move new homepage to root
|
||||
new_homepage.move(root_page, pos='last-child')
|
||||
|
@ -135,7 +135,7 @@ class TestSiteRootPathsCache(TestCase):
|
|||
homepage = Page.objects.get(url_path='/home/')
|
||||
|
||||
# Warm up the cache by getting the url
|
||||
_ = homepage.url
|
||||
_ = homepage.url # noqa
|
||||
|
||||
# Change homepage title and slug
|
||||
homepage.title = "New home"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import warnings
|
||||
|
||||
from django.http import HttpResponse, Http404
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.core.urlresolvers import reverse
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def add_document_permissions_to_admin_groups(apps, schema_editor):
|
||||
ContentType = apps.get_model('contenttypes.ContentType')
|
||||
Permission = apps.get_model('auth.Permission')
|
||||
Group = apps.get_model('auth.Group')
|
||||
Document = apps.get_model('wagtaildocs.Document')
|
||||
|
||||
# Get document permissions
|
||||
document_content_type, _created = ContentType.objects.get_or_create(
|
||||
|
|
|
@ -19,7 +19,7 @@ def get_document_json(document):
|
|||
"""
|
||||
|
||||
return json.dumps({
|
||||
'id': document.id,
|
||||
'id': document.id,
|
||||
'title': document.title,
|
||||
'edit_link': reverse('wagtaildocs_edit_document', args=(document.id,)),
|
||||
})
|
||||
|
@ -94,7 +94,7 @@ def document_chosen(request, document_id):
|
|||
|
||||
return render_modal_workflow(
|
||||
request, None, 'wagtaildocs/chooser/document_chosen.js',
|
||||
{'document_json': get_document_json(document)}
|
||||
{'document_json': get_document_json(document)}
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ def editor_js():
|
|||
@hooks.register('register_permissions')
|
||||
def register_permissions():
|
||||
document_content_type = ContentType.objects.get(app_label='wagtaildocs', model='document')
|
||||
document_permissions = Permission.objects.filter(content_type = document_content_type)
|
||||
document_permissions = Permission.objects.filter(content_type=document_content_type)
|
||||
return document_permissions
|
||||
|
||||
|
||||
|
|
|
@ -10,15 +10,19 @@ from six.moves.urllib.parse import urlencode
|
|||
|
||||
from django.utils.module_loading import import_string
|
||||
from django.conf import settings
|
||||
from django.utils import six
|
||||
|
||||
from wagtail.wagtailembeds.oembed_providers import get_oembed_provider
|
||||
from wagtail.wagtailembeds.models import Embed
|
||||
|
||||
|
||||
class EmbedNotFoundException(Exception): pass
|
||||
class EmbedlyException(Exception): pass
|
||||
class AccessDeniedEmbedlyException(EmbedlyException): pass
|
||||
class EmbedNotFoundException(Exception):
|
||||
pass
|
||||
|
||||
class EmbedlyException(Exception):
|
||||
pass
|
||||
|
||||
class AccessDeniedEmbedlyException(EmbedlyException):
|
||||
pass
|
||||
|
||||
|
||||
def embedly(url, max_width=None, key=None):
|
||||
|
@ -72,7 +76,7 @@ def oembed(url, max_width=None):
|
|||
raise EmbedNotFoundException
|
||||
|
||||
# Work out params
|
||||
params = {'url': url, 'format': 'json', }
|
||||
params = {'url': url, 'format': 'json'}
|
||||
if max_width:
|
||||
params['maxwidth'] = max_width
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ OEMBED_ENDPOINTS = {
|
|||
"http://www.ifttt.com/oembed/": [
|
||||
"^http(?:s)?://ifttt\\.com/recipes/.+$"
|
||||
],
|
||||
|
||||
|
||||
# Added 11th December 2014 - http://developers.issuu.com/api/oembed.html
|
||||
"http://issuu.com/oembed": [
|
||||
"^http(?:s)?://(?:www\\.)?issuu\\.com/[^#?/]+/docs/.+$"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import warnings
|
||||
|
||||
from django import template
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from bs4 import BeautifulSoup
|
|||
from wagtail.wagtailembeds.rich_text import MediaEmbedHandler
|
||||
|
||||
try:
|
||||
import embedly
|
||||
import embedly # noqa
|
||||
no_embedly = False
|
||||
except ImportError:
|
||||
no_embedly = True
|
||||
|
@ -89,7 +89,7 @@ class TestEmbeds(TestCase):
|
|||
# Width must be set to None
|
||||
self.assertEqual(embed.width, None)
|
||||
|
||||
def test_no_html(self) :
|
||||
def test_no_html(self):
|
||||
def no_html_finder(url, max_width=None):
|
||||
"""
|
||||
A finder which returns everything but HTML
|
||||
|
@ -227,13 +227,13 @@ class TestOembed(TestCase):
|
|||
|
||||
def test_oembed_invalid_request(self):
|
||||
config = {'side_effect': URLError('foo')}
|
||||
with patch.object(six.moves.urllib.request, 'urlopen', **config) as urlopen:
|
||||
with patch.object(six.moves.urllib.request, 'urlopen', **config):
|
||||
self.assertRaises(EmbedNotFoundException, wagtail_oembed,
|
||||
"http://www.youtube.com/watch/")
|
||||
|
||||
@patch('six.moves.urllib.request.urlopen')
|
||||
@patch('json.loads')
|
||||
def test_oembed_photo_request(self, loads, urlopen) :
|
||||
def test_oembed_photo_request(self, loads, urlopen):
|
||||
urlopen.return_value = self.dummy_response
|
||||
loads.return_value = {'type': 'photo',
|
||||
'url': 'http://www.example.com'}
|
||||
|
|
|
@ -22,17 +22,17 @@ from .forms import FormBuilder
|
|||
|
||||
|
||||
FORM_FIELD_CHOICES = (
|
||||
('singleline', _('Single line text')),
|
||||
('multiline', _('Multi-line text')),
|
||||
('email', _('Email')),
|
||||
('number', _('Number')),
|
||||
('url', _('URL')),
|
||||
('checkbox', _('Checkbox')),
|
||||
('checkboxes', _('Checkboxes')),
|
||||
('dropdown', _('Drop down')),
|
||||
('radio', _('Radio buttons')),
|
||||
('date', _('Date')),
|
||||
('datetime', _('Date/time')),
|
||||
('singleline', _('Single line text')),
|
||||
('multiline', _('Multi-line text')),
|
||||
('email', _('Email')),
|
||||
('number', _('Number')),
|
||||
('url', _('URL')),
|
||||
('checkbox', _('Checkbox')),
|
||||
('checkboxes', _('Checkboxes')),
|
||||
('dropdown', _('Drop down')),
|
||||
('radio', _('Radio buttons')),
|
||||
('date', _('Date')),
|
||||
('datetime', _('Date/time')),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def add_image_permissions_to_admin_groups(apps, schema_editor):
|
||||
ContentType = apps.get_model('contenttypes.ContentType')
|
||||
Permission = apps.get_model('auth.Permission')
|
||||
Group = apps.get_model('auth.Group')
|
||||
Image = apps.get_model('wagtailimages.Image')
|
||||
|
||||
# Get image permissions
|
||||
image_content_type, _created = ContentType.objects.get_or_create(
|
||||
|
|
|
@ -2,7 +2,6 @@ from __future__ import unicode_literals
|
|||
|
||||
import os.path
|
||||
import hashlib
|
||||
import re
|
||||
from contextlib import contextmanager
|
||||
import warnings
|
||||
|
||||
|
@ -32,6 +31,7 @@ from wagtail.wagtailsearch import index
|
|||
from wagtail.wagtailimages.rect import Rect
|
||||
from wagtail.wagtailimages.exceptions import InvalidFilterSpecError
|
||||
from wagtail.wagtailadmin.utils import get_object_usage
|
||||
from wagtail.utils.deprecation import RemovedInWagtail11Warning
|
||||
|
||||
|
||||
class SourceImageIOError(IOError):
|
||||
|
@ -330,8 +330,8 @@ class Filter(models.Model):
|
|||
|
||||
warnings.warn(
|
||||
"The IMAGE_COMPRESSION_QUALITY setting has been renamed to "
|
||||
"WAGTAILIMAGES_JPEG_QUALITY. Please update your settings."
|
||||
, RemovedInWagtail11Warning)
|
||||
"WAGTAILIMAGES_JPEG_QUALITY. Please update your settings.",
|
||||
RemovedInWagtail11Warning)
|
||||
else:
|
||||
quality = 85
|
||||
|
||||
|
|
|
@ -448,7 +448,7 @@ class TestMultipleImageUploader(TestCase, WagtailTestUtils):
|
|||
self.assertEqual(response_json['image_id'], self.image.id)
|
||||
self.assertTrue(response_json['success'])
|
||||
|
||||
def test_edit_post_noajax(self):
|
||||
def test_delete_post_noajax(self):
|
||||
"""
|
||||
This tests that a POST request to the delete view without AJAX returns a 400 response
|
||||
"""
|
||||
|
|
|
@ -79,7 +79,7 @@ class ImageOperationTestCase(unittest.TestCase):
|
|||
test_name = 'test_run_%s' % filter_spec
|
||||
test_run.__name__ = test_name
|
||||
return test_run
|
||||
|
||||
|
||||
@classmethod
|
||||
def setup_test_methods(cls):
|
||||
if cls.operation_class is None:
|
||||
|
@ -274,7 +274,6 @@ class TestMinMaxOperation(ImageOperationTestCase):
|
|||
|
||||
filter_spec_error_tests = [
|
||||
'min',
|
||||
#'hello-800x600',
|
||||
'min-800',
|
||||
'min-abc',
|
||||
'min-800xabc',
|
||||
|
@ -307,7 +306,6 @@ class TestWidthHeightOperation(ImageOperationTestCase):
|
|||
|
||||
filter_spec_error_tests = [
|
||||
'width',
|
||||
#'hello-800',
|
||||
'width-800x600',
|
||||
'width-abc',
|
||||
'width-800-c100',
|
||||
|
|
|
@ -9,12 +9,11 @@ from django.contrib.auth.models import Group, Permission
|
|||
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.db.utils import IntegrityError
|
||||
from django.db import connection
|
||||
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
from wagtail.wagtailcore.models import Page
|
||||
from wagtail.tests.testapp.models import EventPage, EventPageCarouselItem
|
||||
from wagtail.wagtailimages.models import Rendition, Filter, SourceImageIOError
|
||||
from wagtail.wagtailimages.models import Rendition, SourceImageIOError
|
||||
from wagtail.wagtailimages.rect import Rect
|
||||
|
||||
from .utils import Image, get_test_image_file
|
||||
|
@ -229,7 +228,7 @@ class TestGetWillowImage(TestCase):
|
|||
# Attempting to get the Willow image for images without files
|
||||
# should raise a SourceImageIOError
|
||||
with self.assertRaises(SourceImageIOError):
|
||||
with bad_image.get_willow_image() as willow_image:
|
||||
with bad_image.get_willow_image():
|
||||
self.fail() # Shouldn't get here
|
||||
|
||||
|
||||
|
@ -366,7 +365,7 @@ class TestIssue312(TestCase):
|
|||
# Now manually duplicate the renditon and check that the database blocks it
|
||||
self.assertRaises(
|
||||
IntegrityError,
|
||||
Rendition.objects.create,
|
||||
Rendition.objects.create,
|
||||
image=rend1.image,
|
||||
filter=rend1.filter,
|
||||
width=rend1.width,
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import datetime
|
||||
import warnings
|
||||
from contextlib import contextmanager
|
||||
|
||||
from mock import MagicMock
|
||||
|
||||
|
@ -8,7 +6,6 @@ from django.test import TestCase
|
|||
from django import template, forms
|
||||
from django.utils import six
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
|
||||
from taggit.forms import TagField, TagWidget
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ from django.shortcuts import get_object_or_404
|
|||
from django.http import HttpResponse
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
from wagtail.wagtailimages.models import get_image_model, Filter
|
||||
from wagtail.wagtailimages.models import get_image_model
|
||||
from wagtail.wagtailimages.utils import verify_signature
|
||||
from wagtail.wagtailimages.exceptions import InvalidFilterSpecError
|
||||
|
||||
|
|
|
@ -3,12 +3,11 @@ import json
|
|||
from django.shortcuts import render, get_object_or_404
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
from django.views.decorators.http import require_POST
|
||||
from django.core.exceptions import PermissionDenied, ValidationError
|
||||
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.translation import ugettext as _
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
from wagtail.wagtailsearch.backends import get_search_backends
|
||||
|
@ -20,7 +19,6 @@ from wagtail.wagtailimages.fields import (
|
|||
IMAGE_FIELD_HELP_TEXT,
|
||||
INVALID_IMAGE_ERROR,
|
||||
ALLOWED_EXTENSIONS,
|
||||
SUPPORTED_FORMATS_TEXT,
|
||||
FILE_TOO_LARGE_ERROR,
|
||||
)
|
||||
|
||||
|
@ -64,9 +62,9 @@ def add(request):
|
|||
form = ImageForm({
|
||||
'title': request.FILES['files[]'].name,
|
||||
}, {
|
||||
'file': request.FILES['files[]'],
|
||||
'file': request.FILES['files[]'],
|
||||
})
|
||||
|
||||
|
||||
if form.is_valid():
|
||||
# Save it
|
||||
image = form.save(commit=False)
|
||||
|
@ -113,7 +111,7 @@ def edit(request, image_id, callback=None):
|
|||
if not image.is_editable_by_user(request.user):
|
||||
raise PermissionDenied
|
||||
|
||||
form = ImageForm(request.POST, request.FILES, instance=image, prefix='image-'+image_id)
|
||||
form = ImageForm(request.POST, request.FILES, instance=image, prefix='image-' + image_id)
|
||||
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
|
|
|
@ -43,7 +43,7 @@ def check_old_style_urlconf():
|
|||
# wagtail.wagtailimages.admin_urls is loaded to, resulting in the wagtailimages_serve path
|
||||
# being equal to wagtailimages_index followed by three arbitrary args
|
||||
try:
|
||||
wagtailimages_serve_path = urlresolvers.reverse('wagtailimages_serve', args = ['123', '456', '789'])
|
||||
wagtailimages_serve_path = urlresolvers.reverse('wagtailimages_serve', args=['123', '456', '789'])
|
||||
except urlresolvers.NoReverseMatch:
|
||||
# wagtailimages_serve is not defined at all, so there's no collision
|
||||
OLD_STYLE_URLCONF_CHECK_PASSED = True
|
||||
|
@ -97,7 +97,7 @@ def editor_js():
|
|||
@hooks.register('register_permissions')
|
||||
def register_permissions():
|
||||
image_content_type = ContentType.objects.get(app_label='wagtailimages', model='image')
|
||||
image_permissions = Permission.objects.filter(content_type = image_content_type)
|
||||
image_permissions = Permission.objects.filter(content_type=image_content_type)
|
||||
return image_permissions
|
||||
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ class TestRedirectsAddView(TestCase, WagtailTestUtils):
|
|||
|
||||
def get(self, params={}):
|
||||
return self.client.get(reverse('wagtailredirects_add_redirect'), params)
|
||||
|
||||
|
||||
def post(self, post_data={}):
|
||||
return self.client.post(reverse('wagtailredirects_add_redirect'), post_data)
|
||||
|
||||
|
@ -142,7 +142,7 @@ class TestRedirectsEditView(TestCase, WagtailTestUtils):
|
|||
|
||||
def get(self, params={}, redirect_id=None):
|
||||
return self.client.get(reverse('wagtailredirects_edit_redirect', args=(redirect_id or self.redirect.id, )), params)
|
||||
|
||||
|
||||
def post(self, post_data={}, redirect_id=None):
|
||||
return self.client.post(reverse('wagtailredirects_edit_redirect', args=(redirect_id or self.redirect.id, )), post_data)
|
||||
|
||||
|
@ -190,7 +190,7 @@ class TestRedirectsDeleteView(TestCase, WagtailTestUtils):
|
|||
|
||||
def get(self, params={}, redirect_id=None):
|
||||
return self.client.get(reverse('wagtailredirects_delete_redirect', args=(redirect_id or self.redirect.id, )), params)
|
||||
|
||||
|
||||
def post(self, post_data={}, redirect_id=None):
|
||||
return self.client.post(reverse('wagtailredirects_delete_redirect', args=(redirect_id or self.redirect.id, )), post_data)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.contrib.auth.decorators import permission_required
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views.decorators.vary import vary_on_headers
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
from six import text_type
|
||||
|
||||
from django.db import models
|
||||
from django.db.models.query import QuerySet
|
||||
from django.db.models.lookups import Lookup
|
||||
from django.db.models.sql.where import SubqueryConstraint, WhereNode
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
|
||||
from wagtail.wagtailsearch.index import class_is_indexed
|
||||
|
||||
|
|
|
@ -4,13 +4,11 @@ import json
|
|||
|
||||
from six.moves.urllib.parse import urlparse
|
||||
|
||||
from django.db import models
|
||||
|
||||
from elasticsearch import Elasticsearch, NotFoundError, RequestError
|
||||
from elasticsearch import Elasticsearch, NotFoundError
|
||||
from elasticsearch.helpers import bulk
|
||||
|
||||
from wagtail.wagtailsearch.backends.base import BaseSearch, BaseSearchQuery, BaseSearchResults
|
||||
from wagtail.wagtailsearch.index import Indexed, SearchField, FilterField, class_is_indexed
|
||||
from wagtail.wagtailsearch.index import SearchField, FilterField, class_is_indexed
|
||||
|
||||
|
||||
class ElasticSearchMapping(object):
|
||||
|
|
|
@ -7,10 +7,10 @@ from wagtail.wagtailsearch import models
|
|||
|
||||
|
||||
class QueryForm(forms.Form):
|
||||
query_string = forms.CharField(label=_('Search term(s)/phrase'),
|
||||
help_text=_("""Enter the full search string to match. An
|
||||
exact match is required for your Editors Picks to be
|
||||
displayed, wildcards are NOT allowed."""),
|
||||
query_string = forms.CharField(label=_("Search term(s)/phrase"),
|
||||
help_text=_("Enter the full search string to match. An "
|
||||
"exact match is required for your Editors Picks to be "
|
||||
"displayed, wildcards are NOT allowed."),
|
||||
required=True)
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
import warnings
|
||||
|
||||
from six import string_types
|
||||
|
||||
from django.db import models
|
||||
from django.apps import apps
|
||||
|
||||
|
@ -140,4 +136,3 @@ class SearchField(BaseField):
|
|||
|
||||
class FilterField(BaseField):
|
||||
suffix = '_filter'
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from optparse import make_option
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.conf import settings
|
||||
|
||||
from wagtail.wagtailsearch.index import Indexed, get_indexed_models
|
||||
from wagtail.wagtailsearch.index import get_indexed_models
|
||||
from wagtail.wagtailsearch.backends import get_search_backend
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.db.models.signals import post_save, post_delete
|
||||
|
||||
from wagtail.wagtailsearch.index import Indexed, get_indexed_models
|
||||
from wagtail.wagtailsearch.index import get_indexed_models
|
||||
from wagtail.wagtailsearch.backends import get_search_backends
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from six import StringIO
|
||||
import warnings
|
||||
import unittest
|
||||
|
||||
from django.test import TestCase
|
||||
|
@ -82,15 +81,6 @@ class BackendTests(WagtailTestUtils):
|
|||
# Should return two results
|
||||
self.assertEqual(len(results), 2)
|
||||
|
||||
@unittest.skip("Need something to prefetch")
|
||||
def test_prefetch_related(self):
|
||||
# Get results
|
||||
results = self.backend.search("Hello", models.SearchTest, prefetch_related=['prefetch_field'])
|
||||
|
||||
# Test both single result and multiple result (different code for each), only checking that this doesnt crash
|
||||
single_result = results[0]
|
||||
multi_result = results[:2]
|
||||
|
||||
def test_callable_indexed_field(self):
|
||||
# Get results
|
||||
results = self.backend.search("Callable", models.SearchTest)
|
||||
|
|
|
@ -29,13 +29,13 @@ class TestElasticSearchBackend(BackendTests, TestCase):
|
|||
from wagtail.wagtailsearch.backends.base import FieldError
|
||||
|
||||
with self.assertRaises(FieldError):
|
||||
results = list(self.backend.search("Hello", models.SearchTest, filters=dict(id=42)))
|
||||
list(self.backend.search("Hello", models.SearchTest, filters=dict(id=42)))
|
||||
|
||||
def test_filter_with_unsupported_lookup_type(self):
|
||||
from wagtail.wagtailsearch.backends.base import FilterError
|
||||
|
||||
with self.assertRaises(FilterError):
|
||||
results = list(self.backend.search("Hello", models.SearchTest, filters=dict(title__iregex='h(ea)llo')))
|
||||
list(self.backend.search("Hello", models.SearchTest, filters=dict(title__iregex='h(ea)llo')))
|
||||
|
||||
def test_partial_search(self):
|
||||
# Reset the index
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
import warnings
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
from wagtail.wagtailsearch import index
|
||||
from wagtail.tests.search import models
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
|
||||
|
||||
class TestContentTypeNames(TestCase):
|
||||
|
|
|
@ -1 +1 @@
|
|||
from wagtail.wagtailsearch.urls.frontend import urlpatterns
|
||||
from wagtail.wagtailsearch.urls.frontend import urlpatterns # noqa
|
||||
|
|
|
@ -1 +1 @@
|
|||
from wagtail.wagtailsearch.views.frontend import search
|
||||
from wagtail.wagtailsearch.views.frontend import search # noqa
|
||||
|
|
|
@ -19,8 +19,7 @@ def search(
|
|||
show_unpublished=False,
|
||||
search_title_only=False,
|
||||
extra_filters={},
|
||||
path=None,
|
||||
):
|
||||
path=None):
|
||||
|
||||
# Get default templates
|
||||
if template is None:
|
||||
|
|
|
@ -28,7 +28,7 @@ def create(request):
|
|||
form = SiteForm(request.POST)
|
||||
if form.is_valid():
|
||||
site = form.save()
|
||||
messages.success(request, _("Site '{0}' created.").format(site.hostname), buttons = [
|
||||
messages.success(request, _("Site '{0}' created.").format(site.hostname), buttons=[
|
||||
messages.button(reverse('wagtailsites_edit', args=(site.id,)), _('Edit'))
|
||||
])
|
||||
return redirect('wagtailsites_index')
|
||||
|
@ -50,7 +50,7 @@ def edit(request, site_id):
|
|||
form = SiteForm(request.POST, instance=site)
|
||||
if form.is_valid():
|
||||
site = form.save()
|
||||
messages.success(request, _("Site '{0}' updated.").format(site.hostname), buttons = [
|
||||
messages.success(request, _("Site '{0}' updated.").format(site.hostname), buttons=[
|
||||
messages.button(reverse('wagtailsites_edit', args=(site.id,)), _('Edit'))
|
||||
])
|
||||
return redirect('wagtailsites_index')
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
from django.http import Http404
|
||||
from django.test import TestCase
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db import models
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
|
@ -114,13 +112,11 @@ class TestSnippetEditView(TestCase, WagtailTestUtils):
|
|||
self.assertTemplateUsed(response, 'wagtailsnippets/snippets/edit.html')
|
||||
|
||||
def test_non_existant_model(self):
|
||||
response = self.client.get(reverse('wagtailsnippets_edit',
|
||||
args=('tests', 'foo', self.test_snippet.id)))
|
||||
response = self.client.get(reverse('wagtailsnippets_edit', args=('tests', 'foo', self.test_snippet.id)))
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_nonexistant_id(self):
|
||||
response = self.client.get(reverse('wagtailsnippets_edit',
|
||||
args=('tests', 'advert', 999999)))
|
||||
response = self.client.get(reverse('wagtailsnippets_edit', args=('tests', 'advert', 999999)))
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_edit_invalid(self):
|
||||
|
|
|
@ -138,7 +138,7 @@ def create(request, content_type_app_name, content_type_model_name):
|
|||
instance=instance
|
||||
),
|
||||
buttons=[
|
||||
messages.button(reverse('wagtailsnippets_edit', args=(content_type_app_name,content_type_model_name,instance.id,)), _('Edit'))
|
||||
messages.button(reverse('wagtailsnippets_edit', args=(content_type_app_name, content_type_model_name, instance.id)), _('Edit'))
|
||||
]
|
||||
)
|
||||
return redirect('wagtailsnippets_list', content_type.app_label, content_type.model)
|
||||
|
@ -181,7 +181,7 @@ def edit(request, content_type_app_name, content_type_model_name, id):
|
|||
instance=instance
|
||||
),
|
||||
buttons=[
|
||||
messages.button(reverse('wagtailsnippets_edit', args=(content_type_app_name,content_type_model_name,instance.id,)), _('Edit'))
|
||||
messages.button(reverse('wagtailsnippets_edit', args=(content_type_app_name, content_type_model_name, instance.id)), _('Edit'))
|
||||
]
|
||||
)
|
||||
return redirect('wagtailsnippets_list', content_type.app_label, content_type.model)
|
||||
|
|
|
@ -10,7 +10,7 @@ from wagtail.wagtailadmin.widgets import AdminChooser
|
|||
|
||||
class AdminSnippetChooser(AdminChooser):
|
||||
target_content_type = None
|
||||
|
||||
|
||||
def __init__(self, content_type=None, **kwargs):
|
||||
if 'snippet_type_name' in kwargs:
|
||||
snippet_type_name = kwargs.pop('snippet_type_name')
|
||||
|
|
|
@ -84,7 +84,7 @@ def create(request):
|
|||
group = form.save()
|
||||
formset.instance = group
|
||||
formset.save()
|
||||
messages.success(request, _("Group '{0}' created.").format(group), buttons = [
|
||||
messages.success(request, _("Group '{0}' created.").format(group), buttons=[
|
||||
messages.button(reverse('wagtailusers_groups_edit', args=(group.id,)), _('Edit'))
|
||||
])
|
||||
return redirect('wagtailusers_groups_index')
|
||||
|
@ -109,7 +109,7 @@ def edit(request, group_id):
|
|||
if form.is_valid() and formset.is_valid():
|
||||
group = form.save()
|
||||
formset.save()
|
||||
messages.success(request, _("Group '{0}' updated.").format(group), buttons = [
|
||||
messages.success(request, _("Group '{0}' updated.").format(group), buttons=[
|
||||
messages.button(reverse('wagtailusers_groups_edit', args=(group.id,)), _('Edit'))
|
||||
])
|
||||
return redirect('wagtailusers_groups_index')
|
||||
|
|
|
@ -88,7 +88,7 @@ def create(request):
|
|||
])
|
||||
return redirect('wagtailusers_users_index')
|
||||
else:
|
||||
messages.error(request, _("The user could not be created due to errors.") )
|
||||
messages.error(request, _("The user could not be created due to errors."))
|
||||
else:
|
||||
form = UserCreationForm()
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue