2018-01-07 22:55:27 +00:00
|
|
|
# -*- 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):
|
|
|
|
|
2019-11-04 16:55:03 +00:00
|
|
|
dependencies = [("users", "0067_serveurpermission")]
|
2018-01-07 22:55:27 +00:00
|
|
|
|
|
|
|
def transfer_permissions(apps, schema_editor):
|
2019-11-04 16:55:03 +00:00
|
|
|
critical_rights = [
|
|
|
|
"adm",
|
|
|
|
"admin",
|
|
|
|
"bureau",
|
|
|
|
"infra",
|
|
|
|
"tresorier",
|
|
|
|
"serveur",
|
|
|
|
"bofh",
|
|
|
|
]
|
2018-01-07 22:55:27 +00:00
|
|
|
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:
|
2019-11-04 16:55:03 +00:00
|
|
|
rg.critical = True
|
2018-01-20 15:23:42 +00:00
|
|
|
rg.save()
|
2018-01-07 22:55:27 +00:00
|
|
|
|
|
|
|
def untransfer_permissions(apps, schema_editor):
|
|
|
|
return
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.AlterModelOptions(
|
2019-11-04 16:55:03 +00:00
|
|
|
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"),
|
|
|
|
)
|
|
|
|
},
|
2018-01-07 22:55:27 +00:00
|
|
|
),
|
|
|
|
migrations.AddField(
|
2019-11-04 16:55:03 +00:00
|
|
|
model_name="listright",
|
|
|
|
name="critical",
|
2018-01-07 22:55:27 +00:00
|
|
|
field=models.BooleanField(default=False),
|
|
|
|
),
|
|
|
|
migrations.RunPython(transfer_permissions, untransfer_permissions),
|
|
|
|
]
|