mirror of https://github.com/jumpserver/jumpserver
perf: Add GatherAccountDetailField and update serializers
parent
8f8935ddd8
commit
8420c0b22b
|
@ -59,7 +59,7 @@ class GatherAccountsFilter:
|
||||||
'groups': '',
|
'groups': '',
|
||||||
}
|
}
|
||||||
detail = {
|
detail = {
|
||||||
'canlogin': user_info.get('canlogin'),
|
'can_login': user_info.get('canlogin'),
|
||||||
'superuser': user_info.get('superuser'),
|
'superuser': user_info.get('superuser'),
|
||||||
}
|
}
|
||||||
user['detail'] = detail
|
user['detail'] = detail
|
||||||
|
@ -87,7 +87,6 @@ class GatherAccountsFilter:
|
||||||
'is_disabled': user_info.get('is_disabled', ''),
|
'is_disabled': user_info.get('is_disabled', ''),
|
||||||
'default_database_name': user_info.get('default_database_name', ''),
|
'default_database_name': user_info.get('default_database_name', ''),
|
||||||
}
|
}
|
||||||
print(user)
|
|
||||||
user['detail'] = detail
|
user['detail'] = detail
|
||||||
result[user['username']] = user
|
result[user['username']] = user
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -16,7 +16,7 @@ DEFAULT_PASSWORD_RULES = {
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'AutomationTypes', 'SecretStrategy', 'SSHKeyStrategy', 'Connectivity',
|
'AutomationTypes', 'SecretStrategy', 'SSHKeyStrategy', 'Connectivity',
|
||||||
'DEFAULT_PASSWORD_LENGTH', 'DEFAULT_PASSWORD_RULES', 'TriggerChoice',
|
'DEFAULT_PASSWORD_LENGTH', 'DEFAULT_PASSWORD_RULES', 'TriggerChoice',
|
||||||
'PushAccountActionChoice', 'AccountBackupType', 'ChangeSecretRecordStatusChoice',
|
'PushAccountActionChoice', 'AccountBackupType', 'ChangeSecretRecordStatusChoice', 'GatherAccountDetailField'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,3 +114,20 @@ class ChangeSecretRecordStatusChoice(models.TextChoices):
|
||||||
failed = 'failed', _('Failed')
|
failed = 'failed', _('Failed')
|
||||||
success = 'success', _('Success')
|
success = 'success', _('Success')
|
||||||
pending = 'pending', _('Pending')
|
pending = 'pending', _('Pending')
|
||||||
|
|
||||||
|
|
||||||
|
class GatherAccountDetailField(models.TextChoices):
|
||||||
|
can_login = 'can_login', _('Can login')
|
||||||
|
superuser = 'superuser', _('Superuser')
|
||||||
|
create_date = 'create_date', _('Create date')
|
||||||
|
is_disabled = 'is_disabled', _('Is disabled')
|
||||||
|
default_database_name = 'default_database_name', _('Default database name')
|
||||||
|
uid = 'uid', _('UID')
|
||||||
|
account_status = 'account_status', _('Account status')
|
||||||
|
default_tablespace = 'default_tablespace', _('Default tablespace')
|
||||||
|
roles = 'roles', _('Roles')
|
||||||
|
privileges = 'privileges', _('Privileges')
|
||||||
|
groups = 'groups', _('Groups')
|
||||||
|
sudoers = 'sudoers', 'sudoers'
|
||||||
|
authorized_keys = 'authorized_keys', _('Authorized keys')
|
||||||
|
db = 'db', _('DB')
|
||||||
|
|
|
@ -2,7 +2,7 @@ from django.shortcuts import get_object_or_404
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from accounts.const import AutomationTypes
|
from accounts.const import AutomationTypes, GatherAccountDetailField
|
||||||
from accounts.models import GatherAccountsAutomation
|
from accounts.models import GatherAccountsAutomation
|
||||||
from accounts.models import GatheredAccount
|
from accounts.models import GatheredAccount
|
||||||
from accounts.serializers.account.account import AccountAssetSerializer as _AccountAssetSerializer
|
from accounts.serializers.account.account import AccountAssetSerializer as _AccountAssetSerializer
|
||||||
|
@ -82,7 +82,9 @@ class GatheredAccountDetailsSerializer(serializers.Serializer):
|
||||||
obj = get_object_or_404(GatheredAccount, pk=pk)
|
obj = get_object_or_404(GatheredAccount, pk=pk)
|
||||||
details = obj.detail
|
details = obj.detail
|
||||||
for key, value in details.items():
|
for key, value in details.items():
|
||||||
|
field_dict = GatherAccountDetailField._member_map_
|
||||||
|
label = field_dict[key].label if key in field_dict else key
|
||||||
if isinstance(value, bool):
|
if isinstance(value, bool):
|
||||||
self.fields[key] = serializers.BooleanField(label=key, read_only=True)
|
self.fields[key] = serializers.BooleanField(label=label, read_only=True)
|
||||||
else:
|
else:
|
||||||
self.fields[key] = serializers.CharField(label=key, read_only=True)
|
self.fields[key] = serializers.CharField(label=label, read_only=True)
|
||||||
|
|
Loading…
Reference in New Issue