myModel.py 915 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
2
from django.db import models
from django.contrib.auth.models import User
Florent Chehab's avatar
Florent Chehab committed
3
4
from django.contrib.contenttypes.fields import GenericRelation
from .pendingModeration import PendingModeration
Florent Chehab's avatar
Florent Chehab committed
5
6
7
8
9
10
11
12
13
14
15


class MyModel(models.Model):
    """
        All models in the app deppend of this one.
        It contains the required attributes for managing eventual moderation data.

        All the logic behind moderation is done in myModelSerializer
    """

    moderated_by = models.ForeignKey(
16
        User, null=True, on_delete=models.SET_NULL, related_name='+')
Florent Chehab's avatar
Florent Chehab committed
17
18
19
20
    moderated_on = models.DateTimeField(null=True)

    updated_on = models.DateTimeField(null=True)
    updated_by = models.ForeignKey(
21
        User, null=True, on_delete=models.SET_NULL, related_name='+')
Florent Chehab's avatar
Florent Chehab committed
22
    pending_moderation = GenericRelation(PendingModeration)
Florent Chehab's avatar
Florent Chehab committed
23
24
25

    class Meta:
        abstract = True
26

27
28
29
    model_config = {
        "moderation_level": None,
    }