diff --git a/apps/perms/const.py b/apps/perms/const.py index d1c7d3a46..5b8e1baca 100644 --- a/apps/perms/const.py +++ b/apps/perms/const.py @@ -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') diff --git a/apps/perms/migrations/0019_auto_20210831_1150.py b/apps/perms/migrations/0019_auto_20210831_1150.py deleted file mode 100644 index 32c3d7477..000000000 --- a/apps/perms/migrations/0019_auto_20210831_1150.py +++ /dev/null @@ -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'), - ), - ] diff --git a/apps/perms/migrations/0019_auto_20210906_1044.py b/apps/perms/migrations/0019_auto_20210906_1044.py new file mode 100644 index 000000000..42e480669 --- /dev/null +++ b/apps/perms/migrations/0019_auto_20210906_1044.py @@ -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'), + ), + ] diff --git a/apps/perms/models/base.py b/apps/perms/models/base.py index 7f3c3c5ea..2e62a84bf 100644 --- a/apps/perms/models/base.py +++ b/apps/perms/models/base.py @@ -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)() diff --git a/apps/tickets/handler/apply_application.py b/apps/tickets/handler/apply_application.py index 473fdf344..8d03a995d 100644 --- a/apps/tickets/handler/apply_application.py +++ b/apps/tickets/handler/apply_application.py @@ -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), diff --git a/apps/tickets/handler/apply_asset.py b/apps/tickets/handler/apply_asset.py index e4f6bf578..ae8ded3b1 100644 --- a/apps/tickets/handler/apply_asset.py +++ b/apps/tickets/handler/apply_asset.py @@ -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,