Commit 9b371557 authored by jym503558564's avatar jym503558564

[Update] 修改变量名小问题

parent 9cefc625
......@@ -20,7 +20,7 @@ class OrgMiddleware:
org = get_org_from_request(request)
if org.can_admin_by(request.user):
return
if org.can_auditor_by(request.user):
if org.can_audit_by(request.user):
return
admin_orgs = Organization.get_user_admin_orgs(request.user)
if admin_orgs:
......
......@@ -11,7 +11,7 @@ class Organization(models.Model):
name = models.CharField(max_length=128, unique=True, verbose_name=_("Name"))
users = models.ManyToManyField('users.User', related_name='orgs', blank=True)
admins = models.ManyToManyField('users.User', related_name='admin_orgs', blank=True)
auditors = models.ManyToManyField('users.User', related_name='auditor_orgs', blank=True)
auditors = models.ManyToManyField('users.User', related_name='audit_orgs', blank=True)
created_by = models.CharField(max_length=32, null=True, blank=True, verbose_name=_('Created by'))
date_created = models.DateTimeField(auto_now_add=True, null=True, blank=True, verbose_name=_('Date created'))
comment = models.TextField(max_length=128, default='', blank=True, verbose_name=_('Comment'))
......@@ -94,7 +94,7 @@ class Organization(models.Model):
return True
return False
def can_auditor_by(self, user):
def can_audit_by(self, user):
if user in list(self.get_org_auditors()):
return True
return False
......@@ -113,7 +113,7 @@ class Organization(models.Model):
elif user.is_org_admin:
admin_orgs = user.admin_orgs.all()
elif user.is_auditor:
admin_orgs = user.auditor_orgs.all()
admin_orgs = user.audit_orgs.all()
if not admin_orgs:
admin_orgs = [cls.default()]
return admin_orgs
......
......@@ -165,13 +165,13 @@ class RoleMixin:
return self.role == 'Auditor'
@property
def auditor_orgs(self):
def audit_orgs(self):
from orgs.models import Organization
return Organization.get_user_admin_orgs(self)
@property
def is_org_auditor(self):
if self.is_auditor and self.auditor_orgs.exists():
if self.is_auditor and self.audit_orgs.exists():
return True
else:
return False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment