Add fix_people_resource_role
This commit is contained in:
parent
0832517b92
commit
d41c0ccdce
1 changed files with 16 additions and 0 deletions
16
app/management/commands/fix_people_resource_role.py
Normal file
16
app/management/commands/fix_people_resource_role.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
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()
|
||||
role_map = {r.role: r.id for r in roles}
|
||||
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")
|
Loading…
Reference in a new issue