Browse Source

fix: 修复多对多审计内容太长报错&全局组织没有审计

pull/6595/head
xinwen 3 years ago committed by 老广
parent
commit
66b499b8e3
  1. 7
      apps/audits/models.py
  2. 2
      apps/audits/signals_handler.py

7
apps/audits/models.py

@ -5,7 +5,7 @@ from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
from orgs.mixins.models import OrgModelMixin
from orgs.mixins.models import OrgModelMixin, Organization
from orgs.utils import current_org
__all__ = [
@ -63,6 +63,11 @@ class OperateLog(OrgModelMixin):
def __str__(self):
return "<{}> {} <{}>".format(self.user, self.action, self.resource)
def save(self, *args, **kwargs):
if current_org.is_root() and not self.org_id:
self.org_id = Organization.ROOT_ID
return super(OperateLog, self).save(*args, **kwargs)
class PasswordChangeLog(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)

2
apps/audits/signals_handler.py

@ -199,7 +199,7 @@ def on_m2m_changed(sender, action, instance, reverse, model, pk_set, **kwargs):
resource = resource_tmpl.format(**{
instance_name: instance_value,
model_name: str(obj)
})
})[:128] # `resource` 字段只有 128 个字符长 😔
to_create.append(OperateLog(
user=user, action=action, resource_type=resource_type,

Loading…
Cancel
Save