diff --git a/apps/accounts/models/__init__.py b/apps/accounts/models/__init__.py index 46de8344e..c40ee786d 100644 --- a/apps/accounts/models/__init__.py +++ b/apps/accounts/models/__init__.py @@ -1,4 +1,3 @@ from .base import * from .account import * from .automations import * -from .gathered_account import * diff --git a/apps/accounts/models/automations/gather_account.py b/apps/accounts/models/automations/gather_account.py index 1dd5500f7..ced7995c7 100644 --- a/apps/accounts/models/automations/gather_account.py +++ b/apps/accounts/models/automations/gather_account.py @@ -1,9 +1,35 @@ from django.utils.translation import ugettext_lazy as _ +from django.db import models +from django.utils.translation import ugettext_lazy as _ + +from orgs.mixins.models import JMSOrgBaseModel from accounts.const import AutomationTypes from .base import AccountBaseAutomation -__all__ = ['GatherAccountsAutomation'] +__all__ = ['GatherAccountsAutomation', 'GatheredAccount'] + + +class GatheredAccount(JMSOrgBaseModel): + present = models.BooleanField(default=True, verbose_name=_("Present")) + date_last_login = models.DateTimeField(null=True, verbose_name=_("Date last login")) + asset = models.ForeignKey('assets.Asset', on_delete=models.CASCADE, verbose_name=_("Asset")) + username = models.CharField(max_length=32, blank=True, db_index=True, verbose_name=_('Username')) + address_last_login = models.CharField(max_length=39, default='', verbose_name=_("Address last login")) + + @property + def address(self): + return self.asset.address + + class Meta: + verbose_name = _('Gather account') + unique_together = [ + ('username', 'asset'), + ] + ordering = ['asset'] + + def __str__(self): + return '{}: {}'.format(self.asset, self.username) class GatherAccountsAutomation(AccountBaseAutomation): diff --git a/apps/accounts/models/gathered_account.py b/apps/accounts/models/gathered_account.py deleted file mode 100644 index e61487d61..000000000 --- a/apps/accounts/models/gathered_account.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# -from django.db import models -from django.utils.translation import ugettext_lazy as _ - -from orgs.mixins.models import JMSOrgBaseModel - -__all__ = ['GatheredAccount'] - - -class GatheredAccount(JMSOrgBaseModel): - present = models.BooleanField(default=True, verbose_name=_("Present")) - date_last_login = models.DateTimeField(null=True, verbose_name=_("Date last login")) - asset = models.ForeignKey('assets.Asset', on_delete=models.CASCADE, verbose_name=_("Asset")) - username = models.CharField(max_length=32, blank=True, db_index=True, verbose_name=_('Username')) - address_last_login = models.CharField(max_length=39, default='', verbose_name=_("Address last login")) - - @property - def address(self): - return self.asset.address - - class Meta: - verbose_name = _('Gather account') - unique_together = [ - ('username', 'asset'), - ] - ordering = ['asset'] - - def __str__(self): - return '{}: {}'.format(self.asset, self.username)