Files
mayan-edms/mayan/apps/permissions/management/commands/purgepermissions.py
Roberto Rosario 23ffecdd30 Simplify permission lookup method. Add refresh class method to make sure
stored permissions are in sync with proxy permission.
Add __repr__ method.
2017-01-15 23:55:16 -04:00

21 lines
601 B
Python

from __future__ import unicode_literals
from django.core.management.base import BaseCommand
from ...classes import Permission
from ...models import StoredPermission
class Command(BaseCommand):
help = 'Remove obsolete permissions from the database'
def handle(self, *args, **options):
for permission in StoredPermission.objects.all():
try:
Permission.get(
pk='{}.{}'.format(permission.namespace, permission.name),
proxy_only=True
)
except KeyError:
permission.delete()