diff --git a/wagtail/contrib/wagtailsearchpromotions/forms.py b/wagtail/contrib/wagtailsearchpromotions/forms.py index 7ccdb21773..6cbbe01d60 100644 --- a/wagtail/contrib/wagtailsearchpromotions/forms.py +++ b/wagtail/contrib/wagtailsearchpromotions/forms.py @@ -54,7 +54,7 @@ class SearchPromotionsFormSet(SearchPromotionsFormSetBase): if not (form.instance.id is None and not form.has_changed()): non_empty_forms += 1 if ( - non_deleted_forms < self.minimum_forms - or non_empty_forms < self.minimum_forms + non_deleted_forms < self.minimum_forms or + non_empty_forms < self.minimum_forms ): raise forms.ValidationError(self.minimum_forms_message) diff --git a/wagtail/contrib/wagtailsearchpromotions/wagtail_hooks.py b/wagtail/contrib/wagtailsearchpromotions/wagtail_hooks.py index 4dd4f1e08e..3757d0a29e 100644 --- a/wagtail/contrib/wagtailsearchpromotions/wagtail_hooks.py +++ b/wagtail/contrib/wagtailsearchpromotions/wagtail_hooks.py @@ -19,9 +19,9 @@ def register_admin_urls(): class SearchPicksMenuItem(MenuItem): def is_shown(self, request): return ( - request.user.has_perm('wagtailsearchpromotions.add_searchpromotion') - or request.user.has_perm('wagtailsearchpromotions.change_searchpromotion') - or request.user.has_perm('wagtailsearchpromotions.delete_searchpromotion') + request.user.has_perm('wagtailsearchpromotions.add_searchpromotion') or + request.user.has_perm('wagtailsearchpromotions.change_searchpromotion') or + request.user.has_perm('wagtailsearchpromotions.delete_searchpromotion') ) diff --git a/wagtail/wagtailadmin/views/generic.py b/wagtail/wagtailadmin/views/generic.py index 3b7e02d9f4..c3b0ecdc94 100644 --- a/wagtail/wagtailadmin/views/generic.py +++ b/wagtail/wagtailadmin/views/generic.py @@ -61,8 +61,8 @@ class IndexView(PermissionCheckedMixin, View): 'view': self, 'object_list': object_list, 'can_add': ( - self.permission_policy is None - or self.permission_policy.user_has_permission(self.request.user, 'add') + self.permission_policy is None or + self.permission_policy.user_has_permission(self.request.user, 'add') ), } if self.context_object_name: @@ -153,8 +153,8 @@ class EditView(PermissionCheckedMixin, View): 'object': self.instance, 'form': self.form, 'can_delete': ( - self.permission_policy is None - or self.permission_policy.user_has_permission(self.request.user, 'delete') + self.permission_policy is None or + self.permission_policy.user_has_permission(self.request.user, 'delete') ), } if self.context_object_name: diff --git a/wagtail/wagtailadmin/views/pages.py b/wagtail/wagtailadmin/views/pages.py index a937b698f9..4845e52f54 100644 --- a/wagtail/wagtailadmin/views/pages.py +++ b/wagtail/wagtailadmin/views/pages.py @@ -300,8 +300,8 @@ def edit(request, page_id): edit_handler = edit_handler_class(instance=page, form=form) errors_debug = ( - repr(edit_handler.form.errors) - + repr( + repr(edit_handler.form.errors) + + repr( [(name, formset.errors) for (name, formset) in edit_handler.form.formsets.items() if formset.errors] ) ) diff --git a/wagtail/wagtailcore/models.py b/wagtail/wagtailcore/models.py index ee6ef4ad9f..b78db14856 100644 --- a/wagtail/wagtailcore/models.py +++ b/wagtail/wagtailcore/models.py @@ -1595,9 +1595,9 @@ class PagePermissionTester(object): elif 'add' in self.permissions: # user can only delete if all pages in this subtree are unpublished and owned by this user return ( - (not self.page.live) - and (self.page.owner_id == self.user.id) - and (not self.page.get_descendants().exclude(live=False, owner=self.user).exists()) + (not self.page.live) and + (self.page.owner_id == self.user.id) and + (not self.page.get_descendants().exclude(live=False, owner=self.user).exists()) ) else: diff --git a/wagtail/wagtailcore/permission_policies.py b/wagtail/wagtailcore/permission_policies.py index bac334c1d4..2757bd8963 100644 --- a/wagtail/wagtailcore/permission_policies.py +++ b/wagtail/wagtailcore/permission_policies.py @@ -199,9 +199,9 @@ class BaseDjangoAuthPermissionPolicy(BasePermissionPolicy): codename__in=permission_codenames ) return ( - Q(is_superuser=True) - | Q(user_permissions__in=permissions) - | Q(groups__permissions__in=permissions) + Q(is_superuser=True) | + Q(user_permissions__in=permissions) | + Q(groups__permissions__in=permissions) ) & Q(is_active=True) def _get_users_with_any_permission_codenames(self, permission_codenames): @@ -268,8 +268,8 @@ class OwnershipPermissionPolicy(BaseDjangoAuthPermissionPolicy): # having 'add' permission means that there are *potentially* # some instances they can edit (namely: ones they own), # which is sufficient for returning True here - user.has_perm(self._get_permission_name('add')) - or user.has_perm(self._get_permission_name('change')) + user.has_perm(self._get_permission_name('add')) or + user.has_perm(self._get_permission_name('change')) ) else: # unrecognised actions are only allowed for active superusers @@ -302,8 +302,8 @@ class OwnershipPermissionPolicy(BaseDjangoAuthPermissionPolicy): if user.has_perm(self._get_permission_name('change')): return True elif ( - user.has_perm(self._get_permission_name('add')) - and getattr(instance, self.owner_field_name) == user + user.has_perm(self._get_permission_name('add')) and + getattr(instance, self.owner_field_name) == user ): return True else: diff --git a/wagtail/wagtailsearch/backends/base.py b/wagtail/wagtailsearch/backends/base.py index 9545a4365c..d86ced1df9 100644 --- a/wagtail/wagtailsearch/backends/base.py +++ b/wagtail/wagtailsearch/backends/base.py @@ -55,8 +55,8 @@ class BaseSearchQuery(object): if field is None: raise FieldError( - 'Cannot filter search results with field "' + field_attname + '". Please add index.FilterField(\'' - + field_attname + '\') to ' + self.queryset.model.__name__ + '.search_fields.' + 'Cannot filter search results with field "' + field_attname + '". Please add index.FilterField(\'' + + field_attname + '\') to ' + self.queryset.model.__name__ + '.search_fields.' ) # Process the lookup @@ -64,8 +64,8 @@ class BaseSearchQuery(object): if result is None: raise FilterError( - 'Could not apply filter on search results: "' + field_attname + '__' - + lookup + ' = ' + text_type(value) + '". Lookup "' + lookup + '"" not recognosed.' + 'Could not apply filter on search results: "' + field_attname + '__' + + lookup + ' = ' + text_type(value) + '". Lookup "' + lookup + '"" not recognosed.' ) return result diff --git a/wagtail/wagtailusers/wagtail_hooks.py b/wagtail/wagtailusers/wagtail_hooks.py index aa248fb486..6445af84b7 100644 --- a/wagtail/wagtailusers/wagtail_hooks.py +++ b/wagtail/wagtailusers/wagtail_hooks.py @@ -31,9 +31,9 @@ delete_user_perm = "{0}.delete_{1}".format(AUTH_USER_APP_LABEL, AUTH_USER_MODEL_ class UsersMenuItem(MenuItem): def is_shown(self, request): return ( - request.user.has_perm(add_user_perm) - or request.user.has_perm(change_user_perm) - or request.user.has_perm(delete_user_perm) + request.user.has_perm(add_user_perm) or + request.user.has_perm(change_user_perm) or + request.user.has_perm(delete_user_perm) ) @@ -50,9 +50,9 @@ def register_users_menu_item(): class GroupsMenuItem(MenuItem): def is_shown(self, request): return ( - request.user.has_perm('auth.add_group') - or request.user.has_perm('auth.change_group') - or request.user.has_perm('auth.delete_group') + request.user.has_perm('auth.add_group') or + request.user.has_perm('auth.change_group') or + request.user.has_perm('auth.delete_group') ) @@ -81,9 +81,9 @@ def register_permissions(): class UsersSearchArea(SearchArea): def is_shown(self, request): return ( - request.user.has_perm(add_user_perm) - or request.user.has_perm(change_user_perm) - or request.user.has_perm(delete_user_perm) + request.user.has_perm(add_user_perm) or + request.user.has_perm(change_user_perm) or + request.user.has_perm(delete_user_perm) )