From 4c05d5eeaff6b6dddc1fb909405b7df2d0c11809 Mon Sep 17 00:00:00 2001 From: vapao Date: Mon, 30 Mar 2020 11:46:33 +0800 Subject: [PATCH] =?UTF-8?q?U=20ldap=E8=B4=A6=E6=88=B7=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E8=A2=AB=E5=88=A0=E9=99=A4=EF=BC=8C=E5=8F=AF?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=A6=81=E7=94=A8=E5=8A=9F=E8=83=BD=E4=BB=A3?= =?UTF-8?q?=E6=9B=BF=20#42?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apps/account/management/commands/update.py | 17 +++++++++++++++++ spug_api/apps/account/views.py | 11 +++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 spug_api/apps/account/management/commands/update.py diff --git a/spug_api/apps/account/management/commands/update.py b/spug_api/apps/account/management/commands/update.py new file mode 100644 index 0000000..00af4d8 --- /dev/null +++ b/spug_api/apps/account/management/commands/update.py @@ -0,0 +1,17 @@ +# Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug +# Copyright: (c) +# Released under the MIT License. +from django.core.management.base import BaseCommand +from django.core.management import execute_from_command_line +from django.conf import settings + + +class Command(BaseCommand): + help = '升级Spug版本' + + def add_arguments(self, parser): + parser.add_argument('version', help='要升级的版本') + + def handle(self, *args, **options): + + self.stdout.write(self.style.SUCCESS('升级成功')) diff --git a/spug_api/apps/account/views.py b/spug_api/apps/account/views.py index bcceb61..3b58d75 100644 --- a/spug_api/apps/account/views.py +++ b/spug_api/apps/account/views.py @@ -56,10 +56,13 @@ class UserView(View): Argument('id', type=int, help='请指定操作对象') ).parse(request.GET) if error is None: - User.objects.filter(pk=form.id).update( - deleted_at=human_datetime(), - deleted_by=request.user - ) + user = User.objects.filter(pk=form.id).first() + if user: + if user.type == 'ldap': + return json_response(error='ldap账户无法删除,请使用禁用功能来禁止该账户访问系统') + user.deleted_at = human_datetime() + user.deleted_by = request.user + user.save() return json_response(error=error)