2021-11-22 10:50:09 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from app.models import PeopleResource, Role
|
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = 'Fix roles'
|
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
prs = PeopleResource.objects.all()
|
|
|
|
roles = Role.objects.all()
|
2021-11-22 10:52:34 +00:00
|
|
|
role_map = {r.role: r for r in roles}
|
2021-11-22 10:50:09 +00:00
|
|
|
for pr in prs:
|
|
|
|
pr.p_r_role = role_map.get(pr.role, role_map.get(''))
|
|
|
|
pr.save()
|
|
|
|
print("Done %s -- %s -- %s -- %s" % (pr.id, pr.role, pr.resource, pr.person))
|
|
|
|
print("Done all")
|