jumpserver/apps/assets/models/gathered_user.py

39 lines
1.2 KiB
Python
Raw Normal View History

2019-09-18 14:06:46 +00:00
# -*- coding: utf-8 -*-
#
import uuid
from django.db import models
from django.utils.translation import ugettext_lazy as _
from orgs.mixins.models import OrgModelMixin
__all__ = ['GatheredUser']
class GatheredUser(OrgModelMixin):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
asset = models.ForeignKey('assets.Asset', on_delete=models.CASCADE, verbose_name=_("Asset"))
2019-11-14 03:46:42 +00:00
username = models.CharField(max_length=32, blank=True, db_index=True, verbose_name=_('Username'))
present = models.BooleanField(default=True, verbose_name=_("Present"))
2019-11-14 03:46:42 +00:00
date_last_login = models.DateTimeField(null=True, verbose_name=_("Date last login"))
ip_last_login = models.CharField(max_length=39, default='', verbose_name=_("IP last login"))
date_created = models.DateTimeField(auto_now_add=True, verbose_name=_("Date created"))
date_updated = models.DateTimeField(auto_now=True, verbose_name=_("Date updated"))
2019-09-18 14:06:46 +00:00
@property
def hostname(self):
2022-08-11 07:45:03 +00:00
return self.asset.name
2019-09-18 14:06:46 +00:00
@property
def ip(self):
return self.asset.ip
class Meta:
verbose_name = _('GatherUser')
ordering = ['asset']
def __str__(self):
2022-08-11 07:45:03 +00:00
return '{}: {}'.format(self.asset.name, self.username)
2019-09-18 14:06:46 +00:00