blob: 6ad695dca5aa1991ed0a3e52daa7d97f4212cdc9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# Generated by Django 2.2.28 on 2024-11-12 17:12
from django.db import migrations
def clean_permissions(app, __):
Group = app.get_model("auth", "group")
for group in Group.objects.filter(permissions__codename__startswith="add_own_").all():
if group.permissions.exclude(
codename__startswith="add_own_").count():
# other groups, only remove "own"
for own_grp in group.permissions.filter(
codename__startswith="add_own_").all():
group.permissions.remove(own_grp)
continue
for user in group.user_set.all():
user.groups.remove(group)
for pt in group.profile_types.all():
pt.groups.remove(group)
group.delete()
class Migration(migrations.Migration):
dependencies = [
('ishtar_common', '0255_migrate_delete_perm_clean_groups'),
]
operations = [
migrations.RunPython(clean_permissions)
]
|