From: Jan Szejko Date: Wed, 28 Nov 2018 14:43:31 +0000 (+0100) Subject: track change time in book user data X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/0def7bcb965d56cfa88c7e5a1676905b02f84ab6?ds=sidebyside;hp=--cc track change time in book user data --- 0def7bcb965d56cfa88c7e5a1676905b02f84ab6 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'