mirror of https://github.com/jumpserver/jumpserver
perf: change tree api
parent
dd630f0e14
commit
795e952dc1
|
@ -144,7 +144,7 @@ class CategoryTreeApi(SerializeToTreeNodeMixin, generics.ListAPIView):
|
|||
return self.serialize_assets(assets, key)
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
include_asset = bool(self.request.query_params.get('assets'))
|
||||
include_asset = self.request.query_params.get('assets', '0') == '1'
|
||||
|
||||
if include_asset and self.request.query_params.get('key'):
|
||||
nodes = self.get_assets()
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from assets.const import AutomationTypes
|
||||
from .change_secret import ChangeSecretAutomation
|
||||
|
||||
__all__ = ['CreateAccountAutomation']
|
||||
|
||||
|
||||
class CreateAccountAutomation(ChangeSecretAutomation):
|
||||
username = models.CharField(max_length=128, blank=True, verbose_name=_("Username"))
|
||||
secret_type = models.CharField(max_length=16, verbose_name=_('Secret type'))
|
||||
secret_strategy = models.CharField(max_length=16, default=SecretPolicy.random,
|
||||
choices=SecretPolicy.choices, verbose_name=_("Secret strategy"))
|
||||
secret = models.CharField(max_length=1024, blank=True, verbose_name=_("Secret"))
|
||||
accounts = None
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.type = AutomationTypes.push_account
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Push asset account")
|
|
@ -317,10 +317,11 @@ class SomeFieldsMixin:
|
|||
instance: None
|
||||
initial_data: dict
|
||||
common_fields = (
|
||||
'comment', 'created_by', 'date_created', 'date_updated',
|
||||
'comment', 'created_by', 'updated_by',
|
||||
'date_created', 'date_updated',
|
||||
)
|
||||
secret_fields = (
|
||||
'password', 'token', 'secret', 'key', 'private_key', 'public_key',
|
||||
'password', 'token', 'secret', 'key', 'private_key'
|
||||
)
|
||||
|
||||
def get_initial_value(self, attr, default=None):
|
||||
|
@ -335,7 +336,9 @@ class SomeFieldsMixin:
|
|||
def get_fields(self):
|
||||
fields = super().get_fields()
|
||||
for name, field in fields.items():
|
||||
if name in self.secret_fields and \
|
||||
if name == 'id':
|
||||
field.label = 'ID'
|
||||
elif name in self.secret_fields and \
|
||||
not isinstance(self, SecretReadableMixin):
|
||||
field.write_only = True
|
||||
return fields
|
||||
|
|
Loading…
Reference in New Issue