Skip to content

Commit

Permalink
add is_authenticated compatibility django 1.10+
Browse files Browse the repository at this point in the history
  • Loading branch information
khasanovbi committed Aug 25, 2016
1 parent ac63187 commit a58158e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions reversion/compat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import django


def remote_field(field):
# remote_field is new in Django 1.9
return field.remote_field if hasattr(field, 'remote_field') else field.rel
Expand All @@ -6,3 +9,9 @@ def remote_field(field):
def remote_model(field):
# remote_field is new in Django 1.9
return field.remote_field.model if hasattr(field, 'remote_field') else field.rel.to


def is_authenticated(user):
if django.VERSION < (1, 10):
return user.is_authenticated()
return user.is_authenticated
4 changes: 3 additions & 1 deletion reversion/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from functools import wraps

from reversion.compat import is_authenticated
from reversion.revisions import create_revision as create_revision_base, set_user


Expand All @@ -7,7 +9,7 @@ def _request_creates_revision(request):


def _set_user_from_request(request):
if hasattr(request, "user") and request.user.is_authenticated():
if hasattr(request, "user") and is_authenticated(request.user):
set_user(request.user)


Expand Down

0 comments on commit a58158e

Please sign in to comment.