Skip to content

Commit

Permalink
Versions: add timestamp fields
Browse files Browse the repository at this point in the history
This is to allow us to track the latest updated date.
  • Loading branch information
stsewd committed Nov 18, 2020
1 parent 6849d74 commit ee4489d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
24 changes: 24 additions & 0 deletions readthedocs/builds/migrations/0029_add_time_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 2.2.16 on 2020-11-18 16:26

from django.db import migrations
import django_extensions.db.fields


class Migration(migrations.Migration):

dependencies = [
('builds', '0028_add_delete_version_action'),
]

operations = [
migrations.AddField(
model_name='version',
name='created',
field=django_extensions.db.fields.CreationDateTimeField(auto_now_add=True, null=True, verbose_name='created'),
),
migrations.AddField(
model_name='version',
name='modified',
field=django_extensions.db.fields.ModificationDateTimeField(auto_now=True, verbose_name='modified'),
),
]
11 changes: 10 additions & 1 deletion readthedocs/builds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from django.utils import timezone
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
from django_extensions.db.fields import CreationDateTimeField
from django_extensions.db.models import TimeStampedModel
from jsonfield import JSONField
from polymorphic.models import PolymorphicModel
Expand Down Expand Up @@ -88,10 +89,18 @@
log = logging.getLogger(__name__)


class Version(models.Model):
class Version(TimeStampedModel):

"""Version of a ``Project``."""

# Overridden from TimeStampedModel just to allow null values.
# TODO: remove after deploy.
created = CreationDateTimeField(
_('created'),
null=True,
blank=True,
)

project = models.ForeignKey(
Project,
verbose_name=_('Project'),
Expand Down

0 comments on commit ee4489d

Please sign in to comment.