U ldap账户不再允许被删除,可使用禁用功能代替 #42

pull/59/head
vapao 2020-03-30 11:46:33 +08:00
parent ce9adb1129
commit 4c05d5eeaf
2 changed files with 24 additions and 4 deletions

View File

@ -0,0 +1,17 @@
# Copyright: (c) OpenSpug Organization. https://github.com/openspug/spug
# Copyright: (c) <spug.dev@gmail.com>
# 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('升级成功'))

View File

@ -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)