8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 15:33:45 +00:00
re2o/users/migrations/0068_auto_20180107_2245.py

61 lines
2 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-01-07 21:45
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [("users", "0067_serveurpermission")]
def transfer_permissions(apps, schema_editor):
critical_rights = [
"adm",
"admin",
"bureau",
"infra",
"tresorier",
"serveur",
"bofh",
]
db_alias = schema_editor.connection.alias
rights = apps.get_model("users", "ListRight")
for right in critical_rights:
rg = rights.objects.using(db_alias).filter(unix_name=right).first()
2018-01-20 15:23:42 +00:00
if rg:
rg.critical = True
2018-01-20 15:23:42 +00:00
rg.save()
def untransfer_permissions(apps, schema_editor):
return
operations = [
migrations.AlterModelOptions(
name="user",
options={
"permissions": (
("change_user_password", "Peut changer le mot de passe d'un user"),
("change_user_state", "Peut éditer l'etat d'un user"),
("change_user_force", "Peut forcer un déménagement"),
("change_user_shell", "Peut éditer le shell d'un user"),
(
"change_user_groups",
"Peut éditer les groupes d'un user ! Permission critique",
),
(
"change_all_users",
"Peut éditer tous les users, y compris ceux dotés de droits. Superdroit",
),
("view_user", "Peut voir un objet user quelquonque"),
)
},
),
migrations.AddField(
model_name="listright",
name="critical",
field=models.BooleanField(default=False),
),
migrations.RunPython(transfer_permissions, untransfer_permissions),
]