mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-26 07:22:27 +00:00
merge v3
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import time
|
||||
|
||||
from django.db import models
|
||||
from django.db.models.signals import post_save
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@@ -47,6 +45,21 @@ class Command(AbstractSessionCommand):
|
||||
cls.objects.bulk_create(commands)
|
||||
print(f'Create {len(commands)} commands of org ({org})')
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, d):
|
||||
self = cls()
|
||||
for k, v in d.items():
|
||||
setattr(self, k, v)
|
||||
return self
|
||||
|
||||
@classmethod
|
||||
def from_multi_dict(cls, l):
|
||||
commands = []
|
||||
for d in l:
|
||||
command = cls.from_dict(d)
|
||||
commands.append(command)
|
||||
return commands
|
||||
|
||||
class Meta:
|
||||
db_table = "terminal_command"
|
||||
ordering = ('-timestamp',)
|
||||
|
@@ -18,6 +18,8 @@ class Endpoint(JMSBaseModel):
|
||||
mariadb_port = PortField(default=33061, verbose_name=_('MariaDB Port'))
|
||||
postgresql_port = PortField(default=54320, verbose_name=_('PostgreSQL Port'))
|
||||
redis_port = PortField(default=63790, verbose_name=_('Redis Port'))
|
||||
oracle_11g_port = PortField(default=15211, verbose_name=_('Oracle 11g Port'))
|
||||
oracle_12c_port = PortField(default=15212, verbose_name=_('Oracle 12c Port'))
|
||||
comment = models.TextField(default='', blank=True, verbose_name=_('Comment'))
|
||||
|
||||
default_id = '00000000-0000-0000-0000-000000000001'
|
||||
@@ -32,6 +34,10 @@ class Endpoint(JMSBaseModel):
|
||||
def get_port(self, protocol):
|
||||
return getattr(self, f'{protocol}_port', 0)
|
||||
|
||||
def get_oracle_port(self, version):
|
||||
protocol = f'oracle_{version}'
|
||||
return self.get_port(protocol)
|
||||
|
||||
def is_default(self):
|
||||
return str(self.id) == self.default_id
|
||||
|
||||
@@ -57,8 +63,6 @@ class Endpoint(JMSBaseModel):
|
||||
'http_port': 0,
|
||||
}
|
||||
endpoint, created = cls.objects.get_or_create(id=cls.default_id, defaults=data)
|
||||
if not endpoint.host and request:
|
||||
endpoint.host = request.get_host().split(':')[0]
|
||||
return endpoint
|
||||
|
||||
@classmethod
|
||||
@@ -116,4 +120,7 @@ class EndpointRule(JMSBaseModel):
|
||||
endpoint = endpoint_rule.endpoint
|
||||
else:
|
||||
endpoint = Endpoint.get_or_create_default(request)
|
||||
if not endpoint.host and request:
|
||||
# 动态添加 current request host
|
||||
endpoint.host = request.get_host().split(':')[0]
|
||||
return endpoint
|
||||
|
@@ -43,6 +43,8 @@ class SessionSharing(CommonModelMixin, OrgModelMixin):
|
||||
return 'Creator: {}'.format(self.creator)
|
||||
|
||||
def users_display(self):
|
||||
if not self.users:
|
||||
return []
|
||||
with tmp_to_root_org():
|
||||
user_ids = self.users.split(',')
|
||||
users = User.objects.filter(id__in=user_ids)
|
||||
|
Reference in New Issue
Block a user