From 0def7bcb965d56cfa88c7e5a1676905b02f84ab6 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Wed, 28 Nov 2018 15:43:31 +0100 Subject: [PATCH] track change time in book user data --- .../0004_bookuserdata_last_changed.py | 22 +++++++++++++++++++ src/api/models.py | 1 + 2 files changed, 23 insertions(+) create mode 100644 src/api/migrations/0004_bookuserdata_last_changed.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 index 000000000..f42c4054e --- /dev/null +++ b/src/api/migrations/0004_bookuserdata_last_changed.py @@ -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, + ), + ] diff --git a/src/api/models.py b/src/api/models.py index cc71a06f3..2481010be 100644 --- a/src/api/models.py +++ b/src/api/models.py @@ -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' -- 2.20.1