mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Added a model for logging actions
This commit is contained in:
30
src/pretix/base/models/log.py
Normal file
30
src/pretix/base/models/log.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from django.contrib.contenttypes.fields import GenericForeignKey
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
|
||||
|
||||
class LogEntry(models.Model):
|
||||
"""
|
||||
Represents a change or action that has been performed on another object
|
||||
in the database. This uses django.contrib.contenttypes to allow a
|
||||
relation to an arbitrary database object.
|
||||
|
||||
:param user: The user that performed the action
|
||||
:type user: User
|
||||
:param action_type: The type of action that has been performed. This is
|
||||
used to look up the renderer used to describe the action in a human-
|
||||
readable way. This should be some namespaced value using dotted
|
||||
notationto avaoid duplicates, e.g.
|
||||
``"pretix.plugins.banktransfer.incoming_transfer"``.
|
||||
:type action_type: str
|
||||
:param data: Arbitrary data that can be used by the log action renderer
|
||||
:type data: str
|
||||
"""
|
||||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
|
||||
object_id = models.PositiveIntegerField()
|
||||
content_object = GenericForeignKey('content_type', 'object_id')
|
||||
datetime = models.DateTimeField(auto_now_add=True)
|
||||
user = models.ForeignKey('User', null=True, blank=True, on_delete=models.PROTECT)
|
||||
event = models.ForeignKey('Event', null=True, blank=True, on_delete=models.CASCADE)
|
||||
action_type = models.CharField(max_length=255)
|
||||
data = models.TextField(default='{}')
|
||||
Reference in New Issue
Block a user