forked from pythonprobr/pythonpro-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
42 lines (30 loc) · 1.1 KB
/
models.py
File metadata and controls
42 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import uuid
from django.utils import timezone
from django.db import models
from django.db.models import JSONField
from pythonpro.core.models import User
class BaseModel(models.Model):
class Meta:
abstract = True
created = models.DateTimeField('Criado em', default=timezone.now)
updated = models.DateTimeField('Alterado em', auto_now=True)
class UserSession(BaseModel):
class Meta:
verbose_name = 'sessão'
verbose_name_plural = 'sessões'
uuid = models.UUIDField(default=uuid.uuid4, editable=False)
user = models.ForeignKey(User,
on_delete=models.SET_NULL,
null=True,
blank=True)
def __str__(self):
return str(self.uuid)
class PageView(BaseModel):
class Meta:
verbose_name = 'page view'
verbose_name_plural = 'page views'
session = models.ForeignKey(UserSession,
verbose_name='sessão',
on_delete=models.SET_NULL,
null=True)
meta = JSONField()