perf: 优化各serializer字段翻译

This commit is contained in:
ibuler
2021-03-11 20:09:23 +08:00
committed by Jiangjie.Bai
parent 5f48e7aeb2
commit 09303ecc56
8 changed files with 40 additions and 28 deletions

View File

@@ -667,6 +667,13 @@ class User(AuthMixin, TokenMixin, RoleMixin, MFAMixin, AbstractUser):
else:
return user_default
@property
def login_blocked(self):
key_prefix_block = "_LOGIN_BLOCK_{}"
key_block = key_prefix_block.format(self.username)
blocked = bool(cache.get(key_block))
return blocked
def delete(self, using=None, keep_parents=False):
if self.pk == 1 or self.username == 'admin':
return