2019-09-18 14:06:46 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2019-09-19 06:48:25 +00:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2019-09-18 14:06:46 +00:00
|
|
|
|
|
|
|
from orgs.mixins.serializers import OrgResourceModelSerializerMixin
|
2022-11-09 10:15:21 +00:00
|
|
|
from common.drf.fields import ObjectRelatedField
|
|
|
|
from ..models import GatheredUser, Asset
|
2019-09-18 14:06:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
class GatheredUserSerializer(OrgResourceModelSerializerMixin):
|
2022-11-09 10:15:21 +00:00
|
|
|
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'},
|
2019-09-19 06:48:25 +00:00
|
|
|
}
|