jumpserver/apps/assets/serializers/gathered_user.py

27 lines
853 B
Python
Raw Normal View History

2019-09-18 14:06:46 +00:00
# -*- coding: utf-8 -*-
#
from django.utils.translation import ugettext_lazy as _
2019-09-18 14:06:46 +00:00
from orgs.mixins.serializers import OrgResourceModelSerializerMixin
from common.drf.fields import ObjectRelatedField
from ..models import GatheredUser, Asset
2019-09-18 14:06:46 +00:00
class GatheredUserSerializer(OrgResourceModelSerializerMixin):
asset = ObjectRelatedField(queryset=Asset.objects, label=_('Asset'))
2019-09-18 14:06:46 +00:00
class Meta:
model = GatheredUser
2021-04-29 11:10:45 +00:00
fields_mini = ['id']
fields_small = fields_mini + [
2022-09-20 08:18:23 +00:00
'username', 'ip_last_login', 'present', 'name',
2021-04-29 11:10:45 +00:00
'date_last_login', 'date_created', 'date_updated'
2019-09-18 14:06:46 +00:00
]
2022-09-20 08:18:23 +00:00
fields_fk = ['asset', 'ip']
2021-04-29 11:10:45 +00:00
fields = fields_small + fields_fk
2019-09-18 14:06:46 +00:00
read_only_fields = fields
2020-05-20 09:45:50 +00:00
extra_kwargs = {
2022-08-11 07:45:03 +00:00
'name': {'label': _("Hostname")},
2020-05-20 09:45:50 +00:00
'ip': {'label': 'IP'},
}