those who can grant all permissions should have all of them
This commit is contained in:
parent
245c101eb0
commit
544b3dae2e
1 changed files with 8 additions and 2 deletions
|
@ -34,8 +34,6 @@ class AccessRestriction(TitledMixin, models.Model):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def q_for_request(cls, request):
|
def q_for_request(cls, request):
|
||||||
if request.user.is_authenticated and request.user.is_superuser:
|
|
||||||
return Q()
|
|
||||||
return Q(pk__in=AccessPermission.get_for_request(request))
|
return Q(pk__in=AccessPermission.get_for_request(request))
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,6 +156,14 @@ class AccessPermission(models.Model):
|
||||||
if not request.user.is_authenticated:
|
if not request.user.is_authenticated:
|
||||||
return set()
|
return set()
|
||||||
|
|
||||||
|
if request.user_permissions.grant_all_access:
|
||||||
|
cache_key = 'all_access_restrictions:%s' % MapUpdate.current_cache_key()
|
||||||
|
access_restriction_ids = cache.get(cache_key, None)
|
||||||
|
if access_restriction_ids is None:
|
||||||
|
access_restriction_ids = set(AccessRestriction.objects.values_list('pk', flat=True))
|
||||||
|
cache.set(cache_key, access_restriction_ids, 300)
|
||||||
|
return access_restriction_ids
|
||||||
|
|
||||||
cache_key = cls.user_access_permission_key(request.user.pk)
|
cache_key = cls.user_access_permission_key(request.user.pk)
|
||||||
access_restriction_ids = cache.get(cache_key, None)
|
access_restriction_ids = cache.get(cache_key, None)
|
||||||
if access_restriction_ids is None:
|
if access_restriction_ids is None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue