mirror of
https://github.com/retspen/webvirtcloud
synced 2025-01-26 07:05:19 +00:00
a62daad87b
Replaces SHOW_PROFILE_EDIT_PASSWORD option Can be set on per user or per group basis
25 lines
700 B
Python
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),
|
|
]
|