You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rules.py files with the predicate and permission(add_perm)
views.py with import rules.py
when I use permission_required, it always return True, when I test the function(predicate) in the views for see the result with print, it's good but permission_required don't work.
ex:
If I have rules.py:
@rules.predicate
def is_author(user, book):
return book.author == user
rules.add_perm('edit_book', is_author)
if I used @permission_required('edit_book', fn=objectgetter(Book, 'id') it doesn't work but if I use in the views: is_author(object_user, object_book) it's work.
The text was updated successfully, but these errors were encountered:
I look in the views.py files of rules, I modify it with print to see the result of the condition :
if not user.has_perms(perms, obj) always return False(has_perm always return True).
(sorry for my english)
Information:
Django 1.9
Settings:
AUTHENTICATION_BACKENDS = (
)
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rules.apps.AutodiscoverRulesConfig',
'debug_toolbar',
]
rules.py files with the predicate and permission(add_perm)
views.py with import rules.py
when I use permission_required, it always return True, when I test the function(predicate) in the views for see the result with print, it's good but permission_required don't work.
ex:
If I have rules.py:
@rules.predicate
def is_author(user, book):
return book.author == user
rules.add_perm('edit_book', is_author)
if I used @permission_required('edit_book', fn=objectgetter(Book, 'id') it doesn't work but if I use in the views: is_author(object_user, object_book) it's work.
The text was updated successfully, but these errors were encountered: