Created
December 10, 2017 20:42
-
-
Save umutcoskun/72fafb7c80f38b00c6f1e14ee5a99064 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def has_permission(permission): | |
def decorator(func): | |
from functools import wraps | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
user = kwargs.get('user') | |
assert permission in user.permissions | |
result = func(*args, **kwargs) | |
return result | |
return wrapper | |
return decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment