diff --git a/apps/terminal/backends/command/db.py b/apps/terminal/backends/command/db.py index 6e0ac961d..29d322c1a 100644 --- a/apps/terminal/backends/command/db.py +++ b/apps/terminal/backends/command/db.py @@ -21,7 +21,7 @@ class CommandStore(CommandBase): user=command["user"], asset=command["asset"], system_user=command["system_user"], input=command["input"], output=command["output"], session=command["session"], - timestamp=command["timestamp"] + org_id=command["org_id"], timestamp=command["timestamp"] ) def bulk_save(self, commands): @@ -33,7 +33,7 @@ class CommandStore(CommandBase): _commands.append(self.model( user=c["user"], asset=c["asset"], system_user=c["system_user"], input=c["input"], output=c["output"], session=c["session"], - timestamp=c["timestamp"] + org_id=c["org_id"], timestamp=c["timestamp"] )) return self.model.objects.bulk_create(_commands) diff --git a/apps/terminal/backends/command/models.py b/apps/terminal/backends/command/models.py index 186769b48..b7416d0c3 100644 --- a/apps/terminal/backends/command/models.py +++ b/apps/terminal/backends/command/models.py @@ -4,8 +4,10 @@ import uuid from django.db import models from django.utils.translation import ugettext_lazy as _ +from orgs.mixins import OrgModelMixin -class AbstractSessionCommand(models.Model): + +class AbstractSessionCommand(OrgModelMixin): id = models.UUIDField(default=uuid.uuid4, primary_key=True) user = models.CharField(max_length=64, db_index=True, verbose_name=_("User")) asset = models.CharField(max_length=128, db_index=True, verbose_name=_("Asset")) diff --git a/apps/terminal/backends/command/serializers.py b/apps/terminal/backends/command/serializers.py index 634a81b36..c0a6e6c6e 100644 --- a/apps/terminal/backends/command/serializers.py +++ b/apps/terminal/backends/command/serializers.py @@ -12,5 +12,6 @@ class SessionCommandSerializer(serializers.Serializer): input = serializers.CharField(max_length=128) output = serializers.CharField(max_length=1024, allow_blank=True) session = serializers.CharField(max_length=36) + org_id = serializers.CharField(max_length=36) timestamp = serializers.IntegerField() diff --git a/apps/terminal/models.py b/apps/terminal/models.py index 3ae7066bb..e7b730b04 100644 --- a/apps/terminal/models.py +++ b/apps/terminal/models.py @@ -8,6 +8,7 @@ from django.utils import timezone from django.conf import settings from users.models import User +from orgs.mixins import OrgModelMixin from .backends.command.models import AbstractSessionCommand @@ -112,7 +113,7 @@ class Status(models.Model): return self.date_created.strftime("%Y-%m-%d %H:%M:%S") -class Session(models.Model): +class Session(OrgModelMixin): LOGIN_FROM_CHOICES = ( ('ST', 'SSH Terminal'), ('WT', 'Web Terminal'),