mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-30 16:42:25 +00:00
Fix : migration for renaming permission Srv.view_soa to Srv.view_srv
This commit is contained in:
parent
79f4f8051a
commit
c1e3d34b84
2 changed files with 37 additions and 1 deletions
36
machines/migrations/0079_auto_20180416_0107.py
Normal file
36
machines/migrations/0079_auto_20180416_0107.py
Normal file
|
@ -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'),)},
|
||||||
|
),
|
||||||
|
]
|
|
@ -698,7 +698,7 @@ class Srv(RevMixin, AclMixin, models.Model):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
permissions = (
|
permissions = (
|
||||||
("view_soa", "Peut voir un objet soa"),
|
("view_srv", "Peut voir un objet srv"),
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
Loading…
Reference in a new issue