Skip to content

Commit

Permalink
Merge pull request #881 from davboecki/patch-1
Browse files Browse the repository at this point in the history
Fix migration 0014 not working on live data.
  • Loading branch information
evgenyfadeev authored Dec 20, 2020
2 parents 9c143a4 + 1c512ef commit b6cb737
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion askbot/migrations/0014_populate_askbot_roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
def populate_askbot_roles(apps, schema_editor):
Role = apps.get_model('askbot', 'Role')
UserProfile = apps.get_model('askbot', 'UserProfile')
User = apps.get_model('auth', 'User')
profiles = UserProfile.objects.filter(status__in=('m', 'd'))
count = profiles.count()
message = 'Assigning roles {} to the admins and the moderators'
message = message.format(', '.join(MOD_ROLES + ADMIN_ROLES))
for profile in ProgressBar(profiles.iterator(), count, message):
user = profile.auth_user_ptr
user_id = profile.auth_user_ptr_id
user = User.objects.filter(id=user_id)[0]
if profile.status == 'd':
for role in ADMIN_ROLES + MOD_ROLES:
Role.objects.create(user=user, role=role)
Expand Down

0 comments on commit b6cb737

Please sign in to comment.