-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,130 additions
and
558 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,50 @@ | ||
"""Helpers for module "django.db.models". | ||
https://docs.djangoproject.com/en/3.2/ref/models/ | ||
""" | ||
© Ocado Group | ||
Created on 04/12/2023 at 14:36:56(+00:00). | ||
Base models. | ||
""" | ||
|
||
import typing as t | ||
|
||
from django.db.models import Model as _Model | ||
from django.db import models | ||
from django.utils.translation import gettext_lazy as _ | ||
|
||
from .fields import * | ||
|
||
class Model(_Model): | ||
"""A base class for all Django models. | ||
|
||
Args: | ||
_Model (django.db.models.Model): Django's model class. | ||
""" | ||
class AbstractModel(models.Model): | ||
"""Base model to be inherited by other models throughout the CFL system.""" | ||
|
||
id: int | ||
pk: int | ||
|
||
|
||
AnyModel = t.TypeVar("AnyModel", bound=Model) | ||
# https://docs.djangoproject.com/en/3.2/ref/models/fields/#django.db.models.DateField.auto_now | ||
last_saved_at = models.DateTimeField( | ||
_("last saved at"), | ||
auto_now=True, | ||
help_text=_( | ||
"Record the last time the model was saved. This is used by our data" | ||
" warehouse to know what data was modified since the last scheduled" | ||
" data transfer from the database to the data warehouse." | ||
), | ||
) | ||
|
||
delete_after = models.DateTimeField( | ||
_("delete after"), | ||
null=True, | ||
blank=True, | ||
help_text=_( | ||
"When this data is scheduled for deletion. Set to null if not" | ||
" scheduled for deletion. This is used by our data warehouse to" | ||
" transfer data that's been scheduled for deletion before it's" | ||
" actually deleted. Data will actually be deleted in a CRON job" | ||
" after this delete after." | ||
), | ||
) | ||
|
||
class Meta: | ||
abstract = True | ||
|
||
|
||
AnyModel = t.TypeVar("AnyModel", bound=AbstractModel) |
Oops, something went wrong.