From c1e3d34b84ac5e61cd6fc0b915e9000955eee652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Sun, 15 Apr 2018 23:52:24 +0000 Subject: [PATCH] Fix : migration for renaming permission Srv.view_soa to Srv.view_srv --- .../migrations/0079_auto_20180416_0107.py | 36 +++++++++++++++++++ machines/models.py | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 machines/migrations/0079_auto_20180416_0107.py diff --git a/machines/migrations/0079_auto_20180416_0107.py b/machines/migrations/0079_auto_20180416_0107.py new file mode 100644 index 00000000..df73f74b --- /dev/null +++ b/machines/migrations/0079_auto_20180416_0107.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2018-04-15 23:07 +from __future__ import unicode_literals + +from django.db import migrations + +def rename_permission_soa_to_srv(apps, schema_editor): + Permission = apps.get_model('auth', 'Permission') + # The Permission called 'view_soa' but in the Srv object + try: + to_rename = Permission.objects.get( + codename='view_soa', + content_type__model='srv' + ) + except Permission.DoesNotExist: + # The permission is missing so no problem + pass + else: + to_rename.name = 'Peut voir un object srv' + to_rename.codename = 'view_srv' + to_rename.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('machines', '0078_auto_20180415_1252'), + ] + + operations = [ + migrations.RunPython(rename_permission_soa_to_srv), + migrations.AlterModelOptions( + name='srv', + options={'permissions': (('view_srv', 'Peut voir un objet srv'),)}, + ), + ] diff --git a/machines/models.py b/machines/models.py index 4282d1f5..9ed973f2 100644 --- a/machines/models.py +++ b/machines/models.py @@ -698,7 +698,7 @@ class Srv(RevMixin, AclMixin, models.Model): class Meta: permissions = ( - ("view_soa", "Peut voir un objet soa"), + ("view_srv", "Peut voir un objet srv"), ) def __str__(self):