[Feature] terminal config load

pull/968/head
ibuler 7 years ago
parent b936d54a48
commit 41f1c3f7f7

@ -262,8 +262,11 @@ class SessionReplayViewSet(viewsets.ViewSet):
return HttpResponseNotFound()
class LoadConfig(APIView):
class TerminalConfig(APIView):
permission_classes = (IsAppUser,)
def get(self, request):
pass
user = request.user
terminal = user.terminal
configs = terminal.config
return Response(configs, status=200)

@ -44,14 +44,24 @@ class Terminal(models.Model):
self.user.save()
def get_common_storage(self):
pass
storage_all = settings.TERMINAL_COMMAND_STORAGE
if self.command_storage in storage_all:
storage = storage_all.get(self.command_storage)
else:
storage = storage_all.get('default')
return {"TERMINAL_COMMAND_STORAGE": storage}
def get_replay_storage(self):
pass
@property
def config(self):
return
configs = {}
for k in dir(settings):
if k.startswith('TERMINAL'):
configs[k] = getattr(settings, k)
configs.update(self.get_common_storage())
return configs
def create_app_user(self):
random = uuid.uuid4().hex[:6]

@ -20,7 +20,8 @@ urlpatterns = [
url(r'^v1/sessions/(?P<pk>[0-9a-zA-Z\-]{36})/replay/$',
api.SessionReplayViewSet.as_view({'get': 'retrieve', 'post': 'create'}),
name='session-replay'),
url(r'^v1/terminal/(?P<terminal>[a-zA-Z0-9\-]{36})/access-key', api.TerminalTokenApi.as_view(), name='terminal-access-key')
url(r'^v1/terminal/(?P<terminal>[a-zA-Z0-9\-]{36})/access-key', api.TerminalTokenApi.as_view(), name='terminal-access-key'),
url(r'^v1/terminal/config', api.TerminalConfig.as_view(), name='terminal-config'),
]
urlpatterns += router.urls

Loading…
Cancel
Save