1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2025-01-26 07:05:19 +00:00
webvirtcloud/accounts/migrations/0004_apply_change_password.py
Real-Gecko a62daad87b Added change password permission
Replaces SHOW_PROFILE_EDIT_PASSWORD option
Can be set on per user or per group basis
2020-05-27 18:46:37 +06:00

25 lines
700 B
Python

from django.db import migrations
def apply_change_password(apps, schema_editor):
from django.conf import settings
from django.contrib.auth.models import User, Permission
if hasattr(settings, 'SHOW_PROFILE_EDIT_PASSWORD'):
if settings.SHOW_PROFILE_EDIT_PASSWORD:
permission = Permission.objects.get(codename='change_password')
users = User.objects.all()
user: User
for user in users:
user.user_permissions.add(permission)
class Migration(migrations.Migration):
dependencies = [
('accounts', '0003_permissionset'),
]
operations = [
migrations.RunPython(apply_change_password),
]