mirror of
https://github.com/pretix/pretix.git
synced 2026-05-04 15:04:03 +00:00
44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
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 datatime: The timestamp of the logged action
|
|
:type datetime: datetime
|
|
: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
|
|
notation to avoid 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(db_index=True)
|
|
content_object = GenericForeignKey('content_type', 'object_id')
|
|
datetime = models.DateTimeField(auto_now_add=True, db_index=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='{}')
|
|
|
|
class Meta:
|
|
ordering = ('-datetime', )
|
|
|
|
def display(self):
|
|
from ..signals import logentry_display
|
|
|
|
for receiver, response in logentry_display.send(self.event, logentry=self):
|
|
if response:
|
|
return response
|
|
return self.action_type
|