fix SiteAffilation roles transfer
This commit is contained in:
parent
306b189725
commit
e6dfa6d74d
|
|
@ -70,10 +70,12 @@ class Command(BaseCommand):
|
|||
role_choice = getattr(Role, old_role.new_role)
|
||||
sites = SiteSettings.objects.filter(old_id=s.site_id)
|
||||
for site in sites:
|
||||
role = Role.objects.filter(site=site, role=role_choice)
|
||||
data = {'site': site, 'role': role_choice}
|
||||
|
||||
role = Role.objects.filter(**data)
|
||||
if not role.exists():
|
||||
objects.append(
|
||||
Role(site=site, role=role_choice)
|
||||
Role(**data)
|
||||
)
|
||||
|
||||
Role.objects.bulk_create(objects)
|
||||
|
|
@ -114,8 +116,7 @@ class Command(BaseCommand):
|
|||
users = User.objects.filter(old_id=s.account_id)
|
||||
for user in users:
|
||||
for role in roles:
|
||||
user_role = UserRole.objects.get_or_create(user=user,
|
||||
role=role)
|
||||
UserRole.objects.get_or_create(user=user, role=role, state=UserRole.VALIDATED)
|
||||
self.stdout.write(self.style.WARNING(f'Added users roles.'))
|
||||
|
||||
def superuser_role_sql(self):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user