from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models from core.http.models import User class Monitoring(models.Model): content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) object_id = models.PositiveIntegerField() content_object = GenericForeignKey("content_type", "object_id") action = models.CharField(max_length=255) user_id = models.ForeignKey( to=User, on_delete=models.CASCADE, related_name="monitoring" ) timestamp = models.DateTimeField(auto_now_add=True) created_by = models.CharField(max_length=255, null=True, blank=True) created_who = models.CharField(max_length=255, null=True, blank=True) comment = models.CharField(max_length=255, null=True, blank=True) reason = models.CharField(max_length=255, null=True, blank=True) price = models.DecimalField( max_digits=30, decimal_places=2, default=0, null=True, blank=True ) class Meta: ordering = ["-timestamp"]