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)