django 1.11: adapt migration and model (#21489)

This commit is contained in:
Emmanuel Cazenave 2018-07-31 14:04:31 +02:00 committed by Frédéric Péters
parent c6e2632fbc
commit f1668b2bfb
5 changed files with 8 additions and 5 deletions

View File

@ -33,3 +33,6 @@ class Authentic2RBACConfig(AppConfig):
post_migrate.connect(
signal_handlers.create_default_permissions,
sender=self)
post_migrate.connect(
signal_handlers.post_migrate_update_rbac,
sender=self)

View File

@ -125,7 +125,3 @@ def update_content_types_roles():
ct_admin_role.permissions.add(view_user_perm)
ct_admin_role.permissions.add(search_ou_perm)
ct_admin_role.add_child(admin_role)
post_migrate.connect(
signal_handlers.post_migrate_update_rbac,
sender=apps.get_app_config('a2_rbac'))

View File

@ -13,6 +13,8 @@ class ThirdPartyAlterField(migrations.AlterField):
super(ThirdPartyAlterField, self).state_forwards(self.app_label, state)
def database_forwards(self, app_label, schema_editor, from_state, to_state):
if hasattr(from_state, 'clear_delayed_apps_cache'):
from_state.clear_delayed_apps_cache()
super(ThirdPartyAlterField, self).database_forwards(self.app_label,
schema_editor, from_state, to_state)

View File

@ -44,6 +44,8 @@ class CreatePartialIndexes(Operation):
pass
def database_forwards(self, app_label, schema_editor, from_state, to_state):
if hasattr(from_state, 'clear_delayed_apps_cache'):
from_state.clear_delayed_apps_cache()
if not self.allowed(app_label, schema_editor, to_state):
return
for i, (where, non_null_columns) in enumerate(self.indexes()):

View File

@ -125,7 +125,7 @@ Operation._meta.natural_key = ['slug']
class PermissionAbstractBase(models.Model):
operation = models.ForeignKey(
to='Operation',
to=Operation,
verbose_name=_('operation'))
ou = models.ForeignKey(
to=utils.get_ou_model_name(),