audit: log event creation on save

This commit is contained in:
Jens Langhammer 2020-02-18 17:05:11 +01:00
parent 7c353f9297
commit 591d2f89a1
1 changed files with 6 additions and 1 deletions

View File

@ -100,7 +100,6 @@ class Event(UUIDModel):
app = getmodule(stack()[_inspect_offset][0]).__name__
cleaned_kwargs = sanitize_dict(kwargs)
event = Event(action=action.value, app=app, context=cleaned_kwargs)
LOGGER.debug("Created Audit event", action=action, context=cleaned_kwargs)
return event
def from_http(
@ -129,6 +128,12 @@ class Event(UUIDModel):
raise ValidationError(
"you may not edit an existing %s" % self._meta.model_name
)
LOGGER.debug(
"Created Audit event",
action=self.action,
context=self.context,
client_ip=self.client_ip,
)
return super().save(*args, **kwargs)
class Meta: