mirror of https://github.com/jumpserver/jumpserver
Pull it
commit
610c9c5149
|
@ -10,6 +10,7 @@ logger = get_logger(__file__)
|
|||
|
||||
|
||||
class AssetCreateForm(forms.ModelForm):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
instance = kwargs.get('instance', None)
|
||||
if instance:
|
||||
|
@ -100,10 +101,10 @@ class AssetGroupForm(forms.ModelForm):
|
|||
class Meta:
|
||||
model = AssetGroup
|
||||
fields = [
|
||||
"name", "comment","system_users",
|
||||
"name", "comment", "system_users",
|
||||
]
|
||||
widgets = {
|
||||
'name' : forms.TextInput(attrs={}),
|
||||
'name': forms.TextInput(attrs={}),
|
||||
'system_users': forms.SelectMultiple(attrs={'class': 'select2-system-user', 'data-placeholder': _('Select asset system user')}),
|
||||
|
||||
}
|
||||
|
@ -135,7 +136,8 @@ class IDCForm(forms.ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = IDC
|
||||
fields = ['name', "bandwidth", "operator", 'contact', 'phone', 'address', 'intranet', 'extranet','comment']
|
||||
fields = ['name', "bandwidth", "operator", 'contact',
|
||||
'phone', 'address', 'intranet', 'extranet', 'comment']
|
||||
widgets = {
|
||||
'name': forms.TextInput(attrs={'placeholder': _('Name')}),
|
||||
'intranet': forms.Textarea(
|
||||
|
@ -214,7 +216,8 @@ class AdminUserForm(forms.ModelForm):
|
|||
|
||||
class Meta:
|
||||
model = AdminUser
|
||||
fields = ['name', 'username', 'password', 'private_key_file', 'comment']
|
||||
fields = ['name', 'username', 'password',
|
||||
'private_key_file', 'comment']
|
||||
widgets = {
|
||||
'name': forms.TextInput(attrs={'placeholder': _('Name')}),
|
||||
'username': forms.TextInput(attrs={'placeholder': _('Username')}),
|
||||
|
@ -320,7 +323,7 @@ class AssetTagForm(forms.ModelForm):
|
|||
"name",
|
||||
]
|
||||
widgets = {
|
||||
'name' : forms.TextInput(attrs={}),
|
||||
'name': forms.TextInput(attrs={}),
|
||||
|
||||
}
|
||||
help_texts = {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
import logging
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
|
@ -15,15 +16,22 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
class IDC(models.Model):
|
||||
name = models.CharField(max_length=32, verbose_name=_('Name'))
|
||||
bandwidth = models.CharField(max_length=32, blank=True, verbose_name=_('Bandwidth'))
|
||||
contact = models.CharField(max_length=16, blank=True, verbose_name=_('Contact'))
|
||||
phone = models.CharField(max_length=32, blank=True, verbose_name=_('Phone'))
|
||||
address = models.CharField(max_length=128, blank=True, verbose_name=_("Address"))
|
||||
bandwidth = models.CharField(
|
||||
max_length=32, blank=True, verbose_name=_('Bandwidth'))
|
||||
contact = models.CharField(
|
||||
max_length=128, blank=True, verbose_name=_('Contact'))
|
||||
phone = models.CharField(max_length=32, blank=True,
|
||||
verbose_name=_('Phone'))
|
||||
address = models.CharField(
|
||||
max_length=128, blank=True, verbose_name=_("Address"))
|
||||
intranet = models.TextField(blank=True, verbose_name=_('Intranet'))
|
||||
extranet = models.TextField(blank=True, verbose_name=_('Extranet'))
|
||||
date_created = models.DateTimeField(auto_now_add=True, null=True, verbose_name=_('Date added'))
|
||||
operator = models.CharField(max_length=32, blank=True, verbose_name=_('Operator'))
|
||||
created_by = models.CharField(max_length=32, blank=True, verbose_name=_('Created by'))
|
||||
date_created = models.DateTimeField(
|
||||
auto_now_add=True, null=True, verbose_name=_('Date added'))
|
||||
operator = models.CharField(
|
||||
max_length=32, blank=True, verbose_name=_('Operator'))
|
||||
created_by = models.CharField(
|
||||
max_length=32, blank=True, verbose_name=_('Created by'))
|
||||
comment = models.TextField(blank=True, verbose_name=_('Comment'))
|
||||
|
||||
def __unicode__(self):
|
||||
|
@ -58,4 +66,3 @@ class IDC(models.Model):
|
|||
except IntegrityError:
|
||||
print('Error continue')
|
||||
continue
|
||||
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
import logging
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from common.utils import signer, validate_ssh_private_key, ssh_key_string_to_obj
|
||||
|
||||
|
@ -30,17 +31,20 @@ class AdminUser(models.Model):
|
|||
)
|
||||
name = models.CharField(max_length=128, unique=True, verbose_name=_('Name'))
|
||||
username = models.CharField(max_length=16, verbose_name=_('Username'))
|
||||
_password = models.CharField(max_length=256, blank=True, null=True, verbose_name=_('Password'))
|
||||
_password = models.CharField(
|
||||
max_length=256, blank=True, null=True, verbose_name=_('Password'))
|
||||
_private_key = models.CharField(max_length=4096, blank=True, null=True, verbose_name=_('SSH private key'),
|
||||
validators=[private_key_validator,])
|
||||
_public_key = models.CharField(max_length=4096, blank=True, verbose_name=_('SSH public key'))
|
||||
become = models.BooleanField(default=True)
|
||||
become_method = models.CharField(choices=BECOME_METHOD_CHOICES, default='sudo', max_length=4)
|
||||
become_user = models.CharField(default='root', max_length=64)
|
||||
become_password = models.CharField(default='', max_length=128)
|
||||
_public_key = models.CharField(
|
||||
max_length=4096, blank=True, verbose_name=_('SSH public key'))
|
||||
comment = models.TextField(blank=True, verbose_name=_('Comment'))
|
||||
date_created = models.DateTimeField(auto_now_add=True, null=True)
|
||||
created_by = models.CharField(max_length=32, null=True, verbose_name=_('Created by'))
|
||||
created_by = models.CharField(
|
||||
max_length=32, null=True, verbose_name=_('Created by'))
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
@ -114,22 +118,29 @@ class SystemUser(models.Model):
|
|||
('P', 'Password'),
|
||||
('K', 'Public key'),
|
||||
)
|
||||
name = models.CharField(max_length=128, unique=True, verbose_name=_('Name'))
|
||||
name = models.CharField(max_length=128, unique=True,
|
||||
verbose_name=_('Name'))
|
||||
username = models.CharField(max_length=16, verbose_name=_('Username'))
|
||||
_password = models.CharField(max_length=256, blank=True, null=True, verbose_name=_('Password'))
|
||||
protocol = models.CharField(max_length=16, choices=PROTOCOL_CHOICES, default='ssh', verbose_name=_('Protocol'))
|
||||
_private_key = models.CharField(max_length=4096, blank=True, verbose_name=_('SSH private key'))
|
||||
_public_key = models.CharField(max_length=4096, blank=True, verbose_name=_('SSH public key'))
|
||||
_password = models.CharField(
|
||||
max_length=256, blank=True, verbose_name=_('Password'))
|
||||
protocol = models.CharField(
|
||||
max_length=16, choices=PROTOCOL_CHOICES, default='ssh', verbose_name=_('Protocol'))
|
||||
_private_key = models.CharField(
|
||||
max_length=8192, blank=True, verbose_name=_('SSH private key'))
|
||||
_public_key = models.CharField(
|
||||
max_length=8192, blank=True, verbose_name=_('SSH public key'))
|
||||
auth_method = models.CharField(choices=AUTH_METHOD_CHOICES, default='K',
|
||||
max_length=1, verbose_name=_('Auth method'))
|
||||
auto_push = models.BooleanField(default=True, verbose_name=_('Auto push'))
|
||||
sudo = models.TextField(max_length=4096, default='/user/bin/whoami', verbose_name=_('Sudo'))
|
||||
shell = models.CharField(max_length=64, default='/bin/bash', verbose_name=_('Shell'))
|
||||
home = models.CharField(max_length=64, blank=True, verbose_name=_('Home'))
|
||||
uid = models.IntegerField(null=True, blank=True, verbose_name=_('Uid'))
|
||||
sudo = models.TextField(
|
||||
max_length=4096, default='/sbin/ifconfig', verbose_name=_('Sudo'))
|
||||
shell = models.CharField(
|
||||
max_length=64, default='/bin/bash', verbose_name=_('Shell'))
|
||||
date_created = models.DateTimeField(auto_now_add=True)
|
||||
created_by = models.CharField(max_length=32, blank=True, verbose_name=_('Created by'))
|
||||
comment = models.TextField(max_length=128, blank=True, verbose_name=_('Comment'))
|
||||
created_by = models.CharField(
|
||||
max_length=32, blank=True, verbose_name=_('Created by'))
|
||||
comment = models.TextField(
|
||||
max_length=128, blank=True, verbose_name=_('Comment'))
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
@ -174,7 +185,8 @@ class SystemUser(models.Model):
|
|||
return assets
|
||||
|
||||
def get_assets(self):
|
||||
assets = set(self.assets.all()) | self.get_assets_inherit_from_asset_groups()
|
||||
assets = set(self.assets.all()
|
||||
) | self.get_assets_inherit_from_asset_groups()
|
||||
return list(assets)
|
||||
|
||||
def _to_secret_json(self):
|
||||
|
@ -228,4 +240,3 @@ class SystemUser(models.Model):
|
|||
except IntegrityError:
|
||||
print('Error continue')
|
||||
continue
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import base64
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
@ -20,9 +19,9 @@ class LoginLog(models.Model):
|
|||
login_type = models.CharField(choices=LOGIN_TYPE_CHOICE, max_length=2,
|
||||
verbose_name=_('Login type'))
|
||||
login_ip = models.GenericIPAddressField(verbose_name=_('Login ip'))
|
||||
login_city = models.CharField(max_length=100, blank=True, null=True,
|
||||
login_city = models.CharField(max_length=254, blank=True, null=True,
|
||||
verbose_name=_('Login city'))
|
||||
user_agent = models.CharField(max_length=100, blank=True, null=True,
|
||||
user_agent = models.CharField(max_length=254, blank=True, null=True,
|
||||
verbose_name=_('User agent'))
|
||||
date_login = models.DateTimeField(auto_now_add=True,
|
||||
verbose_name=_('Date login'))
|
||||
|
|
Loading…
Reference in New Issue