From bed39b80a905748ba39fad9d53ec6ddc696b54bb Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Fri, 5 Apr 2019 13:55:02 +0200 Subject: [PATCH] is_authenticated now as attribute (method is deprecated in Django 2) --- colleges/permissions.py | 4 ++-- notifications/views.py | 4 ++-- petitions/forms.py | 2 +- production/permissions.py | 2 +- scipost/decorators.py | 2 +- scipost/views.py | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/colleges/permissions.py b/colleges/permissions.py index 3ded6a384..f6631d518 100644 --- a/colleges/permissions.py +++ b/colleges/permissions.py @@ -9,7 +9,7 @@ from django.core.exceptions import PermissionDenied def fellowship_required(): """Require user to have any Fellowship or Administrational permissions.""" def test(u): - if u.is_authenticated(): + if u.is_authenticated: if hasattr(u, 'contributor') and u.contributor.fellowships.exists(): # Fellow return True @@ -20,7 +20,7 @@ def fellowship_required(): def fellowship_or_admin_required(): """Require user to have any Fellowship or Administrational permissions.""" def test(u): - if u.is_authenticated(): + if u.is_authenticated: if hasattr(u, 'contributor') and u.contributor.fellowships.exists(): # Fellow return True diff --git a/notifications/views.py b/notifications/views.py index a98a37183..7cfdfc817 100644 --- a/notifications/views.py +++ b/notifications/views.py @@ -56,7 +56,7 @@ def mark_toggle(request, slug=None): def live_unread_notification_count(request): """Return JSON of unread messages count.""" - if not request.user.is_authenticated(): + if not request.user.is_authenticated: data = {'unread_count': 0} else: data = {'unread_count': request.user.notifications.unread().count()} @@ -65,7 +65,7 @@ def live_unread_notification_count(request): def live_notification_list(request): """Return JSON of unread count and content of messages.""" - # if not request.user.is_authenticated(): + # if not request.user.is_authenticated: # data = { # 'unread_count': 0, # 'list': [] diff --git a/petitions/forms.py b/petitions/forms.py index f72c516bd..94ab04f01 100644 --- a/petitions/forms.py +++ b/petitions/forms.py @@ -30,7 +30,7 @@ class SignPetitionForm(forms.ModelForm): if self.instance.id: return email - if self.current_user.is_authenticated(): + if self.current_user.is_authenticated: if self.current_user.email != email: self.add_error('email', 'This email address is not associated to your account') else: diff --git a/production/permissions.py b/production/permissions.py index 95723d4bf..456800860 100644 --- a/production/permissions.py +++ b/production/permissions.py @@ -8,7 +8,7 @@ from django.contrib.auth.decorators import user_passes_test def is_production_user(): """Requires user to be a ProductionUser.""" def test(u): - if u.is_authenticated(): + if u.is_authenticated: if hasattr(u, 'production_user') and u.production_user: return True return False diff --git a/scipost/decorators.py b/scipost/decorators.py index d45d9bc05..9c83af41d 100644 --- a/scipost/decorators.py +++ b/scipost/decorators.py @@ -19,7 +19,7 @@ def has_contributor(user): def is_contributor_user(): """Decorator checking if user is related to any Contributor.""" def test(u): - if u.is_authenticated(): + if u.is_authenticated: return has_contributor(u) return False return user_passes_test(test) diff --git a/scipost/views.py b/scipost/views.py index 68577519c..5dfae5e57 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -174,7 +174,7 @@ def register(request): sent. After activation the user needs to be vetted by the SciPost admin. """ - if request.user.is_authenticated(): + if request.user.is_authenticated: return redirect(reverse('scipost:personal_page')) form = RegistrationForm(request.POST or None) -- GitLab