2023-12-05 08:52:11 +00:00
|
|
|
from django.db import models
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
|
|
from common.db.models import JMSBaseModel
|
|
|
|
|
|
|
|
__all__ = ['AppProvider', ]
|
|
|
|
|
|
|
|
|
|
|
|
class AppProvider(JMSBaseModel):
|
|
|
|
name = models.CharField(max_length=128, verbose_name=_('Name'), unique=True)
|
|
|
|
hostname = models.CharField(max_length=128, verbose_name=_('Hostname'))
|
|
|
|
terminal = models.OneToOneField(
|
|
|
|
'terminal.Terminal', on_delete=models.CASCADE, null=True, blank=True,
|
|
|
|
related_name='app_provider', verbose_name=_('Terminal')
|
|
|
|
)
|
|
|
|
apps = models.ManyToManyField(
|
2023-12-08 08:06:17 +00:00
|
|
|
'VirtualApp', verbose_name=_('Virtual app'),
|
2023-12-05 08:52:11 +00:00
|
|
|
through='VirtualAppPublication', through_fields=('provider', 'app'),
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
ordering = ('-date_created',)
|
2024-06-26 08:41:37 +00:00
|
|
|
verbose_name = _('App Provider')
|
2023-12-05 08:52:11 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def load(self):
|
|
|
|
if not self.terminal:
|
|
|
|
return 'offline'
|
|
|
|
return self.terminal.load
|