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

removed unnecessary code

parent b9797d8d
No related branches found
No related tags found
1 merge request!192Feature/add way to change password and PERMISSIONS
Pipeline #7587 passed
......@@ -62,7 +62,7 @@ class PermissionDecorator:
@staticmethod
def get_permissions():
if PermissionDecorator.permissions_queryset is None and len(PermissionDecorator.codenames) > 0:
if PermissionDecorator.permissions_queryset is None or len(PermissionDecorator.codenames) > len(PermissionDecorator.permissions_queryset):
PermissionDecorator.permissions_queryset = Permission.objects.filter(codename__in=PermissionDecorator.codenames)
return PermissionDecorator.permissions_queryset
......@@ -81,21 +81,6 @@ class PermissionDecorator:
#variables to be used on decorator call
self.perm_codename = perm_codename
# since the decorators are executed during code interpretation, we need to avoid executing
# the rest of the code if we are in the process of ./manage migrate or makemigrations
# since Permission won't be already migrated
if is_django_migrating():
return
query_result = Permission.objects.filter(codename=perm_codename)
if len(query_result) < 0:
logger.warn('Codename {} used in PermissionDecorator does not exist.'.format(perm_codename))
raise ValueError
if query_result[0].id not in PermissionDecorator.permission_ids: #avoid re-query if the permissions remain the same
PermissionDecorator.permission_ids.add(query_result[0].id)
PermissionDecorator.permissions_queryset = Permission.objects.filter(id__in=PermissionDecorator.permission_ids).all()
def __call__(self, func):
'''
This method is also called when the function is decorated
......
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