From 51a53e3f3254d7ecb14ca92ea931575556b2a91c Mon Sep 17 00:00:00 2001
From: Jorran Wit <jorrandewit@outlook.com>
Date: Tue, 13 Dec 2016 23:11:32 +0100
Subject: [PATCH] Extend the core model an abstract timestamp object

The core model is extended with an abstract model called
TimeStampedModel. Future and existing models should
inherit from this model to include the default timestamp fields.
---
 scipost/models.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/scipost/models.py b/scipost/models.py
index bc1395d9a..e55e21212 100644
--- a/scipost/models.py
+++ b/scipost/models.py
@@ -179,6 +179,19 @@ TITLE_CHOICES = (
 title_dict = dict(TITLE_CHOICES)
 
 
+class TimeStampedModel(models.Model):
+    """
+    All objects should inherit from this abstract model.
+    This will ensure the creation of created and modified
+    timestamps in the objects.
+    """
+    created = models.DateTimeField(auto_now_add=True)
+    latest_activity = models.DateTimeField(auto_now=True)
+
+    class Meta:
+        abstract = True
+
+
 class Contributor(models.Model):
     """
     All users of SciPost are Contributors.
@@ -258,7 +271,7 @@ class Contributor(models.Model):
 
     def public_info_as_table(self):
         """Prints out all publicly-accessible info as a table."""
-        
+
         template = Template('''
             <table>
             <tr><td>Title: </td><td>&nbsp;</td><td>{{ title }}</td></tr>
-- 
GitLab