Enforce type of log data

This commit is contained in:
Raphael Michel
2019-01-28 09:09:39 +01:00
parent 303ed07504
commit 51a8bac9e6

View File

@@ -76,8 +76,10 @@ class LoggingMixin:
kwargs['api_token'] = api_token
logentry = LogEntry(content_object=self, user=user, action_type=action, event=event, **kwargs)
if data:
if isinstance(data, dict):
logentry.data = json.dumps(data, cls=CustomJSONEncoder)
elif data:
raise TypeError("You should only supply dictionaries as log data.")
if save:
logentry.save()