From d1645a6db7c768d4760685d232465571d5d07564 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Sat, 25 Feb 2023 16:48:43 +0800 Subject: [PATCH] Allow showing of note timestamp in api --- project/db.sqlite3 | Bin 135168 -> 151552 bytes .../notes/migrations/0004_historicalnote.py | 39 ++++++++++++++++++ .../migrations/0005_delete_historicalnote.py | 16 +++++++ project/notes/serializers.py | 2 +- 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 project/notes/migrations/0004_historicalnote.py create mode 100644 project/notes/migrations/0005_delete_historicalnote.py diff --git a/project/db.sqlite3 b/project/db.sqlite3 index e3d2f6acd84bc7d4c4d9eea803376dab00a86705..d7142be08d032fbd2abab8b2879eceac8d534238 100644 GIT binary patch delta 1458 zcmb7^Pi)&%9LL{_lP2-ny^cU#D1Th9VGB)LCywhRnqUSpX;PLJ$h2LUYsaqR&a*4W zYbioXdw>JIw6dm1NQg2a1md(skOLgHY0`E>{OJV=iQB}V!z3go4hWvtW=TDo^!lTWjGj-AZ0Jey0sZm6=Q9jVdFva2~b@!4_l)mLQQkyV>6 z%ci_6TYJ?h|3D_W43{86ASRAfwQ9EmpO3L@J|#?Mr-c;D;$wCVOTW4m++q;C1<=^R zucO<2HwKpb-|l-jbS8M|z`f{mk-~vv#BF%1_4IN0K5X4tfL{i#e3cBeZk&KT41ihh z_i(YbXu%EG+CB-(Fg8Suj>5I`uB@1ve9^5+y3_dd0{ns)jD;KGak$Z1FT$l*io635 zmr*4MJxFs1WwO*Sl5du``R_7=@!tg3*DGnSIc686EIwZ>{PVrx476hChULckJ2ZkXIrfZ;u=A%5eA`R<&!OQk5-TlN?R1*%m`D$qt@zj^f5lv=g*l z-IYbH%LA`>Alg2DWj81jKIz>hL*8QenLvVU!XN&e`S2Q?y}UYj`7XUV8y+BVBaLA@ LjE%wnq+ifqO4ZER delta 320 zcmZozz}c{XV}i7xG6MsHA`ruX<3t@}M&*qO^Z7Z1d4YnWTuUdj3utdvR4C@!yi_Wd zRcr+VJAXO@|4aTW{JZ(n`MddN@z?NYY*sYz=bxOeFUrcx!>q_LxlvzT0;pY>BeAq3 zBfcQDC^xgXI5S_Inc0|e@_e;yr9dp{g4}@DI*i(gUvtL zb(y(bRm9UT}aZ147AEE5(4iit3!G4N;c z74UB5dBOF3I!6Md+{B4y+tU&l8@aY0cVs-zG~L#larbsN55|5*My}0_5B~cvJHQwK E0F-1~3;+NC diff --git a/project/notes/migrations/0004_historicalnote.py b/project/notes/migrations/0004_historicalnote.py new file mode 100644 index 0000000..a18a794 --- /dev/null +++ b/project/notes/migrations/0004_historicalnote.py @@ -0,0 +1,39 @@ +# Generated by Django 4.1.7 on 2023-02-24 08:29 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone +import simple_history.models + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('notes', '0003_alter_note_content'), + ] + + operations = [ + migrations.CreateModel( + name='HistoricalNote', + fields=[ + ('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')), + ('title', models.CharField(max_length=20)), + ('content', models.CharField(max_length=1024)), + ('date_created', models.DateTimeField(default=django.utils.timezone.now, editable=False)), + ('history_id', models.AutoField(primary_key=True, serialize=False)), + ('history_date', models.DateTimeField(db_index=True)), + ('history_change_reason', models.CharField(max_length=100, null=True)), + ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)), + ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name': 'historical note', + 'verbose_name_plural': 'historical notes', + 'ordering': ('-history_date', '-history_id'), + 'get_latest_by': ('history_date', 'history_id'), + }, + bases=(simple_history.models.HistoricalChanges, models.Model), + ), + ] diff --git a/project/notes/migrations/0005_delete_historicalnote.py b/project/notes/migrations/0005_delete_historicalnote.py new file mode 100644 index 0000000..832316c --- /dev/null +++ b/project/notes/migrations/0005_delete_historicalnote.py @@ -0,0 +1,16 @@ +# Generated by Django 4.1.7 on 2023-02-24 08:53 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('notes', '0004_historicalnote'), + ] + + operations = [ + migrations.DeleteModel( + name='HistoricalNote', + ), + ] diff --git a/project/notes/serializers.py b/project/notes/serializers.py index f07403d..c4c74cd 100644 --- a/project/notes/serializers.py +++ b/project/notes/serializers.py @@ -5,4 +5,4 @@ from .models import Note class NoteSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Note - fields = ('id', 'title', 'content') + fields = ('id', 'title', 'content', 'date_created')