|
|
|
@ -8,7 +8,7 @@ from rest_framework.response import Response
|
|
|
|
|
|
|
|
|
|
from common.api import JMSModelViewSet
|
|
|
|
|
from common.permissions import IsServiceAccount
|
|
|
|
|
from common.utils import is_uuid
|
|
|
|
|
from common.utils import is_uuid, get_logger
|
|
|
|
|
from orgs.utils import tmp_to_builtin_org
|
|
|
|
|
from rbac.permissions import RBACPermission
|
|
|
|
|
from terminal.models import AppletHost
|
|
|
|
@ -18,6 +18,8 @@ from terminal.serializers import (
|
|
|
|
|
AppletHostAppletReportSerializer,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
logger = get_logger(__file__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HostMixin:
|
|
|
|
|
request: Request
|
|
|
|
@ -36,6 +38,10 @@ class HostMixin:
|
|
|
|
|
|
|
|
|
|
def self_host(self):
|
|
|
|
|
try:
|
|
|
|
|
info = 'User {} has applet host {}'.format(
|
|
|
|
|
self.request.user, self.request.user.terminal.applet_host
|
|
|
|
|
)
|
|
|
|
|
logger.info(info)
|
|
|
|
|
return self.request.user.terminal.applet_host
|
|
|
|
|
except AttributeError:
|
|
|
|
|
raise self.permission_denied(self.request, 'User has no applet host')
|
|
|
|
@ -46,9 +52,11 @@ class HostMixin:
|
|
|
|
|
@property
|
|
|
|
|
def host(self):
|
|
|
|
|
if self.kwargs.get('host'):
|
|
|
|
|
return self.pk_host()
|
|
|
|
|
host = self.pk_host()
|
|
|
|
|
else:
|
|
|
|
|
return self.self_host()
|
|
|
|
|
host = self.self_host()
|
|
|
|
|
logger.info('Applet host: {}'.format(host))
|
|
|
|
|
return host
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AppletHostAccountsViewSet(HostMixin, JMSModelViewSet):
|
|
|
|
|