| author | ymh <ymh.work@gmail.com> |
| Wed, 19 Jul 2017 15:57:13 +0200 | |
| changeset 119 | 8ff8e2aee0f9 |
| parent 24 | 3b3999550508 |
| permissions | -rw-r--r-- |
| 24 | 1 |
""" |
2 |
base abstract models |
|
3 |
""" |
|
4 |
import uuid |
|
5 |
||
6 |
from concurrency.fields import AutoIncVersionField |
|
7 |
from django.db import models |
|
8 |
from django.utils.translation import ugettext_lazy as _ |
|
9 |
||
10 |
||
11 |
class ModelManager(models.Manager): |
|
12 |
def get_by_natural_key(self, ext_id): |
|
13 |
return self.get(ext_id=ext_id) |
|
14 |
||
15 |
class Model(models.Model): |
|
16 |
objects = ModelManager() |
|
17 |
||
|
119
8ff8e2aee0f9
add parameter to filter session and note by updated date. Add pagination on sessions and notes. add read only endpoint at root level to list notes
ymh <ymh.work@gmail.com>
parents:
24
diff
changeset
|
18 |
created = models.DateTimeField(auto_now_add=True, verbose_name=_('Model|created'), db_index=True) |
|
8ff8e2aee0f9
add parameter to filter session and note by updated date. Add pagination on sessions and notes. add read only endpoint at root level to list notes
ymh <ymh.work@gmail.com>
parents:
24
diff
changeset
|
19 |
updated = models.DateTimeField(auto_now=True, verbose_name=_('Model|updated'), db_index=True) |
| 24 | 20 |
ext_id = models.UUIDField(unique=True, default=uuid.uuid4, verbose_name=_('Model|ext_id')) |
21 |
version = AutoIncVersionField(verbose_name=_('Model|version')) |
|
22 |
||
23 |
def natural_key(self): |
|
24 |
return (self.ext_id, ) |
|
25 |
||
26 |
class Meta: |
|
27 |
abstract = True |