summaryrefslogtreecommitdiffstats
path: root/users/models/user_event.py
blob: 858f334dcf4b0fd6cdebcf9192b4dc2bda53b808 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from django.db import models


class UserEvent(models.Model):
    """
    Tracks major events that happen to users
    """

    class EventType(models.TextChoices):
        created = "created"
        reset_password = "reset_password"
        banned = "banned"

    user = models.ForeignKey(
        "users.User",
        on_delete=models.CASCADE,
        related_name="events",
    )

    date = models.DateTimeField(auto_now_add=True)
    type = models.CharField(max_length=100, choices=EventType.choices)
    data = models.JSONField(blank=True, null=True)