From c96cfc38eefa3a8199753ca17faa861107bb13c5 Mon Sep 17 00:00:00 2001
From: Jorran Wit <jorrandewit@outlook.com>
Date: Tue, 13 Dec 2016 23:33:55 +0100
Subject: [PATCH] Make migrations for added field on Commentary

Commentary model inherits from TimeStampedModel now. It
also includes migrations related to the inheritance:
 - Add added field on Commentary
 - Alter field last_activity on Commentary
---
 .../migrations/0013_auto_20161213_2328.py     | 27 +++++++++++++++++++
 commentaries/models.py                        |  5 ++--
 2 files changed, 29 insertions(+), 3 deletions(-)
 create mode 100644 commentaries/migrations/0013_auto_20161213_2328.py

diff --git a/commentaries/migrations/0013_auto_20161213_2328.py b/commentaries/migrations/0013_auto_20161213_2328.py
new file mode 100644
index 000000000..ec27da036
--- /dev/null
+++ b/commentaries/migrations/0013_auto_20161213_2328.py
@@ -0,0 +1,27 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.3 on 2016-12-13 22:28
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.utils.timezone
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('commentaries', '0012_remove_commentary_specialization'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='commentary',
+            name='created',
+            field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now),
+            preserve_default=False,
+        ),
+        migrations.AlterField(
+            model_name='commentary',
+            name='latest_activity',
+            field=models.DateTimeField(auto_now=True),
+        ),
+    ]
diff --git a/commentaries/models.py b/commentaries/models.py
index c216ce359..b7b570150 100644
--- a/commentaries/models.py
+++ b/commentaries/models.py
@@ -5,7 +5,7 @@ from django.contrib.postgres.fields import JSONField
 from django.template import Template, Context
 
 from journals.models import SCIPOST_JOURNALS_DOMAINS, SCIPOST_JOURNALS_SPECIALIZATIONS
-from scipost.models import Contributor
+from scipost.models import TimeStampedModel, Contributor
 from scipost.models import SCIPOST_DISCIPLINES, SCIPOST_SUBJECT_AREAS
 
 
@@ -15,7 +15,7 @@ COMMENTARY_TYPES = (
     ('preprint', 'arXiv preprint'),
     )
 
-class Commentary(models.Model):
+class Commentary(TimeStampedModel):
     """
     A Commentary contains all the contents of a SciPost Commentary page for a given publication.
     """
@@ -55,7 +55,6 @@ class Commentary(models.Model):
     pages = models.CharField(max_length=50, blank=True, null=True)
     pub_date = models.DateField(verbose_name='date of original publication', blank=True, null=True)
     pub_abstract = models.TextField(verbose_name='abstract')
-    latest_activity = models.DateTimeField(default=timezone.now)
 
     class Meta:
         verbose_name_plural = 'Commentaries'
-- 
GitLab