perf: 修复接口文档 修复迁移文件

pull/8873/head
feng626 2022-08-08 19:18:45 +08:00
parent 87df92ea92
commit a7c82f94cc
7 changed files with 18 additions and 7 deletions

View File

@ -34,7 +34,7 @@ class Migration(migrations.Migration):
model_name='asset',
name='platform',
field=models.ForeignKey(
default=assets.models.Platform.default,
default='',
on_delete=django.db.models.deletion.PROTECT,
related_name='assets', to='assets.Platform',
verbose_name='Platform'),

View File

@ -128,6 +128,11 @@ class SystemUser(ProtocolMixin, BaseUser):
return
self.su_from.assets.add(*tuple(assets_or_ids))
# TODO 暂时为了接口文档添加
@property
def auto_push_account(self):
return
class Meta:
ordering = ['name']
unique_together = [('name', 'org_id')]

View File

@ -183,7 +183,7 @@ class Asset(AbsConnectivity, NodesRelationMixin, OrgModelMixin):
def get_all_system_users(self):
from assets.models import SystemUser
system_user_ids = SystemUser.assets.through.objects.filter(asset=self)\
system_user_ids = SystemUser.assets.through.objects.filter(asset=self) \
.values_list('systemuser_id', flat=True)
system_users = SystemUser.objects.filter(id__in=system_user_ids)
return system_users
@ -193,6 +193,11 @@ class Asset(AbsConnectivity, NodesRelationMixin, OrgModelMixin):
self.category = self.platform.category
return super().save(*args, **kwargs)
# TODO 暂时为了接口文档添加
@property
def os(self):
return
class Meta:
unique_together = [('org_id', 'hostname')]
verbose_name = _("Asset")

View File

@ -14,7 +14,7 @@ class Platform(models.Model):
('gbk', 'GBK'),
)
name = models.SlugField(verbose_name=_("Name"), unique=True, allow_unicode=True)
category = models.CharField(max_length=16, choices=Category.choices, verbose_name=_("Category"))
category = models.CharField(max_length=16, choices=Category.choices, default=Category.HOST, verbose_name=_("Category"))
type = models.CharField(choices=AllTypes.choices, max_length=32, default='Linux', verbose_name=_("Type"))
charset = models.CharField(default='utf8', choices=CHARSET_CHOICES, max_length=8, verbose_name=_("Charset"))
meta = JsonDictTextField(blank=True, null=True, verbose_name=_("Meta"))

View File

@ -117,6 +117,8 @@ class CommandExecutionViewSet(ListModelMixin, OrgGenericViewSet):
def get_queryset(self):
queryset = super().get_queryset()
if getattr(self, 'swagger_fake_view', False):
return queryset.model.objects.none()
if current_org.is_root():
return queryset
queryset = queryset.filter(run_as__org_id=current_org.org_id())

View File

@ -10,7 +10,7 @@ from rest_framework.generics import (
ListAPIView, get_object_or_404
)
from orgs.utils import tmp_to_root_org, get_current_org
from orgs.utils import tmp_to_root_org
from applications.models import Application
from perms.utils.application.permission import (
get_application_system_user_ids,
@ -20,7 +20,6 @@ from .mixin import AppRoleAdminMixin, AppRoleUserMixin
from perms.hands import User, SystemUser
from perms import serializers
__all__ = [
'UserGrantedApplicationSystemUsersApi',
'MyGrantedApplicationSystemUsersApi',
@ -40,7 +39,7 @@ class BaseGrantedApplicationSystemUsersApi(ListAPIView):
application_id = self.kwargs.get('application_id')
application = get_object_or_404(Application, id=application_id)
system_user_ids = self.get_application_system_user_ids(application)
system_users = SystemUser.objects.filter(id__in=system_user_ids)\
system_users = SystemUser.objects.filter(id__in=system_user_ids) \
.only(*self.only_fields).order_by('priority')
return system_users

View File

@ -94,7 +94,7 @@ class RBACPermission(permissions.DjangoModelPermissions):
queryset = self._queryset(view)
model_cls = queryset.model
except Exception as e:
raise e
logger.error(e)
model_cls = None
return model_cls