Skip to content
Snippets Groups Projects
Commit bf279d6f authored by Carlos Vega's avatar Carlos Vega
Browse files

added option to provide a group and gather codenames together, useful to...

added option to provide a group and gather codenames together, useful to retrieve permissions from certain type such as those from configure stuff
parent 644f4f47
No related branches found
No related tags found
1 merge request!192Feature/add way to change password and PERMISSIONS
......@@ -8,6 +8,7 @@ from django.http import HttpResponseForbidden
from django.contrib.auth.models import Permission
import functools
from web.utils import is_django_migrating
from collections import defaultdict
logger = logging.getLogger(__name__)
......@@ -55,6 +56,7 @@ logger = logging.getLogger(__name__)
class PermissionDecorator:
codenames = set()
permission_ids = set()
codename_groups = defaultdict(set)
permissions_queryset = None
n_decorators = 0
......@@ -65,7 +67,7 @@ class PermissionDecorator:
return PermissionDecorator.permissions_queryset
def __init__(self, perm_codename):
def __init__(self, perm_codename, group=None):
'''
This method is called when the code is interpreted, this is, when a function is decorated
because an instance of the decorator is created.
......@@ -73,6 +75,9 @@ class PermissionDecorator:
PermissionDecorator.codenames.add(perm_codename) #register permission codename
PermissionDecorator.n_decorators += 1 #count number of decorators
if group is not None:
PermissionDecorator.codename_groups[group].add(perm_codename)
#variables to be used on decorator call
self.perm_codename = perm_codename
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment