mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-21 19:38:07 +00:00
perf: change Command
This commit is contained in:
@@ -2,6 +2,7 @@ from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from perms.const import ActionChoices
|
||||
from tickets.const import TicketType
|
||||
from .general import Ticket
|
||||
|
||||
__all__ = ['ApplyAssetTicket']
|
||||
@@ -19,6 +20,8 @@ class ApplyAssetTicket(Ticket):
|
||||
apply_date_start = models.DateTimeField(verbose_name=_('Date start'), null=True)
|
||||
apply_date_expired = models.DateTimeField(verbose_name=_('Date expired'), null=True)
|
||||
|
||||
TICKET_TYPE = TicketType.apply_asset
|
||||
|
||||
def get_apply_actions_display(self):
|
||||
return ActionChoices.display(self.apply_actions)
|
||||
|
||||
|
@@ -2,6 +2,7 @@ from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from .general import Ticket
|
||||
from ...const import TicketType
|
||||
|
||||
|
||||
class ApplyCommandTicket(Ticket):
|
||||
@@ -19,5 +20,7 @@ class ApplyCommandTicket(Ticket):
|
||||
null=True, verbose_name=_('Command filter acl')
|
||||
)
|
||||
|
||||
TICKET_TYPE = TicketType.command_confirm
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Apply Command Ticket')
|
||||
|
@@ -303,6 +303,8 @@ class Ticket(StatusMixin, JMSBaseModel):
|
||||
max_length=36, blank=True, default='', verbose_name=_('Organization'), db_index=True
|
||||
)
|
||||
|
||||
TICKET_TYPE = TicketType.general
|
||||
|
||||
class Meta:
|
||||
ordering = ('-date_created',)
|
||||
verbose_name = _('Ticket')
|
||||
@@ -313,11 +315,23 @@ class Ticket(StatusMixin, JMSBaseModel):
|
||||
def __str__(self):
|
||||
return '{}({})'.format(self.title, self.applicant)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.type = self.TICKET_TYPE
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
@property
|
||||
def spec_ticket(self):
|
||||
attr = self.type.replace('_', '') + 'ticket'
|
||||
return getattr(self, attr)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.title
|
||||
|
||||
@name.setter
|
||||
def name(self, value):
|
||||
self.title = value
|
||||
|
||||
# TODO 先单独处理一下
|
||||
@property
|
||||
def org_name(self):
|
||||
|
@@ -5,6 +5,8 @@ from .general import Ticket
|
||||
|
||||
__all__ = ['ApplyLoginAssetTicket']
|
||||
|
||||
from ...const import TicketType
|
||||
|
||||
|
||||
class ApplyLoginAssetTicket(Ticket):
|
||||
apply_login_user = models.ForeignKey(
|
||||
@@ -17,6 +19,8 @@ class ApplyLoginAssetTicket(Ticket):
|
||||
max_length=128, default='', verbose_name=_('Login account')
|
||||
)
|
||||
|
||||
TICKET_TYPE = TicketType.login_asset_confirm
|
||||
|
||||
def activate_connection_token_if_need(self):
|
||||
if not self.connection_token:
|
||||
return
|
||||
|
@@ -5,11 +5,15 @@ from .general import Ticket
|
||||
|
||||
__all__ = ['ApplyLoginTicket']
|
||||
|
||||
from ...const import TicketType
|
||||
|
||||
|
||||
class ApplyLoginTicket(Ticket):
|
||||
apply_login_ip = models.GenericIPAddressField(verbose_name=_('Login IP'), null=True)
|
||||
apply_login_city = models.CharField(max_length=64, verbose_name=_('Login city'), null=True)
|
||||
apply_login_datetime = models.DateTimeField(verbose_name=_('Login Date'), null=True)
|
||||
|
||||
TICKET_TYPE = TicketType.login_confirm
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Apply Login Ticket')
|
||||
|
Reference in New Issue
Block a user