2018-06-27 12:21:20 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.db import migrations
|
|
|
|
|
2019-11-04 16:55:03 +00:00
|
|
|
|
2018-06-27 12:21:20 +00:00
|
|
|
def remove_permission_alias(apps, schema_editor):
|
2019-11-04 16:55:03 +00:00
|
|
|
Permission = apps.get_model("auth", "Permission")
|
|
|
|
for codename in ["add_alias", "change_alias", "delete_alias"]:
|
2018-06-27 12:21:20 +00:00
|
|
|
# Retrieve the wrong permission
|
|
|
|
try:
|
|
|
|
to_remove = Permission.objects.get(
|
2019-11-04 16:55:03 +00:00
|
|
|
codename=codename, content_type__model="domain"
|
2018-06-27 12:21:20 +00:00
|
|
|
)
|
|
|
|
except Permission.DoesNotExist:
|
|
|
|
# The permission is missing so no problem
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
to_remove.delete()
|
|
|
|
|
|
|
|
|
|
|
|
def remove_permission_text(apps, schema_editor):
|
2019-11-04 16:55:03 +00:00
|
|
|
Permission = apps.get_model("auth", "Permission")
|
|
|
|
for codename in ["add_text", "change_text", "delete_text"]:
|
2018-06-27 12:21:20 +00:00
|
|
|
# Retrieve the wrong permission
|
|
|
|
try:
|
|
|
|
to_remove = Permission.objects.get(
|
2019-11-04 16:55:03 +00:00
|
|
|
codename=codename, content_type__model="txt"
|
2018-06-27 12:21:20 +00:00
|
|
|
)
|
|
|
|
except Permission.DoesNotExist:
|
|
|
|
# The permission is missing so no problem
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
to_remove.delete()
|
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
2019-11-04 16:55:03 +00:00
|
|
|
dependencies = [("machines", "0082_auto_20180525_2209")]
|
2018-06-27 12:21:20 +00:00
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(remove_permission_text),
|
|
|
|
migrations.RunPython(remove_permission_alias),
|
|
|
|
]
|