shift remaining permissions into apps

This commit is contained in:
Joel Falknau 2025-03-05 14:18:57 +10:00
parent d9f3b2c876
commit 83a41fb982
No known key found for this signature in database
8 changed files with 68 additions and 32 deletions

View File

@ -8,27 +8,6 @@ from django.db import migrations, models
import allianceauth.authentication.models
def create_permissions(apps, schema_editor):
User = apps.get_model('auth', 'User')
ContentType = apps.get_model('contenttypes', 'ContentType')
Permission = apps.get_model('auth', 'Permission')
ct = ContentType.objects.get_for_model(User)
# Permission.objects.get_or_create(codename="member", content_type=ct, name="member")
# Permission.objects.get_or_create(codename="jabber_broadcast", content_type=ct, name="jabber_broadcast")
# Permission.objects.get_or_create(codename="jabber_broadcast_all", content_type=ct, name="jabber_broadcast_all")
# Permission.objects.get_or_create(codename="fleetactivitytracking", content_type=ct, name="fleetactivitytracking")
# Permission.objects.get_or_create(codename="fleetactivitytracking_statistics", content_type=ct, name="fleetactivitytracking_statistics")
# Permission.objects.get_or_create(codename="signature_management", content_type=ct, name="signature_management")
# Permission.objects.get_or_create(codename="signature_view", content_type=ct, name="signature_view")
# Permission.objects.get_or_create(codename="optimer_management", content_type=ct, name="optimer_management")
# Permission.objects.get_or_create(codename="optimer_view", content_type=ct, name="optimer_view")
Permission.objects.get_or_create(codename="logging_notifications", content_type=ct, name="logging_notifications")
def create_permissions_reverse(apps, schema_editor) -> None:
pass
def create_states(apps, schema_editor) -> None:
State = apps.get_model('authentication', 'State')
@ -140,7 +119,6 @@ class Migration(migrations.Migration):
'ordering': ['-created'],
},
),
migrations.RunPython(create_permissions, create_permissions_reverse),
migrations.RunPython(create_states, create_states_reverse),
]

View File

@ -8,6 +8,20 @@ from django.db import migrations, models
import allianceauth.framework.api.user
def create_permissions(apps, schema_editor) -> None:
# Remnant of AAv0
User = apps.get_model('auth', 'User')
ContentType = apps.get_model('contenttypes', 'ContentType')
Permission = apps.get_model('auth', 'Permission')
ct = ContentType.objects.get_for_model(User)
Permission.objects.get_or_create(codename="fleetactivitytracking", content_type=ct, name="fleetactivitytracking")
Permission.objects.get_or_create(codename="fleetactivitytracking_statistics", content_type=ct, name="fleetactivitytracking_statistics")
def reverse(apps, schema_editor) -> None:
pass
class Migration(migrations.Migration):
replaces = [('fleetactivitytracking', '0001_initial'), ('fleetactivitytracking', '0002_auto_20160905_2220'), ('fleetactivitytracking', '0003_auto_20160906_2354'), ('fleetactivitytracking', '0004_make_strings_more_stringy'), ('fleetactivitytracking', '0005_remove_fat_name'), ('fleetactivitytracking', '0006_auto_20180803_0430'), ('fleetactivitytracking', '0007_sentinel_user')]
@ -46,4 +60,5 @@ class Migration(migrations.Migration):
'unique_together': {('character', 'fatlink')},
},
),
migrations.RunPython(create_permissions, reverse)
]

View File

@ -7,7 +7,8 @@ from django.conf import settings
from django.db import migrations, models
def create_permissions(apps, schema_editor):
def create_permissions(apps, schema_editor) -> None:
# Remnant of AAv0
User = apps.get_model('auth', 'User')
ContentType = apps.get_model('contenttypes', 'ContentType')
Permission = apps.get_model('auth', 'Permission')
@ -15,7 +16,7 @@ def create_permissions(apps, schema_editor):
Permission.objects.get_or_create(codename="group_management", content_type=ct, name="group_management")
def reverse(apps, schema_editor):
def reverse(apps, schema_editor) -> None:
pass

View File

@ -7,7 +7,8 @@ from django.conf import settings
from django.db import migrations, models
def create_permissions(apps, schema_editor):
def create_permissions(apps, schema_editor) -> None:
# Remnant of AAv0
User = apps.get_model('auth', 'User')
ContentType = apps.get_model('contenttypes', 'ContentType')
Permission = apps.get_model('auth', 'Permission')
@ -15,7 +16,7 @@ def create_permissions(apps, schema_editor):
Permission.objects.get_or_create(codename="human_resources", content_type=ct, name="human_resources")
def reverse(apps, schema_editor):
def reverse(apps, schema_editor) -> None:
pass

View File

@ -5,6 +5,19 @@ from django.conf import settings
from django.db import migrations, models
def create_permissions(apps, schema_editor) -> None:
# Remnant of AAv0
User = apps.get_model('auth', 'User')
ContentType = apps.get_model('contenttypes', 'ContentType')
Permission = apps.get_model('auth', 'Permission')
ct = ContentType.objects.get_for_model(User)
Permission.objects.get_or_create(codename="logging_notifications", content_type=ct, name="logging_notifications")
def reverse(apps, schema_editor) -> None:
pass
class Migration(migrations.Migration):
replaces = [('notifications', '0001_initial'), ('notifications', '0002_auto_20160910_1649'), ('notifications', '0003_make_strings_more_stringy'), ('notifications', '0004_performance_tuning'), ('notifications', '0005_fix_level_choices')]
@ -28,4 +41,5 @@ class Migration(migrations.Migration):
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.RunPython(create_permissions, reverse)
]

View File

@ -7,6 +7,20 @@ import django.utils.timezone
from django.db import migrations, models
def create_permissions(apps, schema_editor) -> None:
# Remnant of AAv0
User = apps.get_model('auth', 'User')
ContentType = apps.get_model('contenttypes', 'ContentType')
Permission = apps.get_model('auth', 'Permission')
ct = ContentType.objects.get_for_model(User)
Permission.objects.get_or_create(codename="optimer_management", content_type=ct, name="optimer_management")
Permission.objects.get_or_create(codename="optimer_view", content_type=ct, name="optimer_view")
def reverse(apps, schema_editor) -> None:
pass
class Migration(migrations.Migration):
replaces = [('optimer', '0001_initial'), ('optimer', '0002_auto_20170413_0442'), ('optimer', '0003_make_strings_more_stringy'), ('optimer', '0004_on_delete'), ('optimer', '0005_add_type_and_description')]
@ -49,4 +63,5 @@ class Migration(migrations.Migration):
'default_permissions': (),
},
),
migrations.RunPython(create_permissions, reverse)
]

View File

@ -5,10 +5,20 @@ import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
# Functions from the following migrations need manual copying.
# Move them and any dependencies into this file, then update the
# RunPython operations to refer to the local versions:
# allianceauth.services.modules.openfire.migrations.0002_service_permissions
def create_permissions(apps, schema_editor) -> None:
# Remnant of AAv0
User = apps.get_model('auth', 'User')
ContentType = apps.get_model('contenttypes', 'ContentType')
Permission = apps.get_model('auth', 'Permission')
ct = ContentType.objects.get_for_model(User)
Permission.objects.get_or_create(codename="jabber_broadcast", content_type=ct, name="jabber_broadcast")
Permission.objects.get_or_create(codename="jabber_broadcast_all", content_type=ct, name="jabber_broadcast_all")
def reverse(apps, schema_editor) -> None:
pass
class Migration(migrations.Migration):
@ -31,4 +41,5 @@ class Migration(migrations.Migration):
'permissions': (('access_openfire', 'Can access the Openfire service'),),
},
),
migrations.RunPython(create_permissions, reverse)
]

View File

@ -5,7 +5,8 @@ import django.utils.timezone
from django.db import migrations, models
def create_permissions(apps, schema_editor):
def create_permissions(apps, schema_editor) -> None:
# Remnant of AAv0
User = apps.get_model('auth', 'User')
ContentType = apps.get_model('contenttypes', 'ContentType')
Permission = apps.get_model('auth', 'Permission')
@ -13,7 +14,7 @@ def create_permissions(apps, schema_editor):
Permission.objects.get_or_create(codename="srp_management", content_type=ct, name="srp_management")
def reverse(apps, schema_editor):
def reverse(apps, schema_editor) -> None:
pass