From 17fd44cc9e5ee1ccb518a42be05be6114027c6b1 Mon Sep 17 00:00:00 2001 From: rafalp Date: Sat, 7 Sep 2024 13:47:14 +0200 Subject: [PATCH] More tweaks to new attachments --- misago/attachments/migrations/0001_initial.py | 28 +++++++++---------- .../attachments/migrations/0002_move_data.py | 4 +-- misago/attachments/models.py | 10 +++---- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/misago/attachments/migrations/0001_initial.py b/misago/attachments/migrations/0001_initial.py index ba1eb9201..d7f54e561 100644 --- a/misago/attachments/migrations/0001_initial.py +++ b/misago/attachments/migrations/0001_initial.py @@ -76,14 +76,6 @@ class Migration(migrations.Migration): verbose_name="ID", ), ), - ("secret", models.CharField(max_length=64)), - ( - "filetype", - models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, - to="misago_attachments.attachmenttype", - ), - ), ( "post", models.ForeignKey( @@ -94,12 +86,6 @@ class Migration(migrations.Migration): to="misago_threads.post", ), ), - ( - "uploaded_on", - models.DateTimeField( - db_index=True, default=django.utils.timezone.now - ), - ), ( "uploader", models.ForeignKey( @@ -112,6 +98,20 @@ class Migration(migrations.Migration): ), ("uploader_name", models.CharField(max_length=255)), ("uploader_slug", models.CharField(max_length=255)), + ( + "uploaded_at", + models.DateTimeField( + db_index=True, default=django.utils.timezone.now + ), + ), + ("secret", models.CharField(max_length=64)), + ( + "filetype", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="misago_attachments.attachmenttype", + ), + ), ("filename", models.CharField(db_index=True, max_length=255)), ("size", models.PositiveIntegerField(db_index=True, default=0)), ( diff --git a/misago/attachments/migrations/0002_move_data.py b/misago/attachments/migrations/0002_move_data.py index f71ad6b49..73bc10344 100644 --- a/misago/attachments/migrations/0002_move_data.py +++ b/misago/attachments/migrations/0002_move_data.py @@ -37,10 +37,10 @@ class Migration(migrations.Migration): secret, filetype_id, post_id, - uploaded_on, uploader_id, uploader_name, uploader_slug, + uploaded_at, filename, size, thumbnail, @@ -53,10 +53,10 @@ class Migration(migrations.Migration): secret, filetype_id, post_id, - uploaded_on, uploader_id, uploader_name, uploader_slug, + uploaded_on, filename, size, thumbnail, diff --git a/misago/attachments/models.py b/misago/attachments/models.py index 252dd0d3f..daeaa3f87 100644 --- a/misago/attachments/models.py +++ b/misago/attachments/models.py @@ -36,9 +36,6 @@ def upload_to(instance, filename): class Attachment(PluginDataModel): - secret = models.CharField(max_length=64) - filetype = models.ForeignKey("AttachmentType", on_delete=models.CASCADE) - post = models.ForeignKey( "misago_threads.Post", blank=True, @@ -47,8 +44,6 @@ class Attachment(PluginDataModel): on_delete=models.SET_NULL, ) - uploaded_on = models.DateTimeField(default=timezone.now, db_index=True) - uploader = models.ForeignKey( settings.AUTH_USER_MODEL, blank=True, @@ -59,6 +54,11 @@ class Attachment(PluginDataModel): uploader_name = models.CharField(max_length=255) uploader_slug = models.CharField(max_length=255) + uploaded_at = models.DateTimeField(default=timezone.now, db_index=True) + + secret = models.CharField(max_length=64) + + filetype = models.ForeignKey("AttachmentType", on_delete=models.CASCADE) filename = models.CharField(max_length=255, db_index=True) size = models.PositiveIntegerField(default=0, db_index=True)