From 2efab8874b6cffff1dd3fa7b9b177d778f227c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E4=BD=A9=E7=8F=8A=5Bshiisa=5D?= Date: Wed, 20 Oct 2021 17:46:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=A1=E8=AE=A1=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E8=AE=B0=E5=BD=95=20#71?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0004_auto_20211021_1852.py | 18 ++++++++++++++++++ src/api/bkuser_core/categories/views.py | 6 +++--- src/api/bkuser_core/profiles/views.py | 3 +-- .../0009_alter_settingmeta_category_type.py | 18 ++++++++++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 src/api/bkuser_core/audit/migrations/0004_auto_20211021_1852.py create mode 100644 src/api/bkuser_core/user_settings/migrations/0009_alter_settingmeta_category_type.py diff --git a/src/api/bkuser_core/audit/migrations/0004_auto_20211021_1852.py b/src/api/bkuser_core/audit/migrations/0004_auto_20211021_1852.py new file mode 100644 index 000000000..5f76a6a23 --- /dev/null +++ b/src/api/bkuser_core/audit/migrations/0004_auto_20211021_1852.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.5 on 2021-10-21 10:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('audit', '0003_auto_20210516_1652'), + ] + + operations = [ + migrations.AddField( + model_name='generallog', + name='status', + field=models.CharField(choices=[('succeed', '成功'), ('failed', '失败')], default='successed', max_length=16, verbose_name='状态'), + ), + ] diff --git a/src/api/bkuser_core/categories/views.py b/src/api/bkuser_core/categories/views.py index 2287eb341..95eb58d34 100644 --- a/src/api/bkuser_core/categories/views.py +++ b/src/api/bkuser_core/categories/views.py @@ -39,7 +39,7 @@ from django.utils.decorators import method_decorator from django.utils.module_loading import import_string from drf_yasg.utils import swagger_auto_schema -from rest_framework import filters +from rest_framework import filters, status from rest_framework.decorators import action from rest_framework.parsers import FormParser, MultiPartParser from rest_framework.response import Response @@ -112,7 +112,7 @@ def create(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) instance = serializer.save() - # headers = self.get_success_headers(serializer.data) + headers = self.get_success_headers(serializer.data) # 默认添加到最后 TODO: 需要一个更优雅的实现 max_order = ProfileCategory.objects.get_max_order() @@ -125,6 +125,7 @@ def create(self, request, *args, **kwargs): operator_obj=instance, request=request, ) + return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers) def get_serializer(self, *args, **kwargs): if self.action in ["create"]: @@ -132,7 +133,6 @@ def get_serializer(self, *args, **kwargs): else: return self.serializer_class(*args, **kwargs) - # @method_decorator(audit_error_general_log) @audit_error_general_log(operate_type=OperationEnum.UPDATE.value) @method_decorator(clear_cache_if_succeed) def update(self, request, *args, **kwargs): diff --git a/src/api/bkuser_core/profiles/views.py b/src/api/bkuser_core/profiles/views.py index 277400391..f036e340a 100644 --- a/src/api/bkuser_core/profiles/views.py +++ b/src/api/bkuser_core/profiles/views.py @@ -14,7 +14,7 @@ from collections import defaultdict from operator import or_ -from bkuser_core.audit.constants import LogInFailReasonEnum, OperationEnum, OperationStatusEnum +from bkuser_core.audit.constants import LogInFailReasonEnum, OperationEnum from bkuser_core.audit.utils import create_general_log, create_profile_log from bkuser_core.categories.constants import CategoryType from bkuser_core.categories.loader import get_plugin_by_category @@ -427,7 +427,6 @@ def modify_password(self, request, *args, **kwargs): operator=request.operator, extra_values=modify_summary, operation_type=OperationEnum.UPDATE.value, - status=OperationStatusEnum.SUCCEED.value, ) return Response(data=local_serializers.ProfileMinimalSerializer(instance).data) diff --git a/src/api/bkuser_core/user_settings/migrations/0009_alter_settingmeta_category_type.py b/src/api/bkuser_core/user_settings/migrations/0009_alter_settingmeta_category_type.py new file mode 100644 index 000000000..4c6ac42bd --- /dev/null +++ b/src/api/bkuser_core/user_settings/migrations/0009_alter_settingmeta_category_type.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.5 on 2021-09-26 11:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('user_settings', '0008_auto_20210706_1702'), + ] + + operations = [ + migrations.AlterField( + model_name='settingmeta', + name='category_type', + field=models.CharField(choices=[('local', '本地目录'), ('mad', 'Microsoft Active Directory'), ('ldap', 'OpenLDAP'), ('tof', 'TOF'), ('custom', '自定义目录'), ('pluggable', '可插拔目录')], max_length=32, verbose_name='类型'), + ), + ]