From 54887a3460c6fc175e840f8b07b9dcf972991564 Mon Sep 17 00:00:00 2001 From: jym503558564 <503558564@qq.com> Date: Wed, 20 Nov 2019 17:27:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=AF=A6=E6=83=85=E9=A1=B5=E4=B8=AD=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=BB=84=E6=A0=87=E7=AD=BE=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/users/templates/users/user_detail.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/users/templates/users/user_detail.html b/apps/users/templates/users/user_detail.html index 8e049938c..f8cc0e1d4 100644 --- a/apps/users/templates/users/user_detail.html +++ b/apps/users/templates/users/user_detail.html @@ -212,7 +212,7 @@ - {% if user_object.is_current_org_admin %} + {% if request.user.can_admin_current_org and not user_object.can_audit_current_org%}
{% trans 'User group' %} From cc9554cdb45987a4359f12c268e1d42771cd9b4d Mon Sep 17 00:00:00 2001 From: jym503558564 <503558564@qq.com> Date: Mon, 25 Nov 2019 15:30:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=AF=A6=E6=83=85=E9=A1=B5=E4=B8=AD=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=BB=84=E6=A0=87=E7=AD=BE=E7=9A=84=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=9D=A1=E4=BB=B6=E6=98=AF=EF=BC=9A=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=9A=84=E6=99=AE=E9=80=9A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=88=96=E7=BB=84=E7=AE=A1=E7=90=86=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/orgs/models.py | 5 ++ apps/users/models/user.py | 4 ++ apps/users/templates/users/user_detail.html | 77 +++++++++++---------- 3 files changed, 48 insertions(+), 38 deletions(-) diff --git a/apps/orgs/models.py b/apps/orgs/models.py index c9bdc1f53..f337864fc 100644 --- a/apps/orgs/models.py +++ b/apps/orgs/models.py @@ -118,6 +118,11 @@ class Organization(models.Model): return True return False + def can_user_by(self, user): + if self.get_org_users().filter(id=user.id): + return True + return False + def is_real(self): return self.id not in (self.DEFAULT_NAME, self.ROOT_ID, self.SYSTEM_ID) diff --git a/apps/users/models/user.py b/apps/users/models/user.py index f58422fcd..aaa3bcebb 100644 --- a/apps/users/models/user.py +++ b/apps/users/models/user.py @@ -217,6 +217,10 @@ class RoleMixin: def can_audit_current_org(self): return current_org.can_audit_by(self) + @property + def can_user_current_org(self): + return current_org.can_user_by(self) + @property def can_admin_or_audit_current_org(self): return self.can_admin_current_org or self.can_audit_current_org diff --git a/apps/users/templates/users/user_detail.html b/apps/users/templates/users/user_detail.html index f8cc0e1d4..2c4fad1c9 100644 --- a/apps/users/templates/users/user_detail.html +++ b/apps/users/templates/users/user_detail.html @@ -211,46 +211,47 @@
+ {% if request.user.can_admin_current_org %} + {% if user_object.can_user_current_org or user_object.can_admin_current_org %} +
+
+ {% trans 'User group' %} +
+
+ + + + + + + + + + - {% if request.user.can_admin_current_org and not user_object.can_audit_current_org%} -
-
- {% trans 'User group' %} + {% for group in user_object.groups.all %} +
+ + + + {% endfor %} + +
+ +
+ +
+ {{ group.name }} + + +
+
-
- - - - - - - - - - - - {% for group in user_object.groups.all %} - - - - - {% endfor %} - -
- -
- -
- {{ group.name }} - - -
-
- + {% endif %} {% endif %}