mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-17 19:51:11 +00:00
Remove obsolete compat functions
This commit is contained in:
parent
67b1ddb665
commit
e3f968a154
6 changed files with 10 additions and 28 deletions
|
|
@ -1,13 +1 @@
|
|||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import django
|
||||
|
||||
|
||||
# TODO: This compat function is now obsolete
|
||||
def user_is_authenticated(user):
|
||||
return user.is_authenticated
|
||||
|
||||
|
||||
# TODO: This compat function is now obsolete
|
||||
def user_is_anonymous(user):
|
||||
return user.is_anonymous
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ from django.core.urlresolvers import reverse
|
|||
from django.utils.translation import activate as activate_lang
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from wagtail.utils.compat import user_is_anonymous
|
||||
from wagtail.wagtailadmin import messages
|
||||
|
||||
|
||||
|
|
@ -22,7 +21,7 @@ def require_admin_access(view_func):
|
|||
def decorated_view(request, *args, **kwargs):
|
||||
user = request.user
|
||||
|
||||
if user_is_anonymous(user):
|
||||
if user.is_anonymous:
|
||||
return reject_request(request)
|
||||
|
||||
if user.has_perms(['wagtailadmin.access_admin']):
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ from django.utils.translation import activate
|
|||
from django.views.decorators.cache import never_cache
|
||||
from django.views.decorators.debug import sensitive_post_parameters
|
||||
|
||||
from wagtail.utils.compat import user_is_authenticated
|
||||
from wagtail.wagtailadmin import forms
|
||||
from wagtail.wagtailadmin.utils import get_available_admin_languages
|
||||
from wagtail.wagtailcore.models import UserPagePermissionsProxy
|
||||
|
|
@ -132,7 +131,7 @@ def language_preferences(request):
|
|||
@sensitive_post_parameters()
|
||||
@never_cache
|
||||
def login(request):
|
||||
if user_is_authenticated(request.user) and request.user.has_perm('wagtailadmin.access_admin'):
|
||||
if request.user.is_authenticated and request.user.has_perm('wagtailadmin.access_admin'):
|
||||
return redirect('wagtailadmin_home')
|
||||
else:
|
||||
from django.contrib.auth import get_user_model
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ from django.utils.translation import ugettext_lazy as _
|
|||
from modelcluster.models import ClusterableModel, get_all_child_relations
|
||||
from treebeard.mp_tree import MP_Node
|
||||
|
||||
from wagtail.utils.compat import user_is_authenticated
|
||||
from wagtail.wagtailcore.query import PageQuerySet, TreeQuerySet
|
||||
from wagtail.wagtailcore.signals import page_published, page_unpublished
|
||||
from wagtail.wagtailcore.sites import get_site_for_hostname
|
||||
|
|
@ -1878,7 +1877,7 @@ class BaseViewRestriction(models.Model):
|
|||
return False
|
||||
|
||||
elif self.restriction_type == BaseViewRestriction.LOGIN:
|
||||
if not user_is_authenticated(request.user):
|
||||
if not request.user.is_authenticated:
|
||||
return False
|
||||
|
||||
elif self.restriction_type == BaseViewRestriction.GROUPS:
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ from django.core.exceptions import FieldDoesNotExist, ImproperlyConfigured
|
|||
from django.db.models import Q
|
||||
from django.utils.functional import cached_property
|
||||
|
||||
from wagtail.utils.compat import user_is_authenticated
|
||||
|
||||
|
||||
class BasePermissionPolicy(object):
|
||||
"""
|
||||
|
|
@ -151,10 +149,10 @@ class AuthenticationOnlyPermissionPolicy(BasePermissionPolicy):
|
|||
full permission over the given model
|
||||
"""
|
||||
def user_has_permission(self, user, action):
|
||||
return user_is_authenticated(user) and user.is_active
|
||||
return user.is_authenticated and user.is_active
|
||||
|
||||
def user_has_any_permission(self, user, actions):
|
||||
return user_is_authenticated(user) and user.is_active
|
||||
return user.is_authenticated and user.is_active
|
||||
|
||||
def users_with_any_permission(self, actions):
|
||||
return get_user_model().objects.filter(is_active=True)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from django.contrib.auth.models import Group, Permission
|
|||
from django.core.exceptions import FieldDoesNotExist, ImproperlyConfigured
|
||||
from django.db.models import Q
|
||||
|
||||
from wagtail.utils.compat import user_is_authenticated
|
||||
from wagtail.wagtailcore.models import Collection, GroupCollectionPermission
|
||||
|
||||
from .base import BaseDjangoAuthPermissionPolicy
|
||||
|
|
@ -29,7 +28,7 @@ class CollectionPermissionLookupMixin(object):
|
|||
If collection is specified, only consider GroupCollectionPermission records
|
||||
that apply to that collection.
|
||||
"""
|
||||
if not (user.is_active and user_is_authenticated(user)):
|
||||
if not (user.is_active and user.is_authenticated):
|
||||
return False
|
||||
|
||||
if user.is_superuser:
|
||||
|
|
@ -165,7 +164,7 @@ class CollectionPermissionPolicy(CollectionPermissionLookupMixin, BaseDjangoAuth
|
|||
Return a queryset of all instances of this model for which the given user has
|
||||
permission to perform any of the given actions
|
||||
"""
|
||||
if not (user.is_active and user_is_authenticated(user)):
|
||||
if not (user.is_active and user.is_authenticated):
|
||||
return self.model.objects.none()
|
||||
elif user.is_superuser:
|
||||
return self.model.objects.all()
|
||||
|
|
@ -192,7 +191,7 @@ class CollectionPermissionPolicy(CollectionPermissionLookupMixin, BaseDjangoAuth
|
|||
# in any collection
|
||||
return Collection.objects.all()
|
||||
|
||||
elif not user_is_authenticated(user):
|
||||
elif not user.is_authenticated:
|
||||
return Collection.objects.none()
|
||||
|
||||
else:
|
||||
|
|
@ -275,7 +274,7 @@ class CollectionOwnershipPermissionPolicy(
|
|||
# active superusers can perform any action (including unrecognised ones)
|
||||
# on any instance
|
||||
return self.model.objects.all()
|
||||
elif not user_is_authenticated(user):
|
||||
elif not user.is_authenticated:
|
||||
return self.model.objects.none()
|
||||
elif 'change' in actions or 'delete' in actions:
|
||||
# return instances which are:
|
||||
|
|
@ -333,7 +332,7 @@ class CollectionOwnershipPermissionPolicy(
|
|||
# in any collection
|
||||
return Collection.objects.all()
|
||||
|
||||
elif not user_is_authenticated(user):
|
||||
elif not user.is_authenticated:
|
||||
return Collection.objects.none()
|
||||
|
||||
elif 'change' in actions or 'delete' in actions:
|
||||
|
|
|
|||
Loading…
Reference in a new issue