diff --git a/tox.ini b/tox.ini index 9ec4541abc..e54b5ecad3 100644 --- a/tox.ini +++ b/tox.ini @@ -5,7 +5,7 @@ usedevelop = True envlist = py{27,33,34,35}-dj{17,18}-{sqlite,postgres,mysql}, flake8 [flake8] -ignore = E501,E128,E303 +ignore = E501,E303 exclude = wagtail/project_template/* [testenv] diff --git a/wagtail/contrib/wagtailsearchpromotions/wagtail_hooks.py b/wagtail/contrib/wagtailsearchpromotions/wagtail_hooks.py index 9e8c4164cf..80894eae27 100644 --- a/wagtail/contrib/wagtailsearchpromotions/wagtail_hooks.py +++ b/wagtail/contrib/wagtailsearchpromotions/wagtail_hooks.py @@ -33,4 +33,4 @@ def register_search_picks_menu_item(): @hooks.register('register_permissions') def register_permissions(): return Permission.objects.filter(content_type__app_label='wagtailsearchpromotions', - codename__in=['add_searchpromotion', 'change_searchpromotion', 'delete_searchpromotion']) + codename__in=['add_searchpromotion', 'change_searchpromotion', 'delete_searchpromotion']) diff --git a/wagtail/wagtailadmin/tests/test_edit_handlers.py b/wagtail/wagtailadmin/tests/test_edit_handlers.py index 86e7f6de39..4f22ab6bfb 100644 --- a/wagtail/wagtailadmin/tests/test_edit_handlers.py +++ b/wagtail/wagtailadmin/tests/test_edit_handlers.py @@ -261,7 +261,7 @@ class TestFieldPanel(TestCase): def setUp(self): 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)) + date_from=date(2014, 7, 20), date_to=date(2014, 7, 21)) self.EndDatePanel = FieldPanel('date_to', classname='full-width').bind_to_model(EventPage) diff --git a/wagtail/wagtailadmin/urls/__init__.py b/wagtail/wagtailadmin/urls/__init__.py index 01fea763bd..6487d413a8 100644 --- a/wagtail/wagtailadmin/urls/__init__.py +++ b/wagtail/wagtailadmin/urls/__init__.py @@ -46,7 +46,8 @@ for fn in hooks.get_hooks('register_admin_urls'): # Add "wagtailadmin.access_admin" permission check -urlpatterns = decorate_urlpatterns(urlpatterns, +urlpatterns = decorate_urlpatterns( + urlpatterns, permission_required( 'wagtailadmin.access_admin', login_url='wagtailadmin_login' @@ -68,6 +69,7 @@ urlpatterns += [ ] # Decorate all views with cache settings to prevent caching -urlpatterns = decorate_urlpatterns(urlpatterns, +urlpatterns = decorate_urlpatterns( + urlpatterns, cache_control(private=True, no_cache=True, no_store=True, max_age=0) ) diff --git a/wagtail/wagtailadmin/views/account.py b/wagtail/wagtailadmin/views/account.py index 34cad13b34..29170e8d4a 100644 --- a/wagtail/wagtailadmin/views/account.py +++ b/wagtail/wagtailadmin/views/account.py @@ -109,7 +109,8 @@ def login(request): return redirect('wagtailadmin_home') else: from django.contrib.auth import get_user_model - return auth_views.login(request, + return auth_views.login( + request, template_name='wagtailadmin/login.html', authentication_form=forms.LoginForm, extra_context={ @@ -126,8 +127,8 @@ def logout(request): # absence of sessionid as an indication that front-end pages are being viewed by a # non-logged-in user and are therefore cacheable, so we forcibly delete the cookie here. response.delete_cookie(settings.SESSION_COOKIE_NAME, - domain=settings.SESSION_COOKIE_DOMAIN, - path=settings.SESSION_COOKIE_PATH) + domain=settings.SESSION_COOKIE_DOMAIN, + path=settings.SESSION_COOKIE_PATH) # HACK: pretend that the session hasn't been modified, so that SessionMiddleware # won't override the above and write a new cookie. diff --git a/wagtail/wagtailcore/blocks/list_block.py b/wagtail/wagtailcore/blocks/list_block.py index 0da38c2bc5..73a1c801d0 100644 --- a/wagtail/wagtailcore/blocks/list_block.py +++ b/wagtail/wagtailcore/blocks/list_block.py @@ -81,7 +81,7 @@ class ListBlock(Block): list_members_html = [ self.render_list_member(child_val, "%s-%d" % (prefix, i), i, - errors=error_list[i] if error_list else None) + errors=error_list[i] if error_list else None) for (i, child_val) in enumerate(value) ] @@ -140,7 +140,8 @@ class ListBlock(Block): ] def render_basic(self, value): - children = format_html_join('\n', '
  • {0}
  • ', + children = format_html_join( + '\n', '
  • {0}
  • ', [(self.child_block.render(child_value),) for child_value in value] ) return format_html("", children) diff --git a/wagtail/wagtailcore/blocks/stream_block.py b/wagtail/wagtailcore/blocks/stream_block.py index a544a64003..49f70f4784 100644 --- a/wagtail/wagtailcore/blocks/stream_block.py +++ b/wagtail/wagtailcore/blocks/stream_block.py @@ -120,7 +120,7 @@ class BaseStreamBlock(Block): list_members_html = [ self.render_list_member(child.block_type, child.value, "%s-%d" % (prefix, i), i, - errors=error_list[i] if error_list else None) + errors=error_list[i] if error_list else None) for (i, child) in enumerate(valid_children) ] @@ -197,7 +197,8 @@ class BaseStreamBlock(Block): ] def render_basic(self, value): - return format_html_join('\n', '
    {0}
    ', + return format_html_join( + '\n', '
    {0}
    ', [(force_text(child), child.block_type) for child in value] ) diff --git a/wagtail/wagtailcore/blocks/struct_block.py b/wagtail/wagtailcore/blocks/struct_block.py index ac1786fa39..7c9c438ebc 100644 --- a/wagtail/wagtailcore/blocks/struct_block.py +++ b/wagtail/wagtailcore/blocks/struct_block.py @@ -78,7 +78,7 @@ class BaseStructBlock(Block): ( name, block.bind(value.get(name, block.get_default()), - prefix="%s-%s" % (prefix, name), errors=error_dict.get(name)) + prefix="%s-%s" % (prefix, name), errors=error_dict.get(name)) ) for name, block in self.child_blocks.items() ]) diff --git a/wagtail/wagtailcore/wagtail_hooks.py b/wagtail/wagtailcore/wagtail_hooks.py index 11bf723ff2..fffdd0d8c1 100644 --- a/wagtail/wagtailcore/wagtail_hooks.py +++ b/wagtail/wagtailcore/wagtail_hooks.py @@ -20,6 +20,6 @@ def check_view_restrictions(page, request, serve_args, serve_kwargs): if restriction.id not in passed_restrictions: from wagtail.wagtailcore.forms import PasswordPageViewRestrictionForm form = PasswordPageViewRestrictionForm(instance=restriction, - initial={'return_url': request.get_full_path()}) + initial={'return_url': request.get_full_path()}) action_url = reverse('wagtailcore_authenticate_with_password', args=[restriction.id, page.id]) return page.serve_password_required_response(request, form, action_url) diff --git a/wagtail/wagtaildocs/wagtail_hooks.py b/wagtail/wagtaildocs/wagtail_hooks.py index fb1accb503..083a796695 100644 --- a/wagtail/wagtaildocs/wagtail_hooks.py +++ b/wagtail/wagtaildocs/wagtail_hooks.py @@ -37,7 +37,8 @@ def editor_js(): 'wagtaildocs/js/hallo-plugins/hallo-wagtaildoclink.js', 'wagtaildocs/js/document-chooser.js', ] - js_includes = format_html_join('\n', '', + js_includes = format_html_join( + '\n', '', ((settings.STATIC_URL, filename) for filename in js_files) ) return js_includes + format_html( @@ -54,7 +55,7 @@ def editor_js(): @hooks.register('register_permissions') def register_permissions(): return Permission.objects.filter(content_type__app_label='wagtaildocs', - codename__in=['add_document', 'change_document']) + codename__in=['add_document', 'change_document']) @hooks.register('register_rich_text_link_handler') diff --git a/wagtail/wagtailimages/fields.py b/wagtail/wagtailimages/fields.py index 2663d6667b..78f4cb1a33 100644 --- a/wagtail/wagtailimages/fields.py +++ b/wagtail/wagtailimages/fields.py @@ -73,7 +73,7 @@ class WagtailImageField(ImageField): except IOError: # Uploaded file is not even an image file (or corrupted) raise ValidationError(self.error_messages['invalid_image_known_format'], - code='invalid_image_known_format') + code='invalid_image_known_format') f.seek(file_position) else: diff --git a/wagtail/wagtailimages/wagtail_hooks.py b/wagtail/wagtailimages/wagtail_hooks.py index a5f859695f..60520bb547 100644 --- a/wagtail/wagtailimages/wagtail_hooks.py +++ b/wagtail/wagtailimages/wagtail_hooks.py @@ -37,7 +37,8 @@ def editor_js(): 'wagtailimages/js/hallo-plugins/hallo-wagtailimage.js', 'wagtailimages/js/image-chooser.js', ] - js_includes = format_html_join('\n', '', + js_includes = format_html_join( + '\n', '', ((settings.STATIC_URL, filename) for filename in js_files) ) return js_includes + format_html( @@ -54,7 +55,7 @@ def editor_js(): @hooks.register('register_permissions') def register_permissions(): return Permission.objects.filter(content_type__app_label='wagtailimages', - codename__in=['add_image', 'change_image']) + codename__in=['add_image', 'change_image']) @hooks.register('register_image_operations') diff --git a/wagtail/wagtailredirects/wagtail_hooks.py b/wagtail/wagtailredirects/wagtail_hooks.py index 3de51c4af5..ebacf956b9 100644 --- a/wagtail/wagtailredirects/wagtail_hooks.py +++ b/wagtail/wagtailredirects/wagtail_hooks.py @@ -33,4 +33,4 @@ def register_redirects_menu_item(): @hooks.register('register_permissions') def register_permissions(): return Permission.objects.filter(content_type__app_label='wagtailredirects', - codename__in=['add_redirect', 'change_redirect', 'delete_redirect']) + codename__in=['add_redirect', 'change_redirect', 'delete_redirect']) diff --git a/wagtail/wagtailsearch/forms.py b/wagtail/wagtailsearch/forms.py index dc8dc1a64a..0191e52b8d 100644 --- a/wagtail/wagtailsearch/forms.py +++ b/wagtail/wagtailsearch/forms.py @@ -4,7 +4,7 @@ from django.utils.translation import ugettext_lazy as _ 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 Promoted Results to be " - "displayed, wildcards are NOT allowed."), - required=True) + help_text=_("Enter the full search string to match. An " + "exact match is required for your Promoted Results to be " + "displayed, wildcards are NOT allowed."), + required=True) diff --git a/wagtail/wagtailsearch/queryset.py b/wagtail/wagtailsearch/queryset.py index a12d37c718..2ec8601636 100644 --- a/wagtail/wagtailsearch/queryset.py +++ b/wagtail/wagtailsearch/queryset.py @@ -3,10 +3,10 @@ from wagtail.wagtailsearch.backends import get_search_backend class SearchableQuerySetMixin(object): def search(self, query_string, fields=None, - operator=None, order_by_relevance=True, backend='default'): + operator=None, order_by_relevance=True, backend='default'): """ This runs a search query on all the items in the QuerySet """ search_backend = get_search_backend(backend) return search_backend.search(query_string, self, fields=fields, - operator=operator, order_by_relevance=order_by_relevance) + operator=operator, order_by_relevance=order_by_relevance) diff --git a/wagtail/wagtailsites/wagtail_hooks.py b/wagtail/wagtailsites/wagtail_hooks.py index a0e19bc51e..54e47f3658 100644 --- a/wagtail/wagtailsites/wagtail_hooks.py +++ b/wagtail/wagtailsites/wagtail_hooks.py @@ -33,4 +33,4 @@ def register_sites_menu_item(): @hooks.register('register_permissions') def register_permissions(): return Permission.objects.filter(content_type__app_label='wagtailcore', - codename__in=['add_site', 'change_site', 'delete_site']) + codename__in=['add_site', 'change_site', 'delete_site']) diff --git a/wagtail/wagtailsnippets/tests.py b/wagtail/wagtailsnippets/tests.py index 49667697fa..3c0b5e667c 100644 --- a/wagtail/wagtailsnippets/tests.py +++ b/wagtail/wagtailsnippets/tests.py @@ -281,7 +281,8 @@ class TestSnippetChooserPanel(TestCase): snippet_chooser_panel = [ panel for panel in edit_handler.children - if getattr(panel, 'field_name', None) == 'advert'][0] + if getattr(panel, 'field_name', None) == 'advert' + ][0] field_html = snippet_chooser_panel.render_as_field() self.assertIn("Choose advert", field_html) @@ -478,7 +479,7 @@ class TestAddOnlyPermissions(TestCase, WagtailTestUtils): def test_get_index(self): response = self.client.get(reverse('wagtailsnippets:list', - args=('tests', 'advert'))) + args=('tests', 'advert'))) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'wagtailsnippets/snippets/type_index.html') @@ -487,13 +488,13 @@ class TestAddOnlyPermissions(TestCase, WagtailTestUtils): def test_get_add(self): response = self.client.get(reverse('wagtailsnippets:add', - args=('tests', 'advert'))) + args=('tests', 'advert'))) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'wagtailsnippets/snippets/create.html') def test_get_edit(self): response = self.client.get(reverse('wagtailsnippets:edit', - args=('tests', 'advert', self.test_snippet.id))) + args=('tests', 'advert', self.test_snippet.id))) # permission should be denied self.assertRedirects(response, reverse('wagtailadmin_home')) @@ -518,7 +519,7 @@ class TestEditOnlyPermissions(TestCase, WagtailTestUtils): def test_get_index(self): response = self.client.get(reverse('wagtailsnippets:list', - args=('tests', 'advert'))) + args=('tests', 'advert'))) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'wagtailsnippets/snippets/type_index.html') @@ -527,13 +528,13 @@ class TestEditOnlyPermissions(TestCase, WagtailTestUtils): def test_get_add(self): response = self.client.get(reverse('wagtailsnippets:add', - args=('tests', 'advert'))) + args=('tests', 'advert'))) # permission should be denied self.assertRedirects(response, reverse('wagtailadmin_home')) def test_get_edit(self): response = self.client.get(reverse('wagtailsnippets:edit', - args=('tests', 'advert', self.test_snippet.id))) + args=('tests', 'advert', self.test_snippet.id))) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'wagtailsnippets/snippets/edit.html') @@ -558,7 +559,7 @@ class TestDeleteOnlyPermissions(TestCase, WagtailTestUtils): def test_get_index(self): response = self.client.get(reverse('wagtailsnippets:list', - args=('tests', 'advert'))) + args=('tests', 'advert'))) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'wagtailsnippets/snippets/type_index.html') @@ -567,13 +568,13 @@ class TestDeleteOnlyPermissions(TestCase, WagtailTestUtils): def test_get_add(self): response = self.client.get(reverse('wagtailsnippets:add', - args=('tests', 'advert'))) + args=('tests', 'advert'))) # permission should be denied self.assertRedirects(response, reverse('wagtailadmin_home')) def test_get_edit(self): response = self.client.get(reverse('wagtailsnippets:edit', - args=('tests', 'advert', self.test_snippet.id))) + args=('tests', 'advert', self.test_snippet.id))) # permission should be denied self.assertRedirects(response, reverse('wagtailadmin_home')) diff --git a/wagtail/wagtailusers/forms.py b/wagtail/wagtailusers/forms.py index 82cb89c9e6..994630fa24 100644 --- a/wagtail/wagtailusers/forms.py +++ b/wagtail/wagtailusers/forms.py @@ -235,7 +235,7 @@ class GroupForm(forms.ModelForm): class GroupPagePermissionForm(forms.ModelForm): page = forms.ModelChoiceField(queryset=Page.objects.all(), - widget=AdminPageChooser(show_edit_link=False, can_choose_root=True)) + widget=AdminPageChooser(show_edit_link=False, can_choose_root=True)) class Meta: model = GroupPagePermission