perf: 授权分类采用from_ticket字段

pull/6766/head
feng626 3 years ago committed by 老广
parent 9fb6fd44d1
commit 0a3e5aed56

@ -2,8 +2,3 @@
#
from django.db.models import TextChoices
from django.utils.translation import ugettext_lazy as _
class AuthorizationRules(TextChoices):
manual = 'manual', _('Manual authorization')
ticket = 'ticket', _('Ticket authorization')

@ -1,23 +0,0 @@
# Generated by Django 3.1.12 on 2021-08-31 03:50
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('perms', '0018_auto_20210208_1515'),
]
operations = [
migrations.AddField(
model_name='applicationpermission',
name='authorization_rules',
field=models.CharField(choices=[('manual', 'Manual authorization'), ('ticket', 'Ticket authorization')], default='manual', max_length=64, verbose_name='Authorization rules'),
),
migrations.AddField(
model_name='assetpermission',
name='authorization_rules',
field=models.CharField(choices=[('manual', 'Manual authorization'), ('ticket', 'Ticket authorization')], default='manual', max_length=64, verbose_name='Authorization rules'),
),
]

@ -0,0 +1,23 @@
# Generated by Django 3.1.12 on 2021-09-06 02:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('perms', '0018_auto_20210208_1515'),
]
operations = [
migrations.AddField(
model_name='applicationpermission',
name='from_ticket',
field=models.BooleanField(default=False, verbose_name='From ticket'),
),
migrations.AddField(
model_name='assetpermission',
name='from_ticket',
field=models.BooleanField(default=False, verbose_name='From ticket'),
),
]

@ -11,7 +11,6 @@ from orgs.mixins.models import OrgModelMixin
from common.db.models import UnionQuerySet
from common.utils import date_expired_default, lazyproperty
from orgs.mixins.models import OrgManager
from ..const import AuthorizationRules
__all__ = [
'BasePermission', 'BasePermissionQuerySet'
@ -52,9 +51,7 @@ class BasePermission(OrgModelMixin):
created_by = models.CharField(max_length=128, blank=True, verbose_name=_('Created by'))
date_created = models.DateTimeField(auto_now_add=True, verbose_name=_('Date created'))
comment = models.TextField(verbose_name=_('Comment'), blank=True)
authorization_rules = models.CharField(
max_length=64, default=AuthorizationRules.manual, choices=AuthorizationRules.choices,
verbose_name=_('Authorization rules'))
from_ticket = models.BooleanField(default=False, verbose_name=_('From ticket'))
objects = BasePermissionManager.from_queryset(BasePermissionQuerySet)()

@ -3,7 +3,6 @@ from orgs.utils import tmp_to_org, tmp_to_root_org
from applications.const import AppCategory, AppType
from applications.models import Application
from perms.models import ApplicationPermission
from perms.const import AuthorizationRules
from assets.models import SystemUser
from .base import BaseHandler
@ -90,7 +89,7 @@ class Handler(BaseHandler):
permissions_data = {
'id': self.ticket.id,
'name': apply_permission_name,
'authorization_rules': AuthorizationRules.ticket,
'from_ticket': True,
'category': apply_category,
'type': apply_type,
'comment': str(permission_comment),

@ -5,7 +5,6 @@ from .base import BaseHandler
from django.utils.translation import ugettext as _
from perms.models import AssetPermission, Action
from perms.const import AuthorizationRules
from orgs.utils import tmp_to_org, tmp_to_root_org
@ -84,7 +83,7 @@ class Handler(BaseHandler):
permission_data = {
'id': self.ticket.id,
'name': apply_permission_name,
'authorization_rules': AuthorizationRules.ticket,
'from_ticket': True,
'comment': str(permission_comment),
'created_by': permission_created_by,
'actions': apply_actions,

Loading…
Cancel
Save