From 1b4a2b8f6a0ac73beab7641f7a0ba908cd4e1af5 Mon Sep 17 00:00:00 2001 From: Her Email Date: Mon, 20 Nov 2023 19:31:31 -0500 Subject: [PATCH] fix edited_time --- ...9_alter_collection_edited_time_and_more.py | 63 +++++++++++++++++++ journal/models/common.py | 4 +- journal/models/itemlist.py | 4 +- journal/models/like.py | 2 +- journal/views/collection.py | 1 - requirements.txt | 4 +- takahe/urls.py | 2 +- 7 files changed, 70 insertions(+), 10 deletions(-) create mode 100644 journal/migrations/0019_alter_collection_edited_time_and_more.py diff --git a/journal/migrations/0019_alter_collection_edited_time_and_more.py b/journal/migrations/0019_alter_collection_edited_time_and_more.py new file mode 100644 index 00000000..8d457011 --- /dev/null +++ b/journal/migrations/0019_alter_collection_edited_time_and_more.py @@ -0,0 +1,63 @@ +# Generated by Django 4.2.7 on 2023-11-21 00:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("journal", "0018_shelflogentrypost_shelflogentry_posts_and_more"), + ] + + operations = [ + migrations.AlterField( + model_name="collection", + name="edited_time", + field=models.DateTimeField(auto_now=True), + ), + migrations.AlterField( + model_name="collectionmember", + name="edited_time", + field=models.DateTimeField(auto_now=True), + ), + migrations.AlterField( + model_name="comment", + name="edited_time", + field=models.DateTimeField(auto_now=True), + ), + migrations.AlterField( + model_name="like", + name="edited_time", + field=models.DateTimeField(auto_now=True), + ), + migrations.AlterField( + model_name="rating", + name="edited_time", + field=models.DateTimeField(auto_now=True), + ), + migrations.AlterField( + model_name="review", + name="edited_time", + field=models.DateTimeField(auto_now=True), + ), + migrations.AlterField( + model_name="shelf", + name="edited_time", + field=models.DateTimeField(auto_now=True), + ), + migrations.AlterField( + model_name="shelfmember", + name="edited_time", + field=models.DateTimeField(auto_now=True), + ), + migrations.AlterField( + model_name="tag", + name="edited_time", + field=models.DateTimeField(auto_now=True), + ), + migrations.AlterField( + model_name="tagmember", + name="edited_time", + field=models.DateTimeField(auto_now=True), + ), + ] diff --git a/journal/models/common.py b/journal/models/common.py index 8d01aae0..9a72d631 100644 --- a/journal/models/common.py +++ b/journal/models/common.py @@ -235,9 +235,7 @@ class Content(Piece): default=0 ) # 0: Public / 1: Follower only / 2: Self only created_time = models.DateTimeField(default=timezone.now) - edited_time = models.DateTimeField( - default=timezone.now - ) # auto_now=True FIXME revert this after migration + edited_time = models.DateTimeField(auto_now=True) metadata = models.JSONField(default=dict) item = models.ForeignKey(Item, on_delete=models.PROTECT) remote_id = models.CharField(max_length=200, null=True, default=None) diff --git a/journal/models/itemlist.py b/journal/models/itemlist.py index f70a0497..f06c00a7 100644 --- a/journal/models/itemlist.py +++ b/journal/models/itemlist.py @@ -23,7 +23,7 @@ class List(Piece): default=0 ) # 0: Public / 1: Follower only / 2: Self only created_time = models.DateTimeField(default=timezone.now) - edited_time = models.DateTimeField(default=timezone.now) + edited_time = models.DateTimeField(auto_now=True) metadata = models.JSONField(default=dict) class Meta: @@ -148,7 +148,7 @@ class ListMember(Piece): default=0 ) # 0: Public / 1: Follower only / 2: Self only created_time = models.DateTimeField(default=timezone.now) - edited_time = models.DateTimeField(default=timezone.now) + edited_time = models.DateTimeField(auto_now=True) metadata = models.JSONField(default=dict) item = models.ForeignKey(Item, on_delete=models.PROTECT) position = models.PositiveIntegerField() diff --git a/journal/models/like.py b/journal/models/like.py index 1601edfb..6fc53499 100644 --- a/journal/models/like.py +++ b/journal/models/like.py @@ -14,7 +14,7 @@ class Like(Piece): # TODO remove default=0 ) # 0: Public / 1: Follower only / 2: Self only created_time = models.DateTimeField(default=timezone.now) - edited_time = models.DateTimeField(default=timezone.now) + edited_time = models.DateTimeField(auto_now=True) target = models.ForeignKey(Piece, on_delete=models.CASCADE, related_name="likes") @staticmethod diff --git a/journal/views/collection.py b/journal/views/collection.py index a15558e9..723d0398 100644 --- a/journal/views/collection.py +++ b/journal/views/collection.py @@ -279,7 +279,6 @@ def collection_edit(request: AuthedHttpRequest, collection_uuid=None): if form.is_valid(): if not collection: form.instance.owner = request.user.identity - form.instance.edited_time = timezone.now() form.save() return redirect( reverse("journal:collection_retrieve", args=[form.instance.uuid]) diff --git a/requirements.txt b/requirements.txt index 7b3c46cc..f2aa239e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,9 @@ cachetools dateparser discord.py -django~=4.2.6 +django~=4.2.7 django-anymail -django-auditlog>=3.0.0-beta.2 +django-auditlog>=3.0.0-beta.3 django-bleach django-compressor django-cors-headers diff --git a/takahe/urls.py b/takahe/urls.py index 03b40de9..c010c8bb 100644 --- a/takahe/urls.py +++ b/takahe/urls.py @@ -2,7 +2,7 @@ from .views import * -app_name = "users" +app_name = "takahe" urlpatterns = [ path("auth/login/", auth_login, name="auth_login"), path("auth/logout/", auth_logout, name="auth_logout"),