You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
870 B
Python
31 lines
870 B
Python
from django.db import migrations
|
|
|
|
|
|
def grant_admin_permissions(apps, schema_editor):
|
|
User = apps.get_model('api', 'User')
|
|
User.objects.filter(is_admin=True).update(
|
|
can_measure=True,
|
|
can_manually_measure=True,
|
|
can_manage_entities=True,
|
|
can_edit_documents=True,
|
|
)
|
|
# Also cover accounts created via createsuperuser (is_superuser=True but is_admin not set)
|
|
User.objects.filter(is_superuser=True).update(
|
|
is_admin=True,
|
|
can_measure=True,
|
|
can_manually_measure=True,
|
|
can_manage_entities=True,
|
|
can_edit_documents=True,
|
|
)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('api', '0004_user_can_edit_documents_user_can_manage_entities_and_more'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(grant_admin_permissions, migrations.RunPython.noop),
|
|
]
|