0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Fix W503 warnings

This commit is contained in:
Karl Hobley 2016-01-27 11:37:19 +00:00 committed by Matt Westcott
parent ae957be7ed
commit 0cf59107a7
8 changed files with 34 additions and 34 deletions

View File

@ -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)

View File

@ -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')
)

View File

@ -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:

View File

@ -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]
)
)

View File

@ -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:

View File

@ -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:

View File

@ -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

View File

@ -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)
)