track change time in book user data
authorJan Szejko <janek37@gmail.com>
Wed, 28 Nov 2018 14:43:31 +0000 (15:43 +0100)
committerJan Szejko <janek37@gmail.com>
Wed, 28 Nov 2018 14:43:31 +0000 (15:43 +0100)
src/api/migrations/0004_bookuserdata_last_changed.py [new file with mode: 0644]
src/api/models.py

diff --git a/src/api/migrations/0004_bookuserdata_last_changed.py b/src/api/migrations/0004_bookuserdata_last_changed.py
new file mode 100644 (file)
index 0000000..f42c405
--- /dev/null
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import datetime
+from django.utils.timezone import utc
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('api', '0003_bookuserdata'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='bookuserdata',
+            name='last_changed',
+            field=models.DateTimeField(default=datetime.datetime(2018, 11, 28, 14, 41, 2, 673054, tzinfo=utc), auto_now=True),
+            preserve_default=False,
+        ),
+    ]
index cc71a06..2481010 100644 (file)
@@ -45,6 +45,7 @@ class BookUserData(models.Model):
     book = models.ForeignKey(Book)
     user = models.ForeignKey(User)
     complete = models.BooleanField(default=False)
+    last_changed = models.DateTimeField(auto_now=True)
 
     def get_state(self):
         return 'complete' if self.complete else 'reading'