From 4dc5d7d70ea9323ea351ad7173ce44b61bce39cd Mon Sep 17 00:00:00 2001 From: ibuler Date: Tue, 19 Nov 2019 10:26:01 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E6=8D=A2=E5=81=9Alazyproperty?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/users/models/user.py | 5 ++--- apps/users/templates/users/user_profile.html | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/apps/users/models/user.py b/apps/users/models/user.py index d9bbfe74f..67e75b569 100644 --- a/apps/users/models/user.py +++ b/apps/users/models/user.py @@ -10,7 +10,6 @@ from django.conf import settings from django.contrib.auth.hashers import make_password from django.contrib.auth.models import AbstractUser from django.core.cache import cache -from django.core.exceptions import ObjectDoesNotExist from django.db import models from django.utils.translation import ugettext_lazy as _ @@ -18,7 +17,7 @@ from django.utils import timezone from django.shortcuts import reverse from orgs.utils import current_org -from common.utils import get_signer, date_expired_default, get_logger +from common.utils import get_signer, date_expired_default, get_logger, lazyproperty from common import fields @@ -217,7 +216,7 @@ class RoleMixin: from orgs.models import Organization return Organization.get_user_admin_or_audit_orgs(self) - @property + @lazyproperty def is_org_admin(self): if self.is_superuser or self.related_admin_orgs.exists(): return True diff --git a/apps/users/templates/users/user_profile.html b/apps/users/templates/users/user_profile.html index 314e86ac3..8c9088504 100644 --- a/apps/users/templates/users/user_profile.html +++ b/apps/users/templates/users/user_profile.html @@ -173,16 +173,6 @@ - {% if request.user.can_update_password %} - - {% trans 'Update password' %}: - - - {% trans 'Update' %} - - - - {% endif %} {% if request.user.mfa_enabled %} {% trans 'Update MFA' %}: @@ -193,6 +183,16 @@ {% endif %} + {% if request.user.can_update_password %} + + {% trans 'Update password' %}: + + + {% trans 'Update' %} + + + + {% endif %} {% if request.user.can_update_ssh_key %} {% trans 'Update SSH public key' %}: