Compare commits
2 Commits
4d82c76fbd
...
fce719aca1
Author | SHA1 | Date |
---|---|---|
Ales (Shagi) Zabala Alava | fce719aca1 | |
Ales (Shagi) Zabala Alava | af773a0afd |
|
@ -1,6 +1,11 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
0.8.10
|
||||
-----
|
||||
|
||||
* New templatetag to check if user has role
|
||||
|
||||
0.8.9
|
||||
-----
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ from django import template
|
|||
from django.utils.html import mark_safe
|
||||
|
||||
from ..sites import site
|
||||
from ..models import UserRole
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
@ -59,3 +60,10 @@ def pagination(request, page):
|
|||
@register.filter
|
||||
def to_json(data):
|
||||
return mark_safe(json.dumps(data))
|
||||
|
||||
|
||||
@register.filter
|
||||
def has_role(user, role):
|
||||
if user.is_superuser:
|
||||
return True
|
||||
return UserRole.objects.filter(role__in=(role, "admins"), user=user).exists()
|
||||
|
|
Loading…
Reference in New Issue