mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-26 22:52:26 +00:00
246 lines
7 KiB
Python
246 lines
7 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Generated by Django 1.10.7 on 2017-12-31 19:53
|
|
from __future__ import unicode_literals
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('users', '0065_auto_20171231_2053'),
|
|
('cotisations', '0028_auto_20171231_0007'),
|
|
('machines', '0071_auto_20171231_2100'),
|
|
('preferences', '0025_auto_20171231_2142'),
|
|
('topologie', '0033_auto_20171231_1743'),
|
|
]
|
|
def transfer_permissions(apps, schema_editor):
|
|
permission_groups = {'bofh': ['add_ban',
|
|
'change_ban',
|
|
'delete_ban',
|
|
'view_ban',
|
|
'add_club',
|
|
'change_club',
|
|
'delete_club',
|
|
'add_user',
|
|
'change_user',
|
|
'change_user_force',
|
|
'change_user_password',
|
|
'change_user_shell',
|
|
'view_user',
|
|
'add_whitelist',
|
|
'change_whitelist',
|
|
'delete_whitelist',
|
|
'view_whitelist'],
|
|
'bureau': ['add_logentry',
|
|
'change_logentry',
|
|
'delete_logentry',
|
|
'add_group',
|
|
'change_group',
|
|
'delete_group',
|
|
'add_permission',
|
|
'change_permission',
|
|
'delete_permission',
|
|
'add_adherent',
|
|
'change_adherent',
|
|
'delete_adherent',
|
|
'add_ban',
|
|
'change_ban',
|
|
'delete_ban',
|
|
'view_ban',
|
|
'add_club',
|
|
'change_club',
|
|
'delete_club',
|
|
'add_listright',
|
|
'change_listright',
|
|
'delete_listright',
|
|
'view_listright',
|
|
'add_school',
|
|
'change_school',
|
|
'delete_school',
|
|
'view_school',
|
|
'add_user',
|
|
'change_user',
|
|
'change_user_force',
|
|
'change_user_groups',
|
|
'change_user_password',
|
|
'change_user_shell',
|
|
'change_user_state',
|
|
'delete_user',
|
|
'view_user',
|
|
'add_whitelist',
|
|
'change_whitelist',
|
|
'delete_whitelist',
|
|
'view_whitelist'],
|
|
'cableur': ['add_logentry',
|
|
'view_article',
|
|
'add_banque',
|
|
'change_banque',
|
|
'delete_banque',
|
|
'view_banque',
|
|
'add_cotisation',
|
|
'change_cotisation',
|
|
'delete_cotisation',
|
|
'view_cotisation',
|
|
'add_facture',
|
|
'can_create',
|
|
'can_delete',
|
|
'can_edit',
|
|
'can_view',
|
|
'can_view_all',
|
|
'change_facture',
|
|
'delete_facture',
|
|
'view_facture',
|
|
'view_paiement',
|
|
'add_vente',
|
|
'change_vente',
|
|
'delete_vente',
|
|
'view_vente',
|
|
'add_domain',
|
|
'change_domain',
|
|
'delete_domain',
|
|
'view_domain',
|
|
'use_all_extension',
|
|
'view_extension',
|
|
'add_interface',
|
|
'change_interface',
|
|
'delete_interface',
|
|
'view_interface',
|
|
'view_iplist',
|
|
'view_iptype',
|
|
'add_machine',
|
|
'change_machine',
|
|
'view_machine',
|
|
'view_machinetype',
|
|
'view_mx',
|
|
'view_nas',
|
|
'view_ns',
|
|
'view_ouvertureportlist',
|
|
'view_service',
|
|
'view_soa',
|
|
'view_soa',
|
|
'view_txt',
|
|
'view_vlan',
|
|
'view_assooption',
|
|
'view_generaloption',
|
|
'view_mailmessageoption',
|
|
'view_optionalmachine',
|
|
'view_optionaltopologie',
|
|
'view_optionaluser',
|
|
'view_service',
|
|
'view_constructorswitch',
|
|
'view_modelswitch',
|
|
'view_port',
|
|
'view_room',
|
|
'view_stack',
|
|
'view_switch',
|
|
'add_adherent',
|
|
'change_adherent',
|
|
'view_ban',
|
|
'add_club',
|
|
'change_club',
|
|
'view_listright',
|
|
'add_school',
|
|
'change_school',
|
|
'delete_school',
|
|
'view_school',
|
|
'view_serviceuser',
|
|
'add_user',
|
|
'change_user',
|
|
'change_user_force',
|
|
'change_user_password',
|
|
'view_user',
|
|
'add_whitelist',
|
|
'change_whitelist',
|
|
'delete_whitelist',
|
|
'view_whitelist'],
|
|
'tresorier': ['add_article',
|
|
'change_article',
|
|
'delete_article',
|
|
'view_article',
|
|
'add_banque',
|
|
'change_banque',
|
|
'delete_banque',
|
|
'view_banque',
|
|
'add_cotisation',
|
|
'change_all_cotisation',
|
|
'change_cotisation',
|
|
'delete_cotisation',
|
|
'view_cotisation',
|
|
'add_facture',
|
|
'can_change_control',
|
|
'can_change_pdf',
|
|
'can_create',
|
|
'can_delete',
|
|
'can_edit',
|
|
'can_view',
|
|
'can_view_all',
|
|
'change_all_facture',
|
|
'change_facture',
|
|
'change_facture_control',
|
|
'change_facture_pdf',
|
|
'delete_facture',
|
|
'view_facture',
|
|
'add_paiement',
|
|
'change_paiement',
|
|
'delete_paiement',
|
|
'view_paiement',
|
|
'add_vente',
|
|
'change_all_vente',
|
|
'change_vente',
|
|
'delete_vente',
|
|
'view_vente'],
|
|
'admin': ['add_logentry',
|
|
'change_logentry',
|
|
'delete_logentry',
|
|
'add_assooption',
|
|
'change_assooption',
|
|
'delete_assooption',
|
|
'view_assooption',
|
|
'add_generaloption',
|
|
'change_generaloption',
|
|
'delete_generaloption',
|
|
'view_generaloption',
|
|
'add_mailmessageoption',
|
|
'change_mailmessageoption',
|
|
'delete_mailmessageoption',
|
|
'view_mailmessageoption',
|
|
'add_optionalmachine',
|
|
'change_optionalmachine',
|
|
'delete_optionalmachine',
|
|
'view_optionalmachine',
|
|
'add_optionaltopologie',
|
|
'change_optionaltopologie',
|
|
'delete_optionaltopologie',
|
|
'view_optionaltopologie',
|
|
'add_optionaluser',
|
|
'change_optionaluser',
|
|
'delete_optionaluser',
|
|
'view_optionaluser',
|
|
'add_service',
|
|
'add_services',
|
|
'change_service',
|
|
'change_services',
|
|
'delete_service',
|
|
'delete_services',
|
|
'view_service']}
|
|
|
|
rights = apps.get_model("users", "ListRight")
|
|
permissions = apps.get_model("auth", "Permission")
|
|
db_alias = schema_editor.connection.alias
|
|
for group in permission_groups:
|
|
group_object = rights.objects.using(db_alias).filter(unix_name=group).first()
|
|
if group_object:
|
|
group_object = group_object.group_ptr
|
|
for permission in permission_groups[group]:
|
|
perm = permissions.objects.using(db_alias).filter(codename=permission).first()
|
|
if perm:
|
|
group_object.permissions.add(perm)
|
|
group_object.save()
|
|
|
|
def untransfer_permissions(apps, schema_editor):
|
|
return
|
|
|
|
operations = [
|
|
migrations.RunPython(transfer_permissions, untransfer_permissions),
|
|
]
|