module.py 861 Bytes
Newer Older
Florent Chehab's avatar
Florent Chehab committed
1
from django.db import models
Florent Chehab's avatar
Florent Chehab committed
2
from reversion.models import Version
Florent Chehab's avatar
Florent Chehab committed
3
4
5


class Module(models.Model):
Florent Chehab's avatar
Florent Chehab committed
6

Florent Chehab's avatar
Florent Chehab committed
7
8
9
10
    module_icon = "You forget to override the icon in the sub-class"
    module_name = "You forget to override the name in the sub-class"
    module_description = "You forget to override the description in the sub-class"

Florent Chehab's avatar
Florent Chehab committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
    def modified_date(self):
        try:
            v = Version.objects.get_for_object(self)
            return v.last().revision.date_created
        except AttributeError:
            return None

    def modified_by(self):
        try:
            v = Version.objects.get_for_object(self)
            user = v.last().revision.user
            return {'user_name': user.get_full_name(), 'user_id': user.pk}
        except AttributeError:
            return None

Florent Chehab's avatar
Florent Chehab committed
26
27
28
29
30
31
32
    class Meta:
        abstract = True


"""
API RELATED STUFF BELLOW
"""