perf: permission (#9244)

Co-authored-by: feng <1304903146@qq.com>
pull/9246/head
fit2bot 2022-12-27 14:48:00 +08:00 committed by GitHub
parent bb23c2a9fa
commit 1e0bfbf8a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 4 deletions

View File

@ -0,0 +1,17 @@
# Generated by Django 3.2.16 on 2022-12-27 06:07
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('ops', '0033_auto_20221223_1536'),
]
operations = [
migrations.AlterModelOptions(
name='celerytask',
options={'ordering': ('name',), 'permissions': [('view_taskmonitor', 'Can view task monitor')], 'verbose_name': 'Celery Task'},
),
]

View File

@ -46,6 +46,9 @@ class CeleryTask(models.Model):
class Meta:
verbose_name = _("Celery Task")
ordering = ('name',)
permissions = [
('view_taskmonitor', _('Can view task monitor'))
]
class CeleryTaskExecution(models.Model):

View File

@ -70,7 +70,6 @@ exclude_permissions = (
('rbac', 'role', '*', '*'),
('ops', 'adhoc', 'delete,change', '*'),
('ops', 'adhocexecution', 'add,delete,change', '*'),
('ops', 'task', 'add,change', 'task'),
('ops', 'jobexecution', 'change,delete', 'jobexecution'),
('ops', 'historicaljob', '*', '*'),
('ops', 'celerytask', 'add,change,delete', 'celerytask'),
@ -99,9 +98,6 @@ exclude_permissions = (
('xpack', 'license', '*', '*'),
('xpack', 'syncinstancedetail', 'add,delete,change', 'syncinstancedetail'),
('xpack', 'syncinstancetaskexecution', 'delete,change', 'syncinstancetaskexecution'),
('xpack', 'changeauthplanexecution', '*', '*'),
('xpack', 'changeauthplantask', '*', '*'),
('xpack', 'gatherusertaskexecution', '*', '*'),
('common', 'permission', 'add,delete,view,change', 'permission'),
('terminal', 'command', 'delete,change', 'command'),
('terminal', 'status', 'delete,change', 'status'),

View File

@ -0,0 +1,24 @@
# Generated by Django 3.2.16 on 2022-12-27 02:41
from django.db import migrations
def migrate_remove_redundant_permission(apps, *args):
model = apps.get_model('rbac', 'ContentType')
model.objects.filter(app_label='applications').delete()
model.objects.filter(app_label='ops', model='task').delete()
model.objects.filter(app_label='xpack', model__in=[
'applicationchangeauthplan', 'applicationchangeauthplanexecution',
'applicationchangeauthplantask', 'changeauthplan', 'changeauthplanexecution',
'changeauthplantask', 'gatherusertask', 'gatherusertaskexecution'
]).delete()
class Migration(migrations.Migration):
dependencies = [
('rbac', '0010_auto_20221220_1956'),
]
operations = [
migrations.RunPython(migrate_remove_redundant_permission)
]

View File

@ -100,6 +100,8 @@ special_pid_mapper = {
'ops.jobauditlog': 'audits',
'ops.view_celerytask': 'task_center',
'ops.view_celerytaskexecution': 'task_center',
'ops.view_taskmonitor': 'task_center',
'ops.adhocexecution': 'task_center',
'ops.job': 'operation_center',
'ops.adhoc': 'operation_center',
'ops.playbook': 'operation_center',