From 11e09b5753d1b3636584e3aa4377c1f0f6da77ca Mon Sep 17 00:00:00 2001 From: rafalp Date: Sun, 9 Aug 2026 05:12:03 +0200 Subject: [PATCH 1/5] Rename post.original to post.content and post.parsed to post.content_parsed --- ...dit-private-thread-post-permission-hook.md | 2 +- .../check-edit-thread-post-permission-hook.md | 2 +- .../plugins/hooks/create-post-edit-hook.md | 19 +- .../hooks/post-needs-content-upgrade-hook.md | 2 +- ...uire-private-thread-reply-approval-hook.md | 2 +- .../hooks/require-thread-approval-hook.md | 2 +- .../hooks/upgrade-post-code-blocks-hook.md | 2 +- .../hooks/upgrade-post-content-hook.md | 4 +- .../hooks/validate-posted-contents-hook.md | 2 +- misago/conftest.py | 18 +- misago/moderation/post.py | 6 +- misago/moderation/posts.py | 4 +- ...eck_edit_private_thread_post_permission.py | 2 +- .../check_edit_thread_post_permission.py | 2 +- misago/postedits/create.py | 2 +- misago/postedits/hooks/create_post_edit.py | 16 +- misago/postedits/restore.py | 6 +- .../postedits/tests/test_create_post_edit.py | 26 +- ...st_private_thread_post_edit_delete_view.py | 52 +- ...test_private_thread_post_edit_hide_view.py | 16 +- ...t_private_thread_post_edit_restore_view.py | 6 +- ...st_private_thread_post_edit_unhide_view.py | 16 +- .../postedits/tests/test_restore_post_edit.py | 30 +- .../test_thread_post_edit_delete_view.py | 50 +- .../tests/test_thread_post_edit_hide_view.py | 14 +- .../test_thread_post_edit_restore_view.py | 6 +- .../test_thread_post_edit_unhide_view.py | 16 +- misago/posting/formsets/edit.py | 8 +- .../hooks/post_needs_content_upgrade.py | 2 +- .../require_private_thread_reply_approval.py | 2 +- .../posting/hooks/require_thread_approval.py | 2 +- .../hooks/require_thread_reply_approval.py | 2 +- .../posting/hooks/upgrade_post_code_blocks.py | 2 +- misago/posting/hooks/upgrade_post_content.py | 4 +- .../posting/hooks/validate_posted_contents.py | 2 +- misago/posting/state/base.py | 4 +- misago/posting/state/edit.py | 8 +- misago/posting/state/reply.py | 6 +- misago/posting/tests/conftest.py | 2 +- misago/posting/tests/test_post_edit_state.py | 10 +- .../tests/test_private_thread_edit_view.py | 16 +- .../test_private_thread_post_edit_view.py | 16 +- .../tests/test_private_thread_reply_view.py | 48 +- misago/posting/tests/test_reply_state.py | 8 +- misago/posting/tests/test_state.py | 8 +- misago/posting/tests/test_thread_edit_view.py | 16 +- .../tests/test_thread_post_edit_view.py | 16 +- .../posting/tests/test_thread_reply_view.py | 50 +- .../tests/test_upgrade_post_code_blocks.py | 52 +- .../tests/test_upgrade_post_content.py | 4 +- .../tests/test_upgrade_post_content_task.py | 4 +- misago/posting/upgradepost.py | 10 +- misago/posting/views/edit.py | 2 +- misago/posting/views/reply.py | 4 +- misago/posting/views/start.py | 2 +- ...e_thread_detail_view_moderation_actions.py | 176 ++- .../test_private_thread_detail_view_posts.py | 612 ++++---- misago/templates/misago/post_feed/post.html | 2 +- misago/test/posts.py | 30 +- .../migrations/0001_threadevent.py | 2 +- misago/threads/checksums.py | 2 +- .../threads/management/commands/parseposts.py | 13 +- .../management/commands/rebuildpostssearch.py | 2 +- misago/threads/merge.py | 8 +- .../migrations/0018_post_content_parsed.py | 23 + .../0018_update_attachments_markup.py | 443 ------ .../migrations/0019_delete_legacy_events.py | 2 +- misago/threads/models/post.py | 20 +- misago/threads/signals.py | 2 +- misago/threads/tests/test_merge_posts.py | 16 +- misago/threads/tests/test_parseposts.py | 4 +- .../threads/tests/test_rebuildpostssearch.py | 2 +- ...t_thread_detail_view_moderation_actions.py | 198 ++- .../tests/test_thread_detail_view_posts.py | 866 +++++------ ...est_update_post_attachments_markup_0018.py | 1363 ----------------- .../management/commands/loaddevfixture.py | 122 +- 76 files changed, 1387 insertions(+), 3156 deletions(-) create mode 100644 misago/threads/migrations/0018_post_content_parsed.py delete mode 100644 misago/threads/migrations/0018_update_attachments_markup.py delete mode 100644 misago/threads/tests/test_update_post_attachments_markup_0018.py diff --git a/dev-docs/plugins/hooks/check-edit-private-thread-post-permission-hook.md b/dev-docs/plugins/hooks/check-edit-private-thread-post-permission-hook.md index f2424cbc6c..ef7f021f26 100644 --- a/dev-docs/plugins/hooks/check-edit-private-thread-post-permission-hook.md +++ b/dev-docs/plugins/hooks/check-edit-private-thread-post-permission-hook.md @@ -101,7 +101,7 @@ def check_user_can_edit_thread( action(permissions, thread, post) if ( - "[PROTECT]" in post.original + "[PROTECT]" in post.content and not permissions.is_private_threads_moderator ): raise PermissionError("Only a moderator can edit this post.") diff --git a/dev-docs/plugins/hooks/check-edit-thread-post-permission-hook.md b/dev-docs/plugins/hooks/check-edit-thread-post-permission-hook.md index a98cf9d474..4f208a65ea 100644 --- a/dev-docs/plugins/hooks/check-edit-thread-post-permission-hook.md +++ b/dev-docs/plugins/hooks/check-edit-thread-post-permission-hook.md @@ -116,7 +116,7 @@ def check_user_can_edit_thread_post( action(permissions, category, thread, post) if ( - "[PROTECT]" in post.original + "[PROTECT]" in post.content and not ( permissions.is_global_moderator or permissions.is_category_moderator(thread.category_id) diff --git a/dev-docs/plugins/hooks/create-post-edit-hook.md b/dev-docs/plugins/hooks/create-post-edit-hook.md index 098a90aece..11e72999f7 100644 --- a/dev-docs/plugins/hooks/create-post-edit-hook.md +++ b/dev-docs/plugins/hooks/create-post-edit-hook.md @@ -61,11 +61,6 @@ The user who performed the edit, a `User` instance or a `str` with the user's na A `str` with a short description of the changes, or `None`. -#### `old_content: str` - -A `str` with a snapshot of `Post.original` before the edit. - - #### `old_title: str | None = None` A `str` with the previous thread title, or `None`. @@ -76,6 +71,16 @@ A `str` with the previous thread title, or `None`. A `str` with the new thread title, or `None`. +#### `old_content: str | None` + +A `str` with a snapshot of `Post.content` before the edit, or `None`. + + +#### `new_content: str | None` + +A `str` with a snapshot of new `Post.content`, or `None`. + + #### `attachments: list[Attachment]` A `list` of new or current `Attachment` instances. @@ -163,12 +168,12 @@ A `str` with the new thread title, or `None`. #### `old_content: str | None` -A `str` with a snapshot of `Post.original` before the edit, or `None`. +A `str` with a snapshot of `Post.content` before the edit, or `None`. #### `new_content: str | None` -A `str` with a snapshot of new `Post.original`, or `None`. +A `str` with a snapshot of new `Post.content`, or `None`. #### `attachments: list[Attachment]` diff --git a/dev-docs/plugins/hooks/post-needs-content-upgrade-hook.md b/dev-docs/plugins/hooks/post-needs-content-upgrade-hook.md index 71d0a0bd74..70682a10fc 100644 --- a/dev-docs/plugins/hooks/post-needs-content-upgrade-hook.md +++ b/dev-docs/plugins/hooks/post-needs-content-upgrade-hook.md @@ -76,7 +76,7 @@ from misago.threads.models import Post @post_needs_content_upgrade_hook.append_filter def post_needs_plugin_content_upgrade(action, post: Post) -> bool: - if " bool: ): return True - if "spam" in state.post.original.lower(): + if "spam" in state.post.content.lower(): return True return False diff --git a/misago/conftest.py b/misago/conftest.py index 61459a5b09..05eab642e4 100644 --- a/misago/conftest.py +++ b/misago/conftest.py @@ -381,7 +381,7 @@ def reply(thread_reply_factory, thread): reply = thread_reply_factory( thread, poster="Reply", - original="I am reply", + content="I am reply", ) synchronize_category(reply.category) @@ -394,7 +394,7 @@ def hidden_reply(thread_reply_factory, thread): reply = thread_reply_factory( thread, poster="HiddenPoster", - original="I am hidden reply", + content="I am hidden reply", is_hidden=True, ) @@ -408,7 +408,7 @@ def unapproved_reply(thread_reply_factory, thread): reply = thread_reply_factory( thread, poster="UnapprovedPoster", - original="I am unapproved reply", + content="I am unapproved reply", is_unapproved=True, ) @@ -422,7 +422,7 @@ def user_reply(thread_reply_factory, thread, user): reply = thread_reply_factory( thread, poster=user, - original="I am user reply", + content="I am user reply", ) synchronize_category(reply.category) @@ -435,7 +435,7 @@ def user_hidden_reply(thread_reply_factory, thread, user): reply = thread_reply_factory( thread, poster=user, - original="I am user hidden reply", + content="I am user hidden reply", is_hidden=True, ) @@ -449,7 +449,7 @@ def user_unapproved_reply(thread_reply_factory, thread, user): reply = thread_reply_factory( thread, poster=user, - original="I am user unapproved reply", + content="I am user unapproved reply", is_unapproved=True, ) @@ -463,7 +463,7 @@ def other_user_reply(thread_reply_factory, thread, other_user): reply = thread_reply_factory( thread, poster=other_user, - original="I am other user reply", + content="I am other user reply", ) synchronize_category(reply.category) @@ -476,7 +476,7 @@ def other_user_hidden_reply(thread_reply_factory, thread, other_user): reply = thread_reply_factory( thread, poster=other_user, - original="I am user hidden reply", + content="I am user hidden reply", is_hidden=True, ) @@ -490,7 +490,7 @@ def other_user_unapproved_reply(thread_reply_factory, thread, other_user): reply = thread_reply_factory( thread, poster=other_user, - original="I am other user unapproved reply", + content="I am other user unapproved reply", is_unapproved=True, ) diff --git a/misago/moderation/post.py b/misago/moderation/post.py index 30eff81bf9..e37f38eb75 100644 --- a/misago/moderation/post.py +++ b/misago/moderation/post.py @@ -511,7 +511,7 @@ def form_valid(self, form) -> ModerationResult: if form.cleaned_data["direction"] == "other": final_post, other_post = other_post, post - old_content = final_post.original + old_content = final_post.content merge_posts( final_post, [other_post], @@ -522,7 +522,7 @@ def form_valid(self, form) -> ModerationResult: ) else: final_post = post - old_content = final_post.original + old_content = final_post.content merge_posts( final_post, [other_post], @@ -547,7 +547,7 @@ def form_valid(self, form) -> ModerationResult: user=request.user, edit_reason=edit_reason, old_content=old_content, - new_content=final_post.original, + new_content=final_post.content, attachments=attachments, edited_at=final_post.updated_at, request=request, diff --git a/misago/moderation/posts.py b/misago/moderation/posts.py index 9dd8b62b23..13ad81c901 100644 --- a/misago/moderation/posts.py +++ b/misago/moderation/posts.py @@ -489,7 +489,7 @@ def form_valid(self, form) -> ModerationResult: posts = sorted(self.posts, key=lambda i: i.id) target, posts = posts[0], posts[1:] - old_content = target.original + old_content = target.content attachments = [] attachments_queryset = Attachment.objects.filter(post__in=self.posts).order_by( @@ -519,7 +519,7 @@ def form_valid(self, form) -> ModerationResult: user=request.user, edit_reason=edit_reason, old_content=old_content, - new_content=target.original, + new_content=target.content, attachments=attachments, edited_at=target.updated_at, request=request, diff --git a/misago/permissions/hooks/check_edit_private_thread_post_permission.py b/misago/permissions/hooks/check_edit_private_thread_post_permission.py index c27501e46f..785ac17056 100644 --- a/misago/permissions/hooks/check_edit_private_thread_post_permission.py +++ b/misago/permissions/hooks/check_edit_private_thread_post_permission.py @@ -104,7 +104,7 @@ def check_user_can_edit_thread( action(permissions, thread, post) if ( - "[PROTECT]" in post.original + "[PROTECT]" in post.content and not permissions.is_private_threads_moderator ): raise PermissionError("Only a moderator can edit this post.") diff --git a/misago/permissions/hooks/check_edit_thread_post_permission.py b/misago/permissions/hooks/check_edit_thread_post_permission.py index ca5ffc020d..ff4bb1eb81 100644 --- a/misago/permissions/hooks/check_edit_thread_post_permission.py +++ b/misago/permissions/hooks/check_edit_thread_post_permission.py @@ -116,7 +116,7 @@ def check_user_can_edit_thread_post( action(permissions, category, thread, post) if ( - "[PROTECT]" in post.original + "[PROTECT]" in post.content and not ( permissions.is_global_moderator or permissions.is_category_moderator(thread.category_id) diff --git a/misago/postedits/create.py b/misago/postedits/create.py index 066750fc4f..971c568a31 100644 --- a/misago/postedits/create.py +++ b/misago/postedits/create.py @@ -77,7 +77,7 @@ def _create_post_edit_action( user_slug = user.slug if old_content and new_content: - content_diff = diff_text(old_content, post.original) + content_diff = diff_text(old_content, post.content) added_content = content_diff.added removed_content = content_diff.removed else: diff --git a/misago/postedits/hooks/create_post_edit.py b/misago/postedits/hooks/create_post_edit.py index d4e3968e0a..bb7371779d 100644 --- a/misago/postedits/hooks/create_post_edit.py +++ b/misago/postedits/hooks/create_post_edit.py @@ -40,11 +40,11 @@ class CreatePostEditHookAction(Protocol): ## `old_content: str | None` - A `str` with a snapshot of `Post.original` before the edit, or `None`. + A `str` with a snapshot of `Post.content` before the edit, or `None`. ## `new_content: str | None` - A `str` with a snapshot of new `Post.original`, or `None`. + A `str` with a snapshot of new `Post.content`, or `None`. ## `attachments: list[Attachment]` @@ -118,10 +118,6 @@ class CreatePostEditHookFilter(Protocol): A `str` with a short description of the changes, or `None`. - ## `old_content: str` - - A `str` with a snapshot of `Post.original` before the edit. - ## `old_title: str | None = None` A `str` with the previous thread title, or `None`. @@ -130,6 +126,14 @@ class CreatePostEditHookFilter(Protocol): A `str` with the new thread title, or `None`. + ## `old_content: str | None` + + A `str` with a snapshot of `Post.content` before the edit, or `None`. + + ## `new_content: str | None` + + A `str` with a snapshot of new `Post.content`, or `None`. + ## `attachments: list[Attachment]` A `list` of new or current `Attachment` instances. diff --git a/misago/postedits/restore.py b/misago/postedits/restore.py index c8c2eecb08..f567fcb4bd 100644 --- a/misago/postedits/restore.py +++ b/misago/postedits/restore.py @@ -36,7 +36,7 @@ def _restore_post_edit_action( ) -> tuple[Post, PostEdit]: timestamp = timezone.now() post = post_edit.post - old_content = post.original + old_content = post.content new_content = post_edit.old_content if isinstance(user, str): @@ -50,8 +50,8 @@ def _restore_post_edit_action( parsing_result = parse(new_content) - post.original = parsing_result.markup - post.parsed = parsing_result.html + post.content = parsing_result.markup + post.content_parsed = parsing_result.html post.metadata = parsing_result.metadata post.set_search_document(post.thread, parsing_result.text) diff --git a/misago/postedits/tests/test_create_post_edit.py b/misago/postedits/tests/test_create_post_edit.py index 31006dfd0c..e56dbf9821 100644 --- a/misago/postedits/tests/test_create_post_edit.py +++ b/misago/postedits/tests/test_create_post_edit.py @@ -6,7 +6,7 @@ def test_create_post_edit_creates_post_edit_by_user(user, post): post=post, user=user, old_content="Lorem ipsum dolor", - new_content=post.original, + new_content=post.content, ) assert post_edit.category == post.category @@ -18,7 +18,7 @@ def test_create_post_edit_creates_post_edit_by_user(user, post): assert post_edit.edit_reason is None assert post_edit.old_title is None assert post_edit.old_content == "Lorem ipsum dolor" - assert post_edit.new_content == post.original + assert post_edit.new_content == post.content assert post_edit.added_content == 1 assert post_edit.removed_content == 1 assert post_edit.attachments == [] @@ -31,7 +31,7 @@ def test_create_post_edit_creates_post_edit_by_deleted_user(post): post=post, user="DeletedUser", old_content="Lorem ipsum dolor", - new_content=post.original, + new_content=post.content, ) assert post_edit.category == post.category @@ -43,7 +43,7 @@ def test_create_post_edit_creates_post_edit_by_deleted_user(post): assert post_edit.edit_reason is None assert post_edit.old_title is None assert post_edit.old_content == "Lorem ipsum dolor" - assert post_edit.new_content == post.original + assert post_edit.new_content == post.content assert post_edit.added_content == 1 assert post_edit.removed_content == 1 assert post_edit.attachments == [] @@ -57,7 +57,7 @@ def test_create_post_edit_creates_post_edit_with_edit_reason(user, post): user=user, edit_reason="Test edit", old_content="Lorem ipsum dolor", - new_content=post.original, + new_content=post.content, ) assert post_edit.category == post.category @@ -69,7 +69,7 @@ def test_create_post_edit_creates_post_edit_with_edit_reason(user, post): assert post_edit.edit_reason == "Test edit" assert post_edit.old_title is None assert post_edit.old_content == "Lorem ipsum dolor" - assert post_edit.new_content == post.original + assert post_edit.new_content == post.content assert post_edit.added_content == 1 assert post_edit.removed_content == 1 assert post_edit.attachments == [] @@ -137,7 +137,7 @@ def test_create_post_edit_creates_post_edit_with_new_attachment( user=user, attachments=[user_image_attachment], old_content="Lorem ipsum dolor", - new_content=post.original, + new_content=post.content, ) assert post_edit.category == post.category @@ -149,7 +149,7 @@ def test_create_post_edit_creates_post_edit_with_new_attachment( assert post_edit.edit_reason is None assert post_edit.old_title is None assert post_edit.old_content == "Lorem ipsum dolor" - assert post_edit.new_content == post.original + assert post_edit.new_content == post.content assert post_edit.added_content == 1 assert post_edit.removed_content == 1 assert post_edit.attachments == [ @@ -183,7 +183,7 @@ def test_create_post_edit_creates_post_edit_with_unchanged_attachment( user=user, attachments=[user_image_attachment], old_content="Lorem ipsum dolor", - new_content=post.original, + new_content=post.content, ) assert post_edit.category == post.category @@ -195,7 +195,7 @@ def test_create_post_edit_creates_post_edit_with_unchanged_attachment( assert post_edit.edit_reason is None assert post_edit.old_title is None assert post_edit.old_content == "Lorem ipsum dolor" - assert post_edit.new_content == post.original + assert post_edit.new_content == post.content assert post_edit.added_content == 1 assert post_edit.removed_content == 1 assert post_edit.attachments == [ @@ -229,7 +229,7 @@ def test_create_post_edit_creates_post_edit_with_deleted_attachment( user=user, deleted_attachments=[user_image_attachment], old_content="Lorem ipsum dolor", - new_content=post.original, + new_content=post.content, ) assert post_edit.category == post.category @@ -241,7 +241,7 @@ def test_create_post_edit_creates_post_edit_with_deleted_attachment( assert post_edit.edit_reason is None assert post_edit.old_title is None assert post_edit.old_content == "Lorem ipsum dolor" - assert post_edit.new_content == post.original + assert post_edit.new_content == post.content assert post_edit.added_content == 1 assert post_edit.removed_content == 1 assert post_edit.attachments == [ @@ -272,7 +272,7 @@ def test_create_post_edit_doesnt_save_edit_if_commit_is_false( post=post, user=user, old_content="Lorem ipsum dolor", - new_content=post.original, + new_content=post.content, commit=False, ) diff --git a/misago/postedits/tests/test_private_thread_post_edit_delete_view.py b/misago/postedits/tests/test_private_thread_post_edit_delete_view.py index e8e3f1edee..f672b01dba 100644 --- a/misago/postedits/tests/test_private_thread_post_edit_delete_view.py +++ b/misago/postedits/tests/test_private_thread_post_edit_delete_view.py @@ -19,7 +19,7 @@ def test_private_thread_post_edit_delete_view_deletes_only_post_edit_on_post( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -60,7 +60,7 @@ def test_private_thread_post_edit_delete_view_deletes_only_post_edit_on_post_in_ post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -93,7 +93,7 @@ def test_private_thread_post_edit_delete_view_deletes_only_post_edit_on_post_in_ post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -127,13 +127,13 @@ def test_private_thread_post_edit_delete_view_deletes_first_post_edit_on_post( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) create_post_edit( post=post, user=user, old_content="Other post edit", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -174,13 +174,13 @@ def test_private_thread_post_edit_delete_view_deletes_first_post_edit_on_post_in post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) other_post_edit = create_post_edit( post=post, user=user, old_content="Other post edit", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -213,13 +213,13 @@ def test_private_thread_post_edit_delete_view_deletes_first_post_edit_on_post_in post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) other_post_edit = create_post_edit( post=post, user=user, old_content="Other post edit", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -253,13 +253,13 @@ def test_private_thread_post_edit_delete_view_deletes_last_post_edit_on_post( post=post, user=user, old_content="Other post edit", - new_content=post.original, + new_content=post.content, ) post_edit = create_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -300,13 +300,13 @@ def test_private_thread_post_edit_delete_view_deletes_last_post_edit_on_post_in_ post=post, user=user, old_content="Other post edit", - new_content=post.original, + new_content=post.content, ) post_edit = create_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -339,13 +339,13 @@ def test_private_thread_post_edit_delete_view_deletes_last_post_edit_on_post_in_ post=post, user=user, old_content="Other post edit", - new_content=post.original, + new_content=post.content, ) post_edit = create_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -379,19 +379,19 @@ def test_private_thread_post_edit_delete_view_deletes_last_post_edit_on_post( post=post, user=user, old_content="Previous post edit", - new_content=post.original, + new_content=post.content, ) post_edit = create_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) create_post_edit( post=post, user=user, old_content="Next post edit", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -432,19 +432,19 @@ def test_private_thread_post_edit_delete_view_deletes_last_post_edit_on_post_in_ post=post, user=user, old_content="Previous post edit", - new_content=post.original, + new_content=post.content, ) post_edit = create_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) next_post_edit = create_post_edit( post=post, user=user, old_content="Next post edit", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -478,19 +478,19 @@ def test_private_thread_post_edit_delete_view_deletes_middle_post_edit_on_post_i post=post, user=user, old_content="Previous post edit", - new_content=post.original, + new_content=post.content, ) post_edit = create_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) next_post_edit = create_post_edit( post=post, user=user, old_content="Next post edit", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -525,7 +525,7 @@ def test_private_thread_post_edit_delete_view_shows_confirmation_page_on_get_req post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.get( @@ -551,7 +551,7 @@ def test_private_thread_post_edit_delete_view_shows_error_403_if_post_edit_cant_ post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( diff --git a/misago/postedits/tests/test_private_thread_post_edit_hide_view.py b/misago/postedits/tests/test_private_thread_post_edit_hide_view.py index 0b28c76674..7d87cbf8a1 100644 --- a/misago/postedits/tests/test_private_thread_post_edit_hide_view.py +++ b/misago/postedits/tests/test_private_thread_post_edit_hide_view.py @@ -19,7 +19,7 @@ def test_private_thread_post_edit_hide_view_hides_post_edit_on_post( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -60,7 +60,7 @@ def test_private_thread_post_edit_hide_view_hides_post_edit_on_post_in_htmx( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -93,7 +93,7 @@ def test_private_thread_post_edit_hide_view_hides_post_edit_on_post_in_modal( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -127,7 +127,7 @@ def test_private_thread_post_edit_hide_view_does_nothing_for_hidden_post_edit_on post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -169,7 +169,7 @@ def test_private_thread_post_edit_hide_view_does_nothing_for_hidden_post_edit_on post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -203,7 +203,7 @@ def test_private_thread_post_edit_hide_view_does_nothing_for_hidden_post_edit_on post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -238,7 +238,7 @@ def test_private_thread_post_edit_hide_view_shows_confirmation_page_on_get_reque post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.get( @@ -267,7 +267,7 @@ def test_private_thread_post_edit_hide_view_shows_error_403_if_post_edit_cant_be post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( diff --git a/misago/postedits/tests/test_private_thread_post_edit_restore_view.py b/misago/postedits/tests/test_private_thread_post_edit_restore_view.py index 5c0aed905d..03a8e95695 100644 --- a/misago/postedits/tests/test_private_thread_post_edit_restore_view.py +++ b/misago/postedits/tests/test_private_thread_post_edit_restore_view.py @@ -15,7 +15,7 @@ def test_private_thread_post_edit_restore_view_restores_user_editable_post_on_po post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -43,7 +43,7 @@ def test_private_thread_post_edit_restore_view_restores_user_editable_post_on_po ) post.refresh_from_db() - assert post.original == "Lorem ipsum" + assert post.content == "Lorem ipsum" def test_private_thread_post_edit_restore_view_shows_confirmation_page_on_get_request( @@ -55,7 +55,7 @@ def test_private_thread_post_edit_restore_view_shows_confirmation_page_on_get_re post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.get( diff --git a/misago/postedits/tests/test_private_thread_post_edit_unhide_view.py b/misago/postedits/tests/test_private_thread_post_edit_unhide_view.py index b6ee43131e..876faf75c5 100644 --- a/misago/postedits/tests/test_private_thread_post_edit_unhide_view.py +++ b/misago/postedits/tests/test_private_thread_post_edit_unhide_view.py @@ -16,7 +16,7 @@ def test_private_thread_post_edit_unhide_view_unhides_hidden_post_edit_on_post( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -55,7 +55,7 @@ def test_private_thread_post_edit_unhide_view_unhides_hidden_post_edit_on_post_i post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -86,7 +86,7 @@ def test_private_thread_post_edit_unhide_view_unhides_hidden_post_edit_on_post_i post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -118,7 +118,7 @@ def test_private_thread_post_edit_unhide_view_does_nothing_for_visible_post_edit post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = moderator_client.post( @@ -156,7 +156,7 @@ def test_private_thread_post_edit_unhide_view_does_nothing_for_visible_post_edit post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = moderator_client.post( @@ -186,7 +186,7 @@ def test_private_thread_post_edit_unhide_view_does_nothing_for_visible_post_edit post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = moderator_client.post( @@ -217,7 +217,7 @@ def test_private_thread_post_edit_unhide_view_shows_method_not_allowed_error_on_ post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -244,7 +244,7 @@ def test_private_thread_post_edit_unhide_view_shows_error_403_if_post_edit_cant_ post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") diff --git a/misago/postedits/tests/test_restore_post_edit.py b/misago/postedits/tests/test_restore_post_edit.py index 3251839dea..fe572d33ac 100644 --- a/misago/postedits/tests/test_restore_post_edit.py +++ b/misago/postedits/tests/test_restore_post_edit.py @@ -7,7 +7,7 @@ def test_restore_post_edit_restores_post(post, user): post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) _, new_post_edit = restore_post_edit(post_edit, user) @@ -15,8 +15,8 @@ def test_restore_post_edit_restores_post(post, user): assert new_post_edit.id assert new_post_edit.new_content == "Lorem ipsum" - assert post.original == "Lorem ipsum" - assert post.parsed == "

Lorem ipsum

" + assert post.content == "Lorem ipsum" + assert post.content_parsed == "

Lorem ipsum

" assert post.last_editor == user assert post.last_editor_name == user.username assert post.last_editor_slug == user.slug @@ -24,8 +24,8 @@ def test_restore_post_edit_restores_post(post, user): post.refresh_from_db() - assert post.original == "Lorem ipsum" - assert post.parsed == "

Lorem ipsum

" + assert post.content == "Lorem ipsum" + assert post.content_parsed == "

Lorem ipsum

" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -39,7 +39,7 @@ def test_restore_post_edit_restores_post_by_deleted_user(post, user): post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) _, new_post_edit = restore_post_edit(post_edit, "DeletedUser") @@ -47,8 +47,8 @@ def test_restore_post_edit_restores_post_by_deleted_user(post, user): assert new_post_edit.id assert new_post_edit.new_content == "Lorem ipsum" - assert post.original == "Lorem ipsum" - assert post.parsed == "

Lorem ipsum

" + assert post.content == "Lorem ipsum" + assert post.content_parsed == "

Lorem ipsum

" assert post.last_editor is None assert post.last_editor_name == "DeletedUser" assert post.last_editor_slug == "deleteduser" @@ -56,8 +56,8 @@ def test_restore_post_edit_restores_post_by_deleted_user(post, user): post.refresh_from_db() - assert post.original == "Lorem ipsum" - assert post.parsed == "

Lorem ipsum

" + assert post.content == "Lorem ipsum" + assert post.content_parsed == "

Lorem ipsum

" assert post.updated_at assert post.edits == 1 assert post.last_editor is None @@ -73,7 +73,7 @@ def test_restore_post_edit_without_commit_doesnt_save_post_and_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) # New post edit creation runs query to snapshot existing attachments @@ -83,8 +83,8 @@ def test_restore_post_edit_without_commit_doesnt_save_post_and_post_edit( assert not new_post_edit.id assert new_post_edit.new_content == "Lorem ipsum" - assert post.original == "Lorem ipsum" - assert post.parsed == "

Lorem ipsum

" + assert post.content == "Lorem ipsum" + assert post.content_parsed == "

Lorem ipsum

" assert post.last_editor is None assert post.last_editor_name == "DeletedUser" assert post.last_editor_slug == "deleteduser" @@ -92,8 +92,8 @@ def test_restore_post_edit_without_commit_doesnt_save_post_and_post_edit( post.refresh_from_db() - assert post.original != "Lorem ipsum" - assert post.parsed != "

Lorem ipsum

" + assert post.content != "Lorem ipsum" + assert post.content_parsed != "

Lorem ipsum

" assert post.updated_at is None assert post.edits == 0 assert post.last_editor is None diff --git a/misago/postedits/tests/test_thread_post_edit_delete_view.py b/misago/postedits/tests/test_thread_post_edit_delete_view.py index 4846fcc17a..1a8f52e546 100644 --- a/misago/postedits/tests/test_thread_post_edit_delete_view.py +++ b/misago/postedits/tests/test_thread_post_edit_delete_view.py @@ -24,7 +24,7 @@ def test_thread_post_edit_delete_view_deletes_only_post_edit_on_post( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -65,7 +65,7 @@ def test_thread_post_edit_delete_view_deletes_only_post_edit_on_post_in_htmx( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -98,7 +98,7 @@ def test_thread_post_edit_delete_view_deletes_only_post_edit_on_post_in_modal( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -132,13 +132,13 @@ def test_thread_post_edit_delete_view_deletes_first_post_edit_on_post( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) create_post_edit( post=post, user=user, old_content="Other post edit", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -179,13 +179,13 @@ def test_thread_post_edit_delete_view_deletes_first_post_edit_on_post_in_htmx( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) other_post_edit = create_post_edit( post=post, user=user, old_content="Other post edit", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -218,13 +218,13 @@ def test_thread_post_edit_delete_view_deletes_first_post_edit_on_post_in_modal( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) other_post_edit = create_post_edit( post=post, user=user, old_content="Other post edit", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -258,13 +258,13 @@ def test_thread_post_edit_delete_view_deletes_last_post_edit_on_post( post=post, user=user, old_content="Other post edit", - new_content=post.original, + new_content=post.content, ) post_edit = create_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -305,13 +305,13 @@ def test_thread_post_edit_delete_view_deletes_last_post_edit_on_post_in_htmx( post=post, user=user, old_content="Other post edit", - new_content=post.original, + new_content=post.content, ) post_edit = create_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -344,13 +344,13 @@ def test_thread_post_edit_delete_view_deletes_last_post_edit_on_post_in_modal( post=post, user=user, old_content="Other post edit", - new_content=post.original, + new_content=post.content, ) post_edit = create_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -384,19 +384,19 @@ def test_thread_post_edit_delete_view_deletes_middle_post_edit_on_post( post=post, user=user, old_content="Previous post edit", - new_content=post.original, + new_content=post.content, ) post_edit = create_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) create_post_edit( post=post, user=user, old_content="Next post edit", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -437,19 +437,19 @@ def test_thread_post_edit_delete_view_deletes_middle_post_edit_on_post_in_htmx( post=post, user=user, old_content="Previous post edit", - new_content=post.original, + new_content=post.content, ) post_edit = create_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) next_post_edit = create_post_edit( post=post, user=user, old_content="Next post edit", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -483,19 +483,19 @@ def test_thread_post_edit_delete_view_deletes_middle_post_edit_on_post_in_modal( post=post, user=user, old_content="Previous post edit", - new_content=post.original, + new_content=post.content, ) post_edit = create_post_edit( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) next_post_edit = create_post_edit( post=post, user=user, old_content="Next post edit", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -530,7 +530,7 @@ def test_thread_post_edit_delete_view_shows_confirmation_page_on_get_request( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.get( diff --git a/misago/postedits/tests/test_thread_post_edit_hide_view.py b/misago/postedits/tests/test_thread_post_edit_hide_view.py index 9f04d89772..f973c4fe5e 100644 --- a/misago/postedits/tests/test_thread_post_edit_hide_view.py +++ b/misago/postedits/tests/test_thread_post_edit_hide_view.py @@ -23,7 +23,7 @@ def test_thread_post_edit_hide_view_hides_post_edit_on_post( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -64,7 +64,7 @@ def test_thread_post_edit_hide_view_hides_post_edit_on_post_in_htmx( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -97,7 +97,7 @@ def test_thread_post_edit_hide_view_hides_post_edit_on_post_in_modal( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.post( @@ -131,7 +131,7 @@ def test_thread_post_edit_hide_view_does_nothing_for_hidden_post_edit_on_post( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -173,7 +173,7 @@ def test_thread_post_edit_hide_view_does_nothing_for_hidden_post_edit_on_post_in post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -207,7 +207,7 @@ def test_thread_post_edit_hide_view_does_nothing_for_hidden_post_edit_on_post_in post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -242,7 +242,7 @@ def test_thread_post_edit_hide_view_shows_confirmation_page_on_get_request( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = user_client.get( diff --git a/misago/postedits/tests/test_thread_post_edit_restore_view.py b/misago/postedits/tests/test_thread_post_edit_restore_view.py index 472d998d39..5d00498235 100644 --- a/misago/postedits/tests/test_thread_post_edit_restore_view.py +++ b/misago/postedits/tests/test_thread_post_edit_restore_view.py @@ -13,7 +13,7 @@ def test_thread_post_edit_restore_view_restores_user_editable_post_on_post_reque post=user_reply, user=user, old_content="Lorem ipsum", - new_content=user_reply.original, + new_content=user_reply.content, ) response = user_client.post( @@ -41,7 +41,7 @@ def test_thread_post_edit_restore_view_restores_user_editable_post_on_post_reque ) user_reply.refresh_from_db() - assert user_reply.original == "Lorem ipsum" + assert user_reply.content == "Lorem ipsum" def test_thread_post_edit_restore_view_shows_confirmation_page_on_get_request( @@ -51,7 +51,7 @@ def test_thread_post_edit_restore_view_shows_confirmation_page_on_get_request( post=user_reply, user=user, old_content="Lorem ipsum", - new_content=user_reply.original, + new_content=user_reply.content, ) response = user_client.get( diff --git a/misago/postedits/tests/test_thread_post_edit_unhide_view.py b/misago/postedits/tests/test_thread_post_edit_unhide_view.py index 99b721549f..c2b11be5ef 100644 --- a/misago/postedits/tests/test_thread_post_edit_unhide_view.py +++ b/misago/postedits/tests/test_thread_post_edit_unhide_view.py @@ -16,7 +16,7 @@ def test_thread_post_edit_unhide_view_unhides_hidden_post_edit_on_post( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -55,7 +55,7 @@ def test_thread_post_edit_unhide_view_unhides_hidden_post_edit_on_post_in_htmx( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -86,7 +86,7 @@ def test_thread_post_edit_unhide_view_unhides_hidden_post_edit_on_post_in_modal( post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -118,7 +118,7 @@ def test_thread_post_edit_unhide_view_does_nothing_for_visible_post_edit_on_post post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = moderator_client.post( @@ -156,7 +156,7 @@ def test_thread_post_edit_unhide_view_does_nothing_for_visible_post_edit_on_post post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = moderator_client.post( @@ -186,7 +186,7 @@ def test_thread_post_edit_unhide_view_does_nothing_for_visible_post_edit_on_post post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) response = moderator_client.post( @@ -217,7 +217,7 @@ def test_thread_post_edit_unhide_view_shows_method_not_allowed_error_on_get_requ post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") @@ -244,7 +244,7 @@ def test_thread_post_edit_unhide_view_shows_error_403_if_post_edit_cant_be_unhid post=post, user=user, old_content="Lorem ipsum", - new_content=post.original, + new_content=post.content, ) hide_post_edit(post_edit, "Moderator") diff --git a/misago/posting/formsets/edit.py b/misago/posting/formsets/edit.py index fafa412f6c..8a5bea7668 100644 --- a/misago/posting/formsets/edit.py +++ b/misago/posting/formsets/edit.py @@ -39,7 +39,7 @@ def _get_thread_post_edit_formset_action( formset.add_form( create_post_form( request, - initial=post.original, + initial=post.content, attachments=get_post_attachments(post), can_upload_attachments=can_upload_threads_attachments( request.user_permissions, post.category @@ -71,7 +71,7 @@ def _get_private_thread_post_edit_formset_action( formset.add_form( create_post_form( request, - initial=post.original, + initial=post.content, attachments=get_post_attachments(post), can_upload_attachments=can_upload_attachments, ) @@ -100,7 +100,7 @@ def _get_thread_edit_formset_action( formset.add_form( create_post_form( request, - initial=post.original, + initial=post.content, attachments=get_post_attachments(post), can_upload_attachments=can_upload_threads_attachments( request.user_permissions, post.category @@ -133,7 +133,7 @@ def _get_private_thread_edit_formset_action( formset.add_form( create_post_form( request, - initial=post.original, + initial=post.content, attachments=get_post_attachments(post), can_upload_attachments=can_upload_attachments, ) diff --git a/misago/posting/hooks/post_needs_content_upgrade.py b/misago/posting/hooks/post_needs_content_upgrade.py index 279c81b500..8653da5b37 100644 --- a/misago/posting/hooks/post_needs_content_upgrade.py +++ b/misago/posting/hooks/post_needs_content_upgrade.py @@ -70,7 +70,7 @@ class PostNeedsContentUpgradeHook( @post_needs_content_upgrade_hook.append_filter def post_needs_plugin_content_upgrade(action, post: Post) -> bool: - if " bool: ): return True - if "spam" in state.post.original.lower(): + if "spam" in state.post.content.lower(): return True return False diff --git a/misago/posting/state/base.py b/misago/posting/state/base.py index 815a2756e7..ba67ad269b 100644 --- a/misago/posting/state/base.py +++ b/misago/posting/state/base.py @@ -120,8 +120,8 @@ def set_thread_title(self, title: str): def set_post_message(self, parsing_result: ParsingResult): self.parsing_result = parsing_result - self.post.original = parsing_result.markup - self.post.parsed = parsing_result.html + self.post.content = parsing_result.markup + self.post.content_parsed = parsing_result.html self.post.metadata = parsing_result.metadata def schedule_post_content_upgrade(self): diff --git a/misago/posting/state/edit.py b/misago/posting/state/edit.py index 63bedfdff7..b8a4f57797 100644 --- a/misago/posting/state/edit.py +++ b/misago/posting/state/edit.py @@ -33,7 +33,7 @@ def __init__(self, request: HttpRequest, post: Post): self.store_object_state(post) self.thread_title = self.thread.title - self.post_original = post.original + self.post_original = post.content self.edit_reason = None def set_edit_reason(self, edit_reason: str): @@ -51,7 +51,7 @@ def is_post_changed(self): if self.thread_title != self.thread.title: return True - if self.post_original.splitlines() != self.post.original.splitlines(): + if self.post_original.splitlines() != self.post.content.splitlines(): return True if self.delete_attachments: @@ -72,7 +72,7 @@ def save_action(self, request: HttpRequest, state: "PostEditState"): post_edits = self.post.edits + 1 self.set_post_edits() - if self.post_original != self.post.original: + if self.post_original != self.post.content: # Full post update self.save_post() else: @@ -85,7 +85,7 @@ def save_action(self, request: HttpRequest, state: "PostEditState"): old_title=self.thread_title, new_title=self.thread.title, old_content=self.post_original, - new_content=self.post.original, + new_content=self.post.content, attachments=self.attachments, deleted_attachments=self.delete_attachments, edited_at=self.timestamp, diff --git a/misago/posting/state/reply.py b/misago/posting/state/reply.py index 1a75dc6569..a0f3345088 100644 --- a/misago/posting/state/reply.py +++ b/misago/posting/state/reply.py @@ -29,7 +29,7 @@ def __init__(self, request: HttpRequest, thread: Thread, post: Post | None = Non self.thread = thread self.post = post or self.initialize_post() self.is_merged = bool(self.post.id) - self.post_original = self.post.original + self.post_original = self.post.content self.store_object_state(self.category) self.store_object_state(self.thread) @@ -39,7 +39,7 @@ def __init__(self, request: HttpRequest, thread: Thread, post: Post | None = Non def set_post_message(self, parsing_result: ParsingResult): if self.post.id: - markup = "\n\n".join([self.post.original, parsing_result.markup]) + markup = "\n\n".join([self.post.content, parsing_result.markup]) parsing_result = parse(markup) super().set_post_message(parsing_result) @@ -79,7 +79,7 @@ def save_post(self): post=self.post, user=self.user, old_content=self.post_original, - new_content=self.post.original, + new_content=self.post.content, attachments=self.attachments, edited_at=self.timestamp, request=self.request, diff --git a/misago/posting/tests/conftest.py b/misago/posting/tests/conftest.py index a55e244e53..912b0a09fb 100644 --- a/misago/posting/tests/conftest.py +++ b/misago/posting/tests/conftest.py @@ -39,7 +39,7 @@ def validate_spam_contents(formset, state): if formset.title and "spam" in state.thread.title.lower(): raise ValidationError("Your message contains spam!") - if "spam" in state.post.original.lower(): + if "spam" in state.post.content.lower(): raise ValidationError("Your message contains spam!") raise ValidationError("Your message contains spam!") diff --git a/misago/posting/tests/test_post_edit_state.py b/misago/posting/tests/test_post_edit_state.py index 03ca8be2cc..7e60ab3af7 100644 --- a/misago/posting/tests/test_post_edit_state.py +++ b/misago/posting/tests/test_post_edit_state.py @@ -24,7 +24,7 @@ def test_post_edit_state_save_updates_post(user, user_request, other_user_thread post = other_user_thread.first_post post.refresh_from_db() - assert post.original == "Edit reply" + assert post.content == "Edit reply" assert post.search_document == f"{other_user_thread.title}\n\nEdit reply" assert post.updated_at == state.timestamp assert post.edits == 1 @@ -141,7 +141,7 @@ def test_post_edit_state_changes_test_returns_false_if_nothing_changed( user_request, other_user_thread ): state = PostEditState(user_request, other_user_thread.first_post) - state.set_post_message(parse(other_user_thread.first_post.original)) + state.set_post_message(parse(other_user_thread.first_post.content)) assert not state.is_post_changed() @@ -152,7 +152,7 @@ def test_post_edit_state_changes_test_returns_true_if_thread_title_changed( state = PostEditState(user_request, other_user_thread.first_post) state.set_thread_title("New title") - state.set_post_message(parse(other_user_thread.first_post.original)) + state.set_post_message(parse(other_user_thread.first_post.content)) assert state.is_post_changed() @@ -161,7 +161,7 @@ def test_post_edit_state_changes_test_returns_true_if_post_contents_changed( user_request, other_user_thread ): post = other_user_thread.first_post - post.original = "Lorem\nIpsum" + post.content = "Lorem\nIpsum" post.save() state = PostEditState(user_request, other_user_thread.first_post) @@ -174,7 +174,7 @@ def test_post_edit_state_changes_test_returns_false_if_only_new_line_characters_ user_request, other_user_thread ): post = other_user_thread.first_post - post.original = "Lorem\r\nIpsum" + post.content = "Lorem\r\nIpsum" post.save() state = PostEditState(user_request, other_user_thread.first_post) diff --git a/misago/posting/tests/test_private_thread_edit_view.py b/misago/posting/tests/test_private_thread_edit_view.py index 3b076ae1c3..42e8fb006e 100644 --- a/misago/posting/tests/test_private_thread_edit_view.py +++ b/misago/posting/tests/test_private_thread_edit_view.py @@ -171,7 +171,7 @@ def test_private_thread_edit_view_displays_edit_form(user_client, user_private_t ) assert_contains(response, "Edit thread") assert_contains(response, user_private_thread.title) - assert_contains(response, user_private_thread.first_post.original) + assert_contains(response, user_private_thread.first_post.content) def test_private_thread_edit_view_displays_edit_form_for_moderator( @@ -188,7 +188,7 @@ def test_private_thread_edit_view_displays_edit_form_for_moderator( ) assert_contains(response, "Edit thread") assert_contains(response, user_private_thread.title) - assert_contains(response, user_private_thread.first_post.original) + assert_contains(response, user_private_thread.first_post.content) def test_private_thread_edit_view_displays_inline_edit_form_in_htmx( @@ -207,7 +207,7 @@ def test_private_thread_edit_view_displays_inline_edit_form_in_htmx( ) assert_contains(response, "Save") assert_contains(response, user_private_thread.title) - assert_contains(response, user_private_thread.first_post.original) + assert_contains(response, user_private_thread.first_post.content) assert_contains(response, "?inline=true") @@ -242,7 +242,7 @@ def test_private_thread_edit_view_updates_thread_title_and_post( assert user_private_thread.title == "Edited title" post = user_private_thread.first_post - assert post.original == "Edited post" + assert post.content == "Edited post" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -290,7 +290,7 @@ def test_private_thread_edit_view_updates_thread_title_and_post_in_htmx( assert user_private_thread.title == "Edited title" post = user_private_thread.first_post - assert post.original == "Edited post" + assert post.content == "Edited post" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -330,7 +330,7 @@ def test_private_thread_edit_view_updates_thread_title_and_post_inline_in_htmx( assert user_private_thread.title == "Edited title" post = user_private_thread.first_post - assert post.original == "Edited post" + assert post.content == "Edited post" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -360,7 +360,7 @@ def test_private_thread_edit_view_sets_edit_reason( post = user_private_thread.first_post post.refresh_from_db() - assert post.original == "Edited post" + assert post.content == "Edited post" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -583,7 +583,7 @@ def test_private_thread_edit_view_skips_flood_control( post = user_private_thread.first_post post.refresh_from_db() - assert post.original == "This is a flood message" + assert post.content == "This is a flood message" assert post.edits == 1 diff --git a/misago/posting/tests/test_private_thread_post_edit_view.py b/misago/posting/tests/test_private_thread_post_edit_view.py index bf51e18faa..cfadd35069 100644 --- a/misago/posting/tests/test_private_thread_post_edit_view.py +++ b/misago/posting/tests/test_private_thread_post_edit_view.py @@ -246,7 +246,7 @@ def test_private_thread_post_edit_view_displays_edit_form( ) assert_contains(response, "Edit post") assert_contains(response, other_user_private_thread.title) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_private_thread_post_edit_view_displays_edit_form_for_moderator( @@ -266,7 +266,7 @@ def test_private_thread_post_edit_view_displays_edit_form_for_moderator( ) assert_contains(response, "Edit post") assert_contains(response, other_user_private_thread.title) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_private_thread_post_edit_view_displays_inline_edit_form_in_htmx( @@ -287,7 +287,7 @@ def test_private_thread_post_edit_view_displays_inline_edit_form_in_htmx( headers={"hx-request": "true"}, ) assert_contains(response, "Save") - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "?inline=true") @@ -324,7 +324,7 @@ def test_private_thread_post_edit_view_updates_thread_post( ) post.refresh_from_db() - assert post.original == "Edited" + assert post.content == "Edited" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -374,7 +374,7 @@ def test_private_thread_post_edit_view_updates_thread_post_in_htmx( ) post.refresh_from_db() - assert post.original == "Edited" + assert post.content == "Edited" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -406,7 +406,7 @@ def test_private_thread_post_edit_view_updates_thread_post_inline_in_htmx( assert_contains(response, "

Edited

") post.refresh_from_db() - assert post.original == "Edited" + assert post.content == "Edited" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -437,7 +437,7 @@ def test_private_thread_post_edit_view_sets_edit_reason( assert response.status_code == 302 post.refresh_from_db() - assert post.original == "Edited post" + assert post.content == "Edited post" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -611,7 +611,7 @@ def test_private_thread_post_edit_view_skips_flood_control( post.refresh_from_db() - assert post.original == "This is a flood message" + assert post.content == "This is a flood message" assert post.edits == 1 diff --git a/misago/posting/tests/test_private_thread_reply_view.py b/misago/posting/tests/test_private_thread_reply_view.py index ae8cc6da22..9f8ca1db90 100644 --- a/misago/posting/tests/test_private_thread_reply_view.py +++ b/misago/posting/tests/test_private_thread_reply_view.py @@ -157,7 +157,7 @@ def test_private_thread_reply_view_displays_posting_form_with_quoted_post( thread_reply_factory, user_client, other_user_private_thread ): post = thread_reply_factory( - other_user_private_thread, poster="QuotedUser", original="Bread and butter" + other_user_private_thread, poster="QuotedUser", content="Bread and butter" ) response = user_client.get( @@ -173,7 +173,7 @@ def test_private_thread_reply_view_displays_posting_form_with_quoted_post( assert_contains(response, "Reply to thread") assert_contains(response, other_user_private_thread.title) assert_contains(response, f"[quote=QuotedUser, post: {post.id}]") - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "[/quote]") @@ -183,7 +183,7 @@ def test_private_thread_reply_view_doesnt_init_posting_form_with_hidden_quoted_p post = thread_reply_factory( other_user_private_thread, poster="QuotedUser", - original="Bread and butter", + content="Bread and butter", is_hidden=True, ) @@ -200,7 +200,7 @@ def test_private_thread_reply_view_doesnt_init_posting_form_with_hidden_quoted_p assert_contains(response, "Reply to thread") assert_contains(response, other_user_private_thread.title) assert_not_contains(response, f"[quote=QuotedUser, post: {post.id}]") - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, "[/quote]") @@ -210,7 +210,7 @@ def test_private_thread_reply_view_doesnt_init_posting_form_with_invisible_quote post = thread_reply_factory( other_user_private_thread, poster="QuotedUser", - original="Bread and butter", + content="Bread and butter", is_unapproved=True, ) @@ -227,7 +227,7 @@ def test_private_thread_reply_view_doesnt_init_posting_form_with_invisible_quote assert_contains(response, "Reply to thread") assert_contains(response, other_user_private_thread.title) assert_not_contains(response, f"[quote=QuotedUser, post: {post.id}]") - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, "[/quote]") @@ -235,7 +235,7 @@ def test_private_thread_reply_view_doesnt_init_posting_form_with_other_thread_qu thread_reply_factory, user_client, other_user_private_thread, user_private_thread ): post = thread_reply_factory( - user_private_thread, poster="QuotedUser", original="Bread and butter" + user_private_thread, poster="QuotedUser", content="Bread and butter" ) response = user_client.get( @@ -251,7 +251,7 @@ def test_private_thread_reply_view_doesnt_init_posting_form_with_other_thread_qu assert_contains(response, "Reply to thread") assert_contains(response, other_user_private_thread.title) assert_not_contains(response, f"[quote=QuotedUser, post: {post.id}]") - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, "[/quote]") @@ -750,7 +750,7 @@ def test_private_thread_reply_view_merges_reply_with_users_recent_post( thread_reply_factory, user, user_client, other_user_private_thread ): reply = thread_reply_factory( - other_user_private_thread, poster=user, original="Previous message" + other_user_private_thread, poster=user, content="Previous message" ) response = user_client.post( @@ -781,7 +781,7 @@ def test_private_thread_reply_view_merges_reply_with_users_recent_post( + f"#post-{reply.id}" ) - assert reply.original == "Previous message\n\nReply contents" + assert reply.content == "Previous message\n\nReply contents" post_edit = PostEdit.objects.get(post=reply) assert not post_edit.edit_reason @@ -793,7 +793,7 @@ def test_private_thread_reply_view_merges_reply_with_users_recent_post_in_htmx( thread_reply_factory, user, user_client, other_user_private_thread ): reply = thread_reply_factory( - other_user_private_thread, poster=user, original="Previous message" + other_user_private_thread, poster=user, content="Previous message" ) response = user_client.post( @@ -815,9 +815,9 @@ def test_private_thread_reply_view_merges_reply_with_users_recent_post_in_htmx( reply.refresh_from_db() assert_contains(response, f"post-{reply.id}") - assert_contains(response, reply.parsed) + assert_contains(response, reply.content_parsed) - assert reply.original == "Previous message\n\nReply contents" + assert reply.content == "Previous message\n\nReply contents" @override_dynamic_settings(merge_concurrent_posts=0, flood_control=0) @@ -829,7 +829,7 @@ def test_private_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_ mock_notify_on_new_thread_reply, ): reply = thread_reply_factory( - other_user_private_thread, poster=user, original="Previous message" + other_user_private_thread, poster=user, content="Previous message" ) response = user_client.post( @@ -862,7 +862,7 @@ def test_private_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_ ) reply.refresh_from_db() - assert reply.original == "Previous message" + assert reply.content == "Previous message" mock_notify_on_new_thread_reply.delay.assert_called_once_with( other_user_private_thread.last_post_id @@ -874,7 +874,7 @@ def test_private_thread_reply_view_doesnt_merge_reply_with_users_recent_post_in_ thread_reply_factory, user, user_client, other_user_private_thread ): thread_reply_factory( - other_user_private_thread, poster=user, original="Previous message" + other_user_private_thread, poster=user, content="Previous message" ) response = user_client.post( @@ -908,7 +908,7 @@ def test_private_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_ post = thread_reply_factory( other_user_private_thread, poster=user, - original="Previous message", + content="Previous message", posted_at=-120, ) @@ -941,7 +941,7 @@ def test_private_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_ ) assert reply.id == post.id + 1 - assert reply.original == "Reply contents" + assert reply.content == "Reply contents" mock_notify_on_new_thread_reply.delay.assert_called_once_with(reply.id) @@ -954,7 +954,7 @@ def test_private_thread_reply_view_doesnt_merge_reply_with_recent_post_if_its_by mock_notify_on_new_thread_reply, ): post = thread_reply_factory( - other_user_private_thread, poster=other_user, original="Previous message" + other_user_private_thread, poster=other_user, content="Previous message" ) response = user_client.post( @@ -986,7 +986,7 @@ def test_private_thread_reply_view_doesnt_merge_reply_with_recent_post_if_its_by ) assert reply.id == post.id + 1 - assert reply.original == "Reply contents" + assert reply.content == "Reply contents" mock_notify_on_new_thread_reply.delay.assert_called_once_with(reply.id) @@ -1002,7 +1002,7 @@ def test_private_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_ post = thread_reply_factory( other_user_private_thread, poster=user, - original="Previous message", + content="Previous message", is_hidden=True, ) @@ -1035,7 +1035,7 @@ def test_private_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_ ) assert reply.id == post.id + 1 - assert reply.original == "Reply contents" + assert reply.content == "Reply contents" mock_notify_on_new_thread_reply.delay.assert_called_once_with(reply.id) @@ -1051,7 +1051,7 @@ def test_private_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_ post = thread_reply_factory( other_user_private_thread, poster=user, - original="Previous message", + content="Previous message", is_locked=True, ) @@ -1084,7 +1084,7 @@ def test_private_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_ ) assert reply.id == post.id + 1 - assert reply.original == "Reply contents" + assert reply.content == "Reply contents" mock_notify_on_new_thread_reply.delay.assert_called_once_with(reply.id) diff --git a/misago/posting/tests/test_reply_state.py b/misago/posting/tests/test_reply_state.py index 7e4879a11c..5ef00c266e 100644 --- a/misago/posting/tests/test_reply_state.py +++ b/misago/posting/tests/test_reply_state.py @@ -78,16 +78,16 @@ def test_reply_state_updates_user(user_request, other_user_thread, user): def test_reply_state_updates_existing_post(user, user_request, user_thread): category = user_thread.category post = user_thread.first_post - post_original = post.original - post_parsed = post.parsed + post_original = post.content + post_parsed = post.content_parsed state = ReplyState(user_request, user_thread, post) state.set_post_message(parse("Test reply")) state.save() post.refresh_from_db() - assert post.original == f"{post_original}\n\nTest reply" - assert post.parsed == f"{post_parsed}\n

Test reply

" + assert post.content == f"{post_original}\n\nTest reply" + assert post.content_parsed == f"{post_parsed}\n

Test reply

" assert post.search_document == ( f"{user_thread.title}\n\n{post_original}\n\nTest reply" ) diff --git a/misago/posting/tests/test_state.py b/misago/posting/tests/test_state.py index f924c3deef..1f7bcbf7b3 100644 --- a/misago/posting/tests/test_state.py +++ b/misago/posting/tests/test_state.py @@ -75,8 +75,8 @@ def test_state_set_post_message_updates_post_contents(user_request, post): state.post = post state.set_post_message(parse("Hello world")) - assert post.original == "Hello world" - assert post.parsed == "

Hello world

" + assert post.content == "Hello world" + assert post.content_parsed == "

Hello world

" assert post.metadata == {} @@ -87,8 +87,8 @@ def test_state_set_post_message_stores_attachments_ids_in_post_metadata( state.post = post state.set_post_message(parse("")) - assert post.original == "" - assert post.parsed == ( + assert post.content == "" + assert post.content_parsed == ( '' ) assert post.metadata == {"attachments": [123]} diff --git a/misago/posting/tests/test_thread_edit_view.py b/misago/posting/tests/test_thread_edit_view.py index d397a087c5..d1dbfdf0b1 100644 --- a/misago/posting/tests/test_thread_edit_view.py +++ b/misago/posting/tests/test_thread_edit_view.py @@ -177,7 +177,7 @@ def test_thread_edit_view_displays_edit_form(user_client, user_thread): ) assert_contains(response, "Edit thread") assert_contains(response, user_thread.title) - assert_contains(response, user_thread.first_post.original) + assert_contains(response, user_thread.first_post.content) def test_thread_edit_view_displays_edit_form_for_moderator( @@ -194,7 +194,7 @@ def test_thread_edit_view_displays_edit_form_for_moderator( ) assert_contains(response, "Edit thread") assert_contains(response, user_thread.title) - assert_contains(response, user_thread.first_post.original) + assert_contains(response, user_thread.first_post.content) def test_thread_edit_view_displays_inline_edit_form_in_htmx(user_client, user_thread): @@ -211,7 +211,7 @@ def test_thread_edit_view_displays_inline_edit_form_in_htmx(user_client, user_th ) assert_contains(response, "Save") assert_contains(response, user_thread.title) - assert_contains(response, user_thread.first_post.original) + assert_contains(response, user_thread.first_post.content) assert_contains(response, "?inline=true") @@ -241,7 +241,7 @@ def test_thread_edit_view_updates_thread_title_and_post(user_client, user, user_ assert user_thread.title == "Edited title" post = user_thread.first_post - assert post.original == "Edited post" + assert post.content == "Edited post" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -286,7 +286,7 @@ def test_thread_edit_view_updates_thread_title_and_post_in_htmx( assert user_thread.title == "Edited title" post = user_thread.first_post - assert post.original == "Edited post" + assert post.content == "Edited post" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -323,7 +323,7 @@ def test_thread_edit_view_updates_thread_title_and_post_inline_in_htmx( assert user_thread.title == "Edited title" post = user_thread.first_post - assert post.original == "Edited post" + assert post.content == "Edited post" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -351,7 +351,7 @@ def test_thread_edit_view_sets_edit_reason(user_client, user, user_thread): post = user_thread.first_post post.refresh_from_db() - assert post.original == "Edited post" + assert post.content == "Edited post" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -563,7 +563,7 @@ def test_thread_edit_view_skips_flood_control(user_client, user_thread, user_rep post = user_thread.first_post post.refresh_from_db() - assert post.original == "This is a flood message" + assert post.content == "This is a flood message" assert post.edits == 1 diff --git a/misago/posting/tests/test_thread_post_edit_view.py b/misago/posting/tests/test_thread_post_edit_view.py index 2caa1c7035..ece29f0c9b 100644 --- a/misago/posting/tests/test_thread_post_edit_view.py +++ b/misago/posting/tests/test_thread_post_edit_view.py @@ -265,7 +265,7 @@ def test_thread_post_edit_view_displays_edit_form( ) assert_contains(response, "Edit post") assert_contains(response, thread.title) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_thread_post_edit_view_displays_edit_form_for_moderator( @@ -281,7 +281,7 @@ def test_thread_post_edit_view_displays_edit_form_for_moderator( ) assert_contains(response, "Edit post") assert_contains(response, thread.title) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_thread_post_edit_view_displays_inline_edit_form_in_htmx( @@ -297,7 +297,7 @@ def test_thread_post_edit_view_displays_inline_edit_form_in_htmx( + "?inline=true", headers={"hx-request": "true"}, ) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Save") assert_contains(response, "?inline=true") @@ -332,7 +332,7 @@ def test_thread_post_edit_view_updates_thread_post( ) post.refresh_from_db() - assert post.original == "Edited" + assert post.content == "Edited" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -379,7 +379,7 @@ def test_thread_post_edit_view_updates_thread_post_in_htmx( ) post.refresh_from_db() - assert post.original == "Edited" + assert post.content == "Edited" assert post.edits == 1 @@ -406,7 +406,7 @@ def test_thread_post_edit_view_updates_thread_post_inline_in_htmx( assert_contains(response, "

Edited

") post.refresh_from_db() - assert post.original == "Edited" + assert post.content == "Edited" assert post.edits == 1 @@ -432,7 +432,7 @@ def test_thread_post_edit_view_sets_edit_reason( assert response.status_code == 302 post.refresh_from_db() - assert post.original == "Edited post" + assert post.content == "Edited post" assert post.updated_at assert post.edits == 1 assert post.last_editor == user @@ -599,7 +599,7 @@ def test_thread_post_edit_view_skips_flood_control( post.refresh_from_db() - assert post.original == "This is a flood message" + assert post.content == "This is a flood message" assert post.edits == 1 diff --git a/misago/posting/tests/test_thread_reply_view.py b/misago/posting/tests/test_thread_reply_view.py index f35bc4db97..8e2e713937 100644 --- a/misago/posting/tests/test_thread_reply_view.py +++ b/misago/posting/tests/test_thread_reply_view.py @@ -194,9 +194,7 @@ def test_thread_reply_view_displays_posting_form_to_users_with_in_locked_thread_ def test_thread_reply_view_displays_posting_form_with_quoted_post( thread_reply_factory, user_client, thread ): - post = thread_reply_factory( - thread, poster="QuotedUser", original="Bread and butter" - ) + post = thread_reply_factory(thread, poster="QuotedUser", content="Bread and butter") response = user_client.get( reverse( @@ -211,7 +209,7 @@ def test_thread_reply_view_displays_posting_form_with_quoted_post( assert_contains(response, "Reply to thread") assert_contains(response, thread.title) assert_contains(response, f"[quote=QuotedUser, post: {post.id}]") - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "[/quote]") @@ -219,7 +217,7 @@ def test_thread_reply_view_doesnt_init_posting_form_with_hidden_quoted_post( thread_reply_factory, user_client, thread ): post = thread_reply_factory( - thread, poster="QuotedUser", original="Bread and butter", is_hidden=True + thread, poster="QuotedUser", content="Bread and butter", is_hidden=True ) response = user_client.get( @@ -235,7 +233,7 @@ def test_thread_reply_view_doesnt_init_posting_form_with_hidden_quoted_post( assert_contains(response, "Reply to thread") assert_contains(response, thread.title) assert_not_contains(response, f"[quote=QuotedUser, post: {post.id}]") - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, "[/quote]") @@ -243,7 +241,7 @@ def test_thread_reply_view_doesnt_init_posting_form_with_invisible_quoted_post( thread_reply_factory, user_client, thread ): post = thread_reply_factory( - thread, poster="QuotedUser", original="Bread and butter", is_unapproved=True + thread, poster="QuotedUser", content="Bread and butter", is_unapproved=True ) response = user_client.get( @@ -259,7 +257,7 @@ def test_thread_reply_view_doesnt_init_posting_form_with_invisible_quoted_post( assert_contains(response, "Reply to thread") assert_contains(response, thread.title) assert_not_contains(response, f"[quote=QuotedUser, post: {post.id}]") - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, "[/quote]") @@ -267,7 +265,7 @@ def test_thread_reply_view_doesnt_init_posting_form_with_other_thread_quoted_pos thread_reply_factory, user_client, thread, user_thread ): post = thread_reply_factory( - user_thread, poster="QuotedUser", original="Bread and butter" + user_thread, poster="QuotedUser", content="Bread and butter" ) response = user_client.get( @@ -283,7 +281,7 @@ def test_thread_reply_view_doesnt_init_posting_form_with_other_thread_quoted_pos assert_contains(response, "Reply to thread") assert_contains(response, thread.title) assert_not_contains(response, f"[quote=QuotedUser, post: {post.id}]") - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, "[/quote]") @@ -725,7 +723,7 @@ def test_thread_reply_view_runs_flood_control_in_quick_reply_in_htmx( def test_thread_reply_view_merges_reply_with_users_recent_post( thread_reply_factory, user, user_client, thread ): - reply = thread_reply_factory(thread, poster=user, original="Previous message") + reply = thread_reply_factory(thread, poster=user, content="Previous message") response = user_client.post( reverse( @@ -748,7 +746,7 @@ def test_thread_reply_view_merges_reply_with_users_recent_post( + f"#post-{reply.id}" ) - assert reply.original == "Previous message\n\nReply contents" + assert reply.content == "Previous message\n\nReply contents" post_edit = PostEdit.objects.get(post=reply) assert not post_edit.edit_reason @@ -759,7 +757,7 @@ def test_thread_reply_view_merges_reply_with_users_recent_post( def test_thread_reply_view_merges_reply_with_users_recent_post_in_htmx( thread_reply_factory, user, user_client, thread ): - reply = thread_reply_factory(thread, poster=user, original="Previous message") + reply = thread_reply_factory(thread, poster=user, content="Previous message") response = user_client.post( reverse( @@ -780,16 +778,16 @@ def test_thread_reply_view_merges_reply_with_users_recent_post_in_htmx( reply.refresh_from_db() assert_contains(response, f"post-{reply.id}") - assert_contains(response, reply.parsed) + assert_contains(response, reply.content_parsed) - assert reply.original == "Previous message\n\nReply contents" + assert reply.content == "Previous message\n\nReply contents" @override_dynamic_settings(merge_concurrent_posts=0, flood_control=0) def test_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_feature_is_disabled( thread_reply_factory, user, user_client, thread, mock_notify_on_new_thread_reply ): - reply = thread_reply_factory(thread, poster=user, original="Previous message") + reply = thread_reply_factory(thread, poster=user, content="Previous message") response = user_client.post( reverse( @@ -814,7 +812,7 @@ def test_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_feature_ ) reply.refresh_from_db() - assert reply.original == "Previous message" + assert reply.content == "Previous message" mock_notify_on_new_thread_reply.delay.assert_called_once_with(thread.last_post_id) @@ -823,7 +821,7 @@ def test_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_feature_ def test_thread_reply_view_doesnt_merge_reply_with_users_recent_post_in_preview( thread_reply_factory, user, user_client, thread ): - thread_reply_factory(thread, poster=user, original="Previous message") + thread_reply_factory(thread, poster=user, content="Previous message") response = user_client.post( reverse( @@ -847,7 +845,7 @@ def test_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_its_too_ thread_reply_factory, user, user_client, thread, mock_notify_on_new_thread_reply ): post = thread_reply_factory( - thread, poster=user, original="Previous message", posted_at=-120 + thread, poster=user, content="Previous message", posted_at=-120 ) response = user_client.post( @@ -872,7 +870,7 @@ def test_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_its_too_ ) assert reply.id == post.id + 1 - assert reply.original == "Reply contents" + assert reply.content == "Reply contents" mock_notify_on_new_thread_reply.delay.assert_called_once_with(reply.id) @@ -884,7 +882,7 @@ def test_thread_reply_view_doesnt_merge_reply_with_recent_post_if_its_by_other_u thread, mock_notify_on_new_thread_reply, ): - post = thread_reply_factory(thread, poster=other_user, original="Previous message") + post = thread_reply_factory(thread, poster=other_user, content="Previous message") response = user_client.post( reverse( @@ -908,7 +906,7 @@ def test_thread_reply_view_doesnt_merge_reply_with_recent_post_if_its_by_other_u ) assert reply.id == post.id + 1 - assert reply.original == "Reply contents" + assert reply.content == "Reply contents" mock_notify_on_new_thread_reply.delay.assert_called_once_with(reply.id) @@ -918,7 +916,7 @@ def test_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_its_hidd thread_reply_factory, user, user_client, thread, mock_notify_on_new_thread_reply ): post = thread_reply_factory( - thread, poster=user, original="Previous message", is_hidden=True + thread, poster=user, content="Previous message", is_hidden=True ) response = user_client.post( @@ -943,7 +941,7 @@ def test_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_its_hidd ) assert reply.id == post.id + 1 - assert reply.original == "Reply contents" + assert reply.content == "Reply contents" mock_notify_on_new_thread_reply.delay.assert_called_once_with(reply.id) @@ -953,7 +951,7 @@ def test_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_its_not_ thread_reply_factory, user, user_client, thread, mock_notify_on_new_thread_reply ): post = thread_reply_factory( - thread, poster=user, original="Previous message", is_locked=True + thread, poster=user, content="Previous message", is_locked=True ) response = user_client.post( @@ -978,7 +976,7 @@ def test_thread_reply_view_doesnt_merge_reply_with_users_recent_post_if_its_not_ ) assert reply.id == post.id + 1 - assert reply.original == "Reply contents" + assert reply.content == "Reply contents" mock_notify_on_new_thread_reply.delay.assert_called_once_with(reply.id) diff --git a/misago/posting/tests/test_upgrade_post_code_blocks.py b/misago/posting/tests/test_upgrade_post_code_blocks.py index ba982b1f7a..e7fff3bd81 100644 --- a/misago/posting/tests/test_upgrade_post_code_blocks.py +++ b/misago/posting/tests/test_upgrade_post_code_blocks.py @@ -5,21 +5,21 @@ def test_upgrade_post_code_blocks_upgrades_post_code(post): - post.parsed = html_element("misago-code", "add(1, 2)", {"syntax": "python"}) + post.content_parsed = html_element("misago-code", "add(1, 2)", {"syntax": "python"}) post.metadata["highlight_code"] = True post.save() upgrade_post_code_blocks(post) post.refresh_from_db() - assert post.parsed.startswith('') - assert post.parsed.endswith("") - assert "span" in post.parsed + assert post.content_parsed.startswith('') + assert post.content_parsed.endswith("") + assert "span" in post.content_parsed assert post.metadata == {} def test_upgrade_post_code_blocks_upgrades_escaped_code(post): - post.parsed = html_element( + post.content_parsed = html_element( "misago-code", escape('echo("")'), {"syntax": "php"} ) post.metadata["highlight_code"] = True @@ -28,70 +28,78 @@ def test_upgrade_post_code_blocks_upgrades_escaped_code(post): upgrade_post_code_blocks(post) post.refresh_from_db() - assert post.parsed.startswith('') - assert post.parsed.endswith("") - assert "echo("<code>")" in post.parsed - assert '""' not in post.parsed + assert post.content_parsed.startswith('') + assert post.content_parsed.endswith("") + assert "echo("<code>")" in post.content_parsed + assert '""' not in post.content_parsed assert post.metadata == {} def test_upgrade_post_code_blocks_upgrades_multiple_code_blocks(post): - post.parsed = html_element("misago-code", "add(1, 2)", {"syntax": "python"}) - post.parsed += "

Hello

" - post.parsed += html_element("misago-code", "add(1, 2)", {"syntax": "php"}) + post.content_parsed = html_element("misago-code", "add(1, 2)", {"syntax": "python"}) + post.content_parsed += "

Hello

" + post.content_parsed += html_element("misago-code", "add(1, 2)", {"syntax": "php"}) post.metadata["highlight_code"] = True post.save() upgrade_post_code_blocks(post) post.refresh_from_db() - assert "

Hello

" in post.parsed - assert "span" in post.parsed + assert "

Hello

" in post.content_parsed + assert "span" in post.content_parsed assert post.metadata == {} def test_upgrade_post_code_blocks_handles_unsupported_syntax(post): - post.parsed = html_element("misago-code", "add(1, 2)", {"syntax": "invalid"}) + post.content_parsed = html_element( + "misago-code", "add(1, 2)", {"syntax": "invalid"} + ) post.metadata["highlight_code"] = True post.save() upgrade_post_code_blocks(post) post.refresh_from_db() - assert post.parsed == 'add(1, 2)' + assert ( + post.content_parsed == 'add(1, 2)' + ) assert post.metadata == {} def test_upgrade_post_code_blocks_handles_unspecified_syntax(post): - post.parsed = html_element("misago-code", "add(1, 2)") + post.content_parsed = html_element("misago-code", "add(1, 2)") post.metadata["highlight_code"] = True post.save() upgrade_post_code_blocks(post) post.refresh_from_db() - assert post.parsed == "add(1, 2)" + assert post.content_parsed == "add(1, 2)" assert post.metadata == {} def test_upgrade_post_code_blocks_skips_upgrade_if_metadata_flag_is_false(post): - post.parsed = html_element("misago-code", "add(1, 2)", {"syntax": "python"}) + post.content_parsed = html_element("misago-code", "add(1, 2)", {"syntax": "python"}) post.metadata["highlight_code"] = False post.save() upgrade_post_code_blocks(post) post.refresh_from_db() - assert post.parsed == ('add(1, 2)') + assert post.content_parsed == ( + 'add(1, 2)' + ) assert post.metadata == {} def test_upgrade_post_code_blocks_skips_upgrade_if_metadata_flag_is_not_set(post): - post.parsed = html_element("misago-code", "add(1, 2)", {"syntax": "python"}) + post.content_parsed = html_element("misago-code", "add(1, 2)", {"syntax": "python"}) post.save() upgrade_post_code_blocks(post) post.refresh_from_db() - assert post.parsed == ('add(1, 2)') + assert post.content_parsed == ( + 'add(1, 2)' + ) assert post.metadata == {} diff --git a/misago/posting/tests/test_upgrade_post_content.py b/misago/posting/tests/test_upgrade_post_content.py index 112e9bae7a..16919846e2 100644 --- a/misago/posting/tests/test_upgrade_post_content.py +++ b/misago/posting/tests/test_upgrade_post_content.py @@ -3,7 +3,7 @@ def test_upgrade_post_content_upgrades_post_code(post): - post.parsed = html_element( + post.content_parsed = html_element( "misago-code", "
add(1, 2)
", {"syntax": "python"} ) post.metadata["highlight_code"] = True @@ -12,5 +12,5 @@ def test_upgrade_post_content_upgrades_post_code(post): upgrade_post_content(post) post.refresh_from_db() - assert "span" in post.parsed + assert "span" in post.content_parsed assert post.metadata == {} diff --git a/misago/posting/tests/test_upgrade_post_content_task.py b/misago/posting/tests/test_upgrade_post_content_task.py index 3b5c190c5f..b3a6c0bdff 100644 --- a/misago/posting/tests/test_upgrade_post_content_task.py +++ b/misago/posting/tests/test_upgrade_post_content_task.py @@ -28,7 +28,7 @@ def test_upgrade_post_content_task_logs_exceptions(mocker, post): def test_upgrade_post_content_task_upgrades_post_code(post): - post.parsed = html_element( + post.content_parsed = html_element( "misago-code", "
add(1, 2)
", {"syntax": "python"} ) post.metadata["highlight_code"] = True @@ -37,5 +37,5 @@ def test_upgrade_post_content_task_upgrades_post_code(post): upgrade_post_content(post.id, post.sha256_checksum) post.refresh_from_db() - assert "span" in post.parsed + assert "span" in post.content_parsed assert post.metadata == {} diff --git a/misago/posting/upgradepost.py b/misago/posting/upgradepost.py index e3e566f9b4..3cac278070 100644 --- a/misago/posting/upgradepost.py +++ b/misago/posting/upgradepost.py @@ -43,15 +43,17 @@ def _upgrade_post_code_blocks_action(post: Post): return if post.metadata["highlight_code"]: - html = CODE_BLOCK_PATTERN.sub(upgrade_post_code_blocks_syntax, post.parsed) + html = CODE_BLOCK_PATTERN.sub( + upgrade_post_code_blocks_syntax, post.content_parsed + ) else: html = None post.metadata.pop("highlight_code") - if html and post.parsed != html: - post.parsed = html - post.save(update_fields=["parsed", "metadata"]) + if html and post.content_parsed != html: + post.content_parsed = html + post.save(update_fields=["content_parsed", "metadata"]) else: post.save(update_fields=["metadata"]) diff --git a/misago/posting/views/edit.py b/misago/posting/views/edit.py index 244939a893..8212ebbe42 100644 --- a/misago/posting/views/edit.py +++ b/misago/posting/views/edit.py @@ -173,7 +173,7 @@ def render( attachments=preview.attachments, ) - context["preview"] = preview.post.parsed + context["preview"] = preview.post.content_parsed context["preview_rich_text_data"] = related_objects if self.is_inline(request): diff --git a/misago/posting/views/reply.py b/misago/posting/views/reply.py index 075c57f35d..30df16db51 100644 --- a/misago/posting/views/reply.py +++ b/misago/posting/views/reply.py @@ -207,7 +207,7 @@ def get_formset_initial_data( data["post"] = ( f"[quote={quoted_post.poster_name}, post: {quoted_post.id}]" "\n" - f"{quoted_post.original}" + f"{quoted_post.content}" "\n" "[/quote]" "\n\n" @@ -274,7 +274,7 @@ def render( attachments=preview.attachments, ) - context["preview"] = preview.post.parsed + context["preview"] = preview.post.content_parsed context["preview_rich_text_data"] = related_objects if extra_context: diff --git a/misago/posting/views/start.py b/misago/posting/views/start.py index 59cae01b9d..90928c7294 100644 --- a/misago/posting/views/start.py +++ b/misago/posting/views/start.py @@ -100,7 +100,7 @@ def preview( attachments=state.attachments, ) - context["preview"] = state.post.parsed + context["preview"] = state.post.content_parsed context["preview_rich_text_data"] = related_objects return render(request, self.template_name, context) diff --git a/misago/privatethreads/tests/test_private_thread_detail_view_moderation_actions.py b/misago/privatethreads/tests/test_private_thread_detail_view_moderation_actions.py index 262ce13108..3acafe5358 100644 --- a/misago/privatethreads/tests/test_private_thread_detail_view_moderation_actions.py +++ b/misago/privatethreads/tests/test_private_thread_detail_view_moderation_actions.py @@ -919,10 +919,10 @@ def test_private_thread_detail_view_merge_posts_moderation_action_merges_posts( mock_posts_synchronize_categories, ): target_post = thread_reply_factory( - user_private_thread, poster=user, original="Target body" + user_private_thread, poster=user, content="Target body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) response = moderator_client.post( @@ -966,7 +966,7 @@ def test_private_thread_detail_view_merge_posts_moderation_action_merges_posts( ) target_post.refresh_from_db() - assert target_post.original == "Target body\n\nOther body" + assert target_post.content == "Target body\n\nOther body" assert not target_post.last_edit_reason post_edit = PostEdit.objects.get(post=target_post) @@ -992,10 +992,10 @@ def test_private_thread_detail_view_merge_posts_moderation_action_merges_posts_i mock_posts_synchronize_categories, ): target_post = thread_reply_factory( - user_private_thread, poster=user, original="Target body" + user_private_thread, poster=user, content="Target body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) response = moderator_client.post( @@ -1029,7 +1029,7 @@ def test_private_thread_detail_view_merge_posts_moderation_action_merges_posts_i assert response.status_code == 200 target_post.refresh_from_db() - assert target_post.original == "Target body\n\nOther body" + assert target_post.content == "Target body\n\nOther body" assert not target_post.last_edit_reason post_edit = PostEdit.objects.get(post=target_post) @@ -1055,10 +1055,10 @@ def test_private_thread_detail_view_merge_posts_moderation_action_merges_posts_w mock_posts_synchronize_categories, ): target_post = thread_reply_factory( - user_private_thread, poster=user, original="Target body" + user_private_thread, poster=user, content="Target body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) response = moderator_client.post( @@ -1103,7 +1103,7 @@ def test_private_thread_detail_view_merge_posts_moderation_action_merges_posts_w ) target_post.refresh_from_db() - assert target_post.original == "Target body\n\nOther body" + assert target_post.content == "Target body\n\nOther body" assert target_post.last_edit_reason == "Test merge" post_edit = PostEdit.objects.get(post=target_post) @@ -1131,10 +1131,10 @@ def test_private_thread_detail_view_merge_posts_moderation_action_merges_posts_w mock_posts_synchronize_categories, ): target_post = thread_reply_factory( - user_private_thread, poster=user, original="Target body" + user_private_thread, poster=user, content="Target body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) text_attachment.associate_with_post(target_post) @@ -1184,7 +1184,7 @@ def test_private_thread_detail_view_merge_posts_moderation_action_merges_posts_w ) target_post.refresh_from_db() - assert target_post.original == "Target body\n\nOther body" + assert target_post.content == "Target body\n\nOther body" assert not target_post.last_edit_reason text_attachment.refresh_from_db() @@ -1220,10 +1220,10 @@ def test_private_thread_detail_view_merge_posts_moderation_action_orders_posts_f mock_posts_synchronize_categories, ): target_post = thread_reply_factory( - user_private_thread, poster=user, original="Target body" + user_private_thread, poster=user, content="Target body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) response = moderator_client.post( @@ -1267,7 +1267,7 @@ def test_private_thread_detail_view_merge_posts_moderation_action_orders_posts_f ) target_post.refresh_from_db() - assert target_post.original == "Target body\n\nOther body" + assert target_post.content == "Target body\n\nOther body" assert not target_post.last_edit_reason post_edit = PostEdit.objects.get(post=target_post) @@ -1292,7 +1292,7 @@ def test_private_thread_detail_view_merge_posts_moderation_action_validates_mult mock_posts_synchronize_categories, ): target_post = thread_reply_factory( - user_private_thread, poster=user, original="Target body" + user_private_thread, poster=user, content="Target body" ) response = moderator_client.post( @@ -1308,7 +1308,7 @@ def test_private_thread_detail_view_merge_posts_moderation_action_validates_mult assert_contains(response, "Select at least two posts to merge.") target_post.refresh_from_db() - assert target_post.original == "Target body" + assert target_post.content == "Target body" assert not PostEdit.objects.exists() @@ -1324,10 +1324,10 @@ def test_private_thread_detail_view_merge_posts_moderation_action_validates_post mock_posts_synchronize_categories, ): target_post = thread_reply_factory( - user_private_thread, poster=user, original="Target body" + user_private_thread, poster=user, content="Target body" ) other_post = thread_reply_factory( - user_private_thread, poster=other_user, original="Other body" + user_private_thread, poster=other_user, content="Other body" ) response = moderator_client.post( @@ -1343,10 +1343,10 @@ def test_private_thread_detail_view_merge_posts_moderation_action_validates_post assert_contains(response, "Merged posts must belong to the same user.") target_post.refresh_from_db() - assert target_post.original == "Target body" + assert target_post.content == "Target body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" assert not PostEdit.objects.exists() @@ -1360,10 +1360,10 @@ def test_private_thread_detail_view_merge_posts_moderation_action_validates_post mock_posts_synchronize_categories, ): target_post = thread_reply_factory( - user_private_thread, poster="John", original="Target body" + user_private_thread, poster="John", content="Target body" ) other_post = thread_reply_factory( - user_private_thread, poster="Alice", original="Other body" + user_private_thread, poster="Alice", content="Other body" ) response = moderator_client.post( @@ -1379,10 +1379,10 @@ def test_private_thread_detail_view_merge_posts_moderation_action_validates_post assert_contains(response, "Merged posts must belong to the same user.") target_post.refresh_from_db() - assert target_post.original == "Target body" + assert target_post.content == "Target body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" assert not PostEdit.objects.exists() @@ -1749,10 +1749,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_other_po ): current_post = user_private_thread.first_post other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) - current_post_content = current_post.original + current_post_content = current_post.content response = moderator_client.post( reverse( @@ -1806,7 +1806,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_other_po ) current_post.refresh_from_db() - assert current_post.original == f"{current_post_content}\n\nOther body" + assert current_post.content == f"{current_post_content}\n\nOther body" assert not current_post.last_edit_reason post_edit = PostEdit.objects.get(post=current_post) @@ -1833,10 +1833,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_other_po ): current_post = user_private_thread.first_post other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) - current_post_content = current_post.original + current_post_content = current_post.content response = moderator_client.post( reverse( @@ -1881,7 +1881,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_other_po assert response["hx-refresh"] == "true" current_post.refresh_from_db() - assert current_post.original == f"{current_post_content}\n\nOther body" + assert current_post.content == f"{current_post_content}\n\nOther body" assert not current_post.last_edit_reason post_edit = PostEdit.objects.get(post=current_post) @@ -1907,10 +1907,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_current_ mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) response = moderator_client.post( @@ -1966,7 +1966,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_current_ ) other_post.refresh_from_db() - assert other_post.original == "Current body\n\nOther body" + assert other_post.content == "Current body\n\nOther body" assert not other_post.last_edit_reason post_edit = PostEdit.objects.get(post=other_post) @@ -1992,10 +1992,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_current_ mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) response = moderator_client.post( @@ -2042,7 +2042,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_current_ assert response["hx-refresh"] == "true" current_post.refresh_from_db() - assert current_post.original == "Current body\n\nOther body" + assert current_post.content == "Current body\n\nOther body" assert not current_post.last_edit_reason post_edit = PostEdit.objects.get(post=current_post) @@ -2068,10 +2068,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_other_po mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) response = moderator_client.post( @@ -2127,7 +2127,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_other_po ) current_post.refresh_from_db() - assert current_post.original == "Current body\n\nOther body" + assert current_post.content == "Current body\n\nOther body" assert not current_post.last_edit_reason post_edit = PostEdit.objects.get(post=current_post) @@ -2153,10 +2153,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_other_po mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) response = moderator_client.post( @@ -2203,7 +2203,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_other_po assert response["hx-refresh"] == "true" other_post.refresh_from_db() - assert other_post.original == "Current body\n\nOther body" + assert other_post.content == "Current body\n\nOther body" assert not other_post.last_edit_reason post_edit = PostEdit.objects.get(post=other_post) @@ -2229,10 +2229,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_posts_wi mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) response = moderator_client.post( @@ -2289,7 +2289,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_posts_wi ) current_post.refresh_from_db() - assert current_post.original == "Current body\n\nOther body" + assert current_post.content == "Current body\n\nOther body" assert current_post.last_edit_reason == "Test merge" post_edit = PostEdit.objects.get(post=current_post) @@ -2317,10 +2317,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_posts_wi mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) text_attachment.associate_with_post(current_post) @@ -2383,7 +2383,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_posts_wi ) current_post.refresh_from_db() - assert current_post.original == "Current body\n\nOther body" + assert current_post.content == "Current body\n\nOther body" assert current_post.last_edit_reason == "Test merge" text_attachment.refresh_from_db() @@ -2421,10 +2421,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_posts_us mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) text_attachment.associate_with_post(current_post) @@ -2480,7 +2480,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_merges_posts_us ) current_post.refresh_from_db() - assert current_post.original == "Current body\n\nOther body" + assert current_post.content == "Current body\n\nOther body" assert current_post.last_edit_reason == "Test merge" text_attachment.refresh_from_db() @@ -2515,10 +2515,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_other mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) other_post = thread_reply_factory( - user_private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Other body" ) response = moderator_client.post( @@ -2557,10 +2557,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_other assert_contains(response, "Enter a valid link.") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" mock_post_synchronize_categories.delay.assert_not_called() @@ -2573,7 +2573,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_threa mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) response = moderator_client.post( @@ -2618,7 +2618,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_threa assert_contains(response, "Post doesn't exist") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" mock_post_synchronize_categories.delay.assert_not_called() @@ -2632,10 +2632,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_threa mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) other_post = thread_reply_factory( - other_user_private_thread, poster=user, original="Other body" + other_user_private_thread, poster=user, content="Other body" ) response = moderator_client.post( @@ -2680,10 +2680,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_threa assert_contains(response, "Enter a link to a post in the current thread.") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" mock_post_synchronize_categories.delay.assert_not_called() @@ -2696,7 +2696,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_threa mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) response = moderator_client.post( @@ -2741,7 +2741,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_threa assert_contains(response, "Can't merge a post with itself.") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" mock_post_synchronize_categories.delay.assert_not_called() @@ -2754,7 +2754,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_globa mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) response = moderator_client.post( @@ -2792,7 +2792,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_globa assert_contains(response, "Post doesn't exist") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" mock_post_synchronize_categories.delay.assert_not_called() @@ -2806,11 +2806,9 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_globa mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" - ) - other_post = thread_reply_factory( - private_thread, poster=user, original="Other body" + user_private_thread, poster=user, content="Current body" ) + other_post = thread_reply_factory(private_thread, poster=user, content="Other body") response = moderator_client.post( reverse( @@ -2847,7 +2845,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_globa assert_contains(response, "Post doesn't exist") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" mock_post_synchronize_categories.delay.assert_not_called() @@ -2861,10 +2859,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_globa mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) other_post = thread_reply_factory( - other_user_private_thread, poster=user, original="Other body" + other_user_private_thread, poster=user, content="Other body" ) response = moderator_client.post( @@ -2902,10 +2900,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_globa assert_contains(response, "Post doesn't exist in this thread") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" mock_post_synchronize_categories.delay.assert_not_called() @@ -2918,7 +2916,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_globa mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) response = moderator_client.post( @@ -2956,7 +2954,7 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_globa assert_contains(response, "Can't merge a post with itself.") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" mock_post_synchronize_categories.delay.assert_not_called() @@ -2969,9 +2967,9 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_first mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) - first_post_content = user_private_thread.first_post.original + first_post_content = user_private_thread.first_post.content response = moderator_client.post( reverse( @@ -3017,10 +3015,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_first ) current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" user_private_thread.first_post.refresh_from_db() - assert user_private_thread.first_post.original == first_post_content + assert user_private_thread.first_post.content == first_post_content mock_post_synchronize_categories.delay.assert_not_called() @@ -3034,10 +3032,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_posts mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster=user, original="Current body" + user_private_thread, poster=user, content="Current body" ) other_post = thread_reply_factory( - user_private_thread, poster=other_user, original="Other body" + user_private_thread, poster=other_user, content="Other body" ) response = moderator_client.post( @@ -3082,10 +3080,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_posts assert_contains(response, "Merged posts must belong to the same user.") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" mock_post_synchronize_categories.delay.assert_not_called() @@ -3097,10 +3095,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_posts mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_private_thread, poster="Bob", original="Current body" + user_private_thread, poster="Bob", content="Current body" ) other_post = thread_reply_factory( - user_private_thread, poster="Elice", original="Other body" + user_private_thread, poster="Elice", content="Other body" ) response = moderator_client.post( @@ -3145,10 +3143,10 @@ def test_private_thread_detail_view_merge_post_moderation_action_validates_posts assert_contains(response, "Merged posts must belong to the same user.") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" mock_post_synchronize_categories.delay.assert_not_called() diff --git a/misago/privatethreads/tests/test_private_thread_detail_view_posts.py b/misago/privatethreads/tests/test_private_thread_detail_view_posts.py index e7f03c160b..a778b0fc6b 100644 --- a/misago/privatethreads/tests/test_private_thread_detail_view_posts.py +++ b/misago/privatethreads/tests/test_private_thread_detail_view_posts.py @@ -42,7 +42,7 @@ def test_private_thread_detail_view_returns_redirect_to_last_page_if_page_is_out thread_reply_factory, user_client, user_private_thread ): for i in range(1, 20): - thread_reply_factory(user_private_thread, original=f"Reply no. {i}") + thread_reply_factory(user_private_thread, content=f"Reply no. {i}") response = user_client.get( reverse( @@ -110,7 +110,7 @@ def test_private_thread_detail_view_shows_first_page_in_multi_page_thread( thread_reply_factory, user_client, user_private_thread ): for i in range(1, 7): - thread_reply_factory(user_private_thread, original=f"Reply no. {i}") + thread_reply_factory(user_private_thread, content=f"Reply no. {i}") response = user_client.get( reverse( @@ -135,7 +135,7 @@ def test_private_thread_detail_view_shows_middle_page_in_multi_page_thread( thread_reply_factory, user_client, user_private_thread ): for i in range(1, 12): - thread_reply_factory(user_private_thread, original=f"Reply no. {i}") + thread_reply_factory(user_private_thread, content=f"Reply no. {i}") response = user_client.get( reverse( @@ -166,7 +166,7 @@ def test_private_thread_detail_view_shows_last_page_in_multi_page_thread( thread_reply_factory, user_client, user_private_thread ): for i in range(1, 7): - thread_reply_factory(user_private_thread, original=f"Reply no. {i}") + thread_reply_factory(user_private_thread, content=f"Reply no. {i}") response = user_client.get( reverse( @@ -190,7 +190,7 @@ def test_private_thread_detail_view_shows_last_page_in_multi_page_thread( def test_private_thread_detail_view_shows_deleted_user_post_to_user( thread_reply_factory, user_client, user_private_thread ): - post = thread_reply_factory(user_private_thread, original=get_random_string(12)) + post = thread_reply_factory(user_private_thread, content=get_random_string(12)) response = user_client.get( reverse( "misago:private-thread", @@ -201,13 +201,13 @@ def test_private_thread_detail_view_shows_deleted_user_post_to_user( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_private_thread_detail_view_shows_deleted_user_post_to_moderator( thread_reply_factory, moderator_client, user_private_thread ): - post = thread_reply_factory(user_private_thread, original=get_random_string(12)) + post = thread_reply_factory(user_private_thread, content=get_random_string(12)) response = moderator_client.get( reverse( "misago:private-thread", @@ -218,14 +218,14 @@ def test_private_thread_detail_view_shows_deleted_user_post_to_moderator( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_private_thread_detail_view_shows_user_post_to_user( thread_reply_factory, user_client, user_private_thread, user ): post = thread_reply_factory( - user_private_thread, original=get_random_string(12), poster=user + user_private_thread, content=get_random_string(12), poster=user ) response = user_client.get( reverse( @@ -237,14 +237,14 @@ def test_private_thread_detail_view_shows_user_post_to_user( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_private_thread_detail_view_shows_other_user_post_to_user( thread_reply_factory, user_client, user_private_thread, other_user ): post = thread_reply_factory( - user_private_thread, original=get_random_string(12), poster=other_user + user_private_thread, content=get_random_string(12), poster=other_user ) response = user_client.get( reverse( @@ -256,14 +256,14 @@ def test_private_thread_detail_view_shows_other_user_post_to_user( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_private_thread_detail_view_shows_user_post_to_moderator( thread_reply_factory, moderator_client, user_private_thread, user ): post = thread_reply_factory( - user_private_thread, original=get_random_string(12), poster=user + user_private_thread, content=get_random_string(12), poster=user ) response = moderator_client.get( reverse( @@ -275,14 +275,14 @@ def test_private_thread_detail_view_shows_user_post_to_moderator( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_private_thread_detail_view_doesnt_show_deleted_user_post_locked_status_message_to_user( thread_reply_factory, user_client, other_user_private_thread ): post = thread_reply_factory( - other_user_private_thread, original=get_random_string(12), is_locked=True + other_user_private_thread, content=get_random_string(12), is_locked=True ) response = user_client.get( reverse( @@ -303,7 +303,7 @@ def test_private_thread_detail_view_doesnt_show_other_user_post_locked_status_me post = thread_reply_factory( other_user_private_thread, poster=other_user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, ) response = user_client.get( @@ -325,7 +325,7 @@ def test_private_thread_detail_view_shows_user_post_locked_status_message_to_use post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, ) response = user_client.get( @@ -345,7 +345,7 @@ def test_private_thread_detail_view_shows_deleted_user_post_locked_status_messag thread_reply_factory, moderator_client, other_user_private_thread ): post = thread_reply_factory( - other_user_private_thread, original=get_random_string(12), is_locked=True + other_user_private_thread, content=get_random_string(12), is_locked=True ) response = moderator_client.get( reverse( @@ -366,7 +366,7 @@ def test_private_thread_detail_view_shows_user_post_locked_status_message_to_mod post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, ) response = moderator_client.get( @@ -388,7 +388,7 @@ def test_private_thread_detail_view_shows_locked_post_with_locked_by_user_at_tim post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_at=True, locked_by=other_user, @@ -415,7 +415,7 @@ def test_private_thread_detail_view_shows_locked_post_with_locked_by_user_at_tim post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_at=True, locked_by=other_user, @@ -441,7 +441,7 @@ def test_private_thread_detail_view_shows_locked_post_with_locked_by_deleted_use post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_at=True, locked_by="OtherUser", @@ -468,7 +468,7 @@ def test_private_thread_detail_view_shows_locked_post_with_locked_by_deleted_use post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_at=True, locked_by="OtherUser", @@ -494,7 +494,7 @@ def test_private_thread_detail_view_shows_locked_post_with_locked_with_at_timest post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_at=True, lock_reason="Lorem ipsum", @@ -520,7 +520,7 @@ def test_private_thread_detail_view_shows_locked_post_with_locked_with_at_timest post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_at=True, ) @@ -545,7 +545,7 @@ def test_private_thread_detail_view_shows_locked_post_with_locked_by_user_with_r post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_by=other_user, lock_reason="Lorem ipsum", @@ -571,7 +571,7 @@ def test_private_thread_detail_view_shows_locked_post_with_locked_by_user_status post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_by=other_user, ) @@ -596,7 +596,7 @@ def test_private_thread_detail_view_shows_locked_post_with_locked_by_deleted_use post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_by="OtherUser", lock_reason="Lorem ipsum", @@ -622,7 +622,7 @@ def test_private_thread_detail_view_shows_locked_post_with_locked_by_deleted_use post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_by="OtherUser", ) @@ -647,7 +647,7 @@ def test_private_thread_detail_view_shows_locked_post_with_lock_reason_status_me post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, lock_reason="Lorem ipsum", ) @@ -671,7 +671,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_timestam ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hidden_by=other_user, @@ -687,7 +687,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_timestam ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -698,7 +698,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_timestam ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hidden_by=other_user, @@ -713,7 +713,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_timestam ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -723,7 +723,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_timestam ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hidden_by="DeletedModerator", @@ -739,7 +739,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_timestam ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -749,7 +749,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_timestam ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hidden_by="DeletedModerator", @@ -764,7 +764,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_timestam ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -773,7 +773,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_timestam ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hide_reason="Lorem ipsum offtopic", @@ -788,7 +788,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_timestam ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -797,7 +797,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_timestam ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, ) @@ -811,7 +811,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_timestam ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_user_and_reason_to_user( @@ -819,7 +819,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_user_and ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_by=other_user, hide_reason="Lorem ipsum offtopic", @@ -834,7 +834,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_user_and ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -845,7 +845,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_user_to_ ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_by=other_user, ) @@ -859,7 +859,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_user_to_ ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -869,7 +869,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_deleted_ ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_by="DeletedModerator", hide_reason="Lorem ipsum offtopic", @@ -884,7 +884,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_deleted_ ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -894,7 +894,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_deleted_ ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_by="DeletedModerator", ) @@ -908,7 +908,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_deleted_ ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -917,7 +917,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_reason_t ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hide_reason="Lorem ipsum offtopic", ) @@ -931,7 +931,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_with_reason_t ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -939,7 +939,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_to_user( thread_reply_factory, user_client, user_private_thread ): post = thread_reply_factory( - user_private_thread, original=get_random_string(12), is_hidden=True + user_private_thread, content=get_random_string(12), is_hidden=True ) response = user_client.get( reverse( @@ -951,7 +951,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_to_user( ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_user_and_reason_to_user( @@ -959,7 +959,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_user_a ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -970,7 +970,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_user_a reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -981,7 +981,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_and_us ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -991,7 +991,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_and_us reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1001,7 +1001,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_delete ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1012,7 +1012,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_delete reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -1022,7 +1022,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_and_de ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1032,7 +1032,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_and_de reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -1041,7 +1041,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_and_re ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1051,7 +1051,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_and_re reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -1060,7 +1060,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_to_use ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1069,7 +1069,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_to_use reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_private_thread_detail_view_shows_user_hidden_post_with_user_and_reason_to_user( @@ -1077,7 +1077,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_user_and_reason_ ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by=other_user, @@ -1087,7 +1087,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_user_and_reason_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -1098,7 +1098,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_user_to_user( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by=other_user, @@ -1107,7 +1107,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_user_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1117,7 +1117,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_deleted_user_and ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by="DeletedModerator", @@ -1127,7 +1127,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_deleted_user_and reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -1137,7 +1137,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_deleted_user_to_ ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by="DeletedModerator", @@ -1146,7 +1146,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_deleted_user_to_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -1155,7 +1155,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_reason_to_user( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hide_reason="Lorem ipsum offtopic", @@ -1164,7 +1164,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_reason_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -1172,7 +1172,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_to_user( thread_reply_factory, user_client, user_private_thread, user ): post = thread_reply_factory( - user_private_thread, original=get_random_string(12), poster=user, is_hidden=True + user_private_thread, content=get_random_string(12), poster=user, is_hidden=True ) response = user_client.get( reverse( @@ -1184,7 +1184,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_to_user( ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_user_and_reason_to_user( @@ -1192,7 +1192,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_ ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_at=True, @@ -1209,7 +1209,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_ ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -1220,7 +1220,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_ ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_at=True, @@ -1236,7 +1236,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_ ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1246,7 +1246,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_ ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_at=True, @@ -1263,7 +1263,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_ ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -1273,7 +1273,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_ ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_at=True, @@ -1289,7 +1289,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_ ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -1298,7 +1298,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_ ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_at=True, @@ -1314,7 +1314,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_ ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -1323,7 +1323,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_ ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_at=True, @@ -1338,7 +1338,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_timestamp_ ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_private_thread_detail_view_shows_other_user_hidden_post_with_user_and_reason_to_user( @@ -1346,7 +1346,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_user_and_r ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_by=other_user, @@ -1362,7 +1362,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_user_and_r ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -1373,7 +1373,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_user_to_us ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_by=other_user, @@ -1388,7 +1388,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_user_to_us ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1398,7 +1398,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_deleted_us ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_by="DeletedModerator", @@ -1414,7 +1414,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_deleted_us ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -1424,7 +1424,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_deleted_us ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_by="DeletedModerator", @@ -1439,7 +1439,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_deleted_us ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -1448,7 +1448,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_reason_to_ ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hide_reason="Lorem ipsum offtopic", @@ -1463,7 +1463,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_with_reason_to_ ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -1472,7 +1472,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_to_user( ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, ) @@ -1486,7 +1486,7 @@ def test_private_thread_detail_view_shows_other_user_hidden_post_to_user( ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_user_and_reason_to_moderator( @@ -1494,7 +1494,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_user_a ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1511,7 +1511,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_user_a ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1523,7 +1523,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_and_us ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1539,7 +1539,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_and_us ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1550,7 +1550,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_delete ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1567,7 +1567,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_delete ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -1578,7 +1578,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_and_de ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1594,7 +1594,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_and_de ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, "DeletedModerator") @@ -1604,7 +1604,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_and_re ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1620,7 +1620,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_and_re ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, "Lorem ipsum offtopic") @@ -1630,7 +1630,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_to_mod ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1645,7 +1645,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_timestamp_to_mod ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") @@ -1654,7 +1654,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_user_and_reason_ ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by=other_user, @@ -1670,7 +1670,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_user_and_reason_ ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1682,7 +1682,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_user_to_moderato ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by=other_user, @@ -1697,7 +1697,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_user_to_moderato ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1708,7 +1708,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_deleted_user_and ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by="DeletedModerator", @@ -1724,7 +1724,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_deleted_user_and ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -1735,7 +1735,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_deleted_user_to_ ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by="DeletedModerator", @@ -1750,7 +1750,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_deleted_user_to_ ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, "DeletedModerator") @@ -1760,7 +1760,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_reason_to_modera ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hide_reason="Lorem ipsum offtopic", @@ -1775,7 +1775,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_with_reason_to_modera ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, "Lorem ipsum offtopic") @@ -1785,7 +1785,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_to_moderator( ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, ) @@ -1799,7 +1799,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_to_moderator( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") @@ -1807,7 +1807,7 @@ def test_private_thread_detail_view_doesnt_show_deleted_user_unapproved_post_to_ thread_reply_factory, user_client, other_user_private_thread ): post = thread_reply_factory( - other_user_private_thread, original=get_random_string(12), is_unapproved=True + other_user_private_thread, content=get_random_string(12), is_unapproved=True ) response = user_client.get( reverse( @@ -1825,7 +1825,7 @@ def test_private_thread_detail_view_shows_deleted_user_unapproved_post_to_modera thread_reply_factory, moderator_client, other_user_private_thread ): post = thread_reply_factory( - other_user_private_thread, original=get_random_string(12), is_unapproved=True + other_user_private_thread, content=get_random_string(12), is_unapproved=True ) response = moderator_client.get( reverse( @@ -1849,7 +1849,7 @@ def test_private_thread_detail_view_doesnt_show_user_unapproved_post_to_other_us post = thread_reply_factory( other_user_private_thread, poster=other_user, - original=get_random_string(12), + content=get_random_string(12), is_unapproved=True, ) response = user_client.get( @@ -1870,7 +1870,7 @@ def test_private_thread_detail_view_shows_user_unapproved_post_to_user( post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_unapproved=True, ) response = user_client.get( @@ -1895,7 +1895,7 @@ def test_private_thread_detail_view_shows_user_unapproved_post_to_moderator( post = thread_reply_factory( other_user_private_thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_unapproved=True, ) response = moderator_client.get( @@ -1943,7 +1943,7 @@ def test_private_thread_detail_view_shows_post_with_all_attachment_types( other_user_broken_image_thumbnail_attachment, other_user_broken_video_attachment, ): - post = thread_reply_factory(user_private_thread, original=get_random_string(12)) + post = thread_reply_factory(user_private_thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -2027,7 +2027,7 @@ def test_private_thread_detail_view_shows_post_with_all_attachment_types( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2110,7 +2110,7 @@ def test_private_thread_detail_view_shows_deleted_user_post_attachments_to_user( user_private_thread, text_attachment, ): - post = thread_reply_factory(user_private_thread, original=get_random_string(12)) + post = thread_reply_factory(user_private_thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -2125,7 +2125,7 @@ def test_private_thread_detail_view_shows_deleted_user_post_attachments_to_user( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2137,7 +2137,7 @@ def test_private_thread_detail_view_shows_deleted_user_post_attachments_to_moder user_private_thread, text_attachment, ): - post = thread_reply_factory(user_private_thread, original=get_random_string(12)) + post = thread_reply_factory(user_private_thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -2152,7 +2152,7 @@ def test_private_thread_detail_view_shows_deleted_user_post_attachments_to_moder ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2166,7 +2166,7 @@ def test_private_thread_detail_view_shows_user_post_attachments_to_user( text_attachment, ): post = thread_reply_factory( - user_private_thread, original=get_random_string(12), poster=user + user_private_thread, content=get_random_string(12), poster=user ) text_attachment.associate_with_post(post) @@ -2182,7 +2182,7 @@ def test_private_thread_detail_view_shows_user_post_attachments_to_user( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2196,7 +2196,7 @@ def test_private_thread_detail_view_shows_other_user_post_attachments_to_user( text_attachment, ): post = thread_reply_factory( - user_private_thread, original=get_random_string(12), poster=other_user + user_private_thread, content=get_random_string(12), poster=other_user ) text_attachment.associate_with_post(post) @@ -2212,7 +2212,7 @@ def test_private_thread_detail_view_shows_other_user_post_attachments_to_user( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2226,7 +2226,7 @@ def test_private_thread_detail_view_shows_user_post_attachments_to_moderator( text_attachment, ): post = thread_reply_factory( - user_private_thread, original=get_random_string(12), poster=user + user_private_thread, content=get_random_string(12), poster=user ) text_attachment.associate_with_post(post) @@ -2242,7 +2242,7 @@ def test_private_thread_detail_view_shows_user_post_attachments_to_moderator( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2255,7 +2255,7 @@ def test_private_thread_detail_view_doesnt_show_deleted_user_hidden_post_attachm text_attachment, ): post = thread_reply_factory( - user_private_thread, original=get_random_string(12), is_hidden=True + user_private_thread, content=get_random_string(12), is_hidden=True ) text_attachment.associate_with_post(post) @@ -2271,7 +2271,7 @@ def test_private_thread_detail_view_doesnt_show_deleted_user_hidden_post_attachm ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, text_attachment.name) assert_not_contains(response, text_attachment.get_absolute_url()) @@ -2284,7 +2284,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_attachments_t text_attachment, ): post = thread_reply_factory( - user_private_thread, original=get_random_string(12), is_hidden=True + user_private_thread, content=get_random_string(12), is_hidden=True ) text_attachment.associate_with_post(post) @@ -2300,7 +2300,7 @@ def test_private_thread_detail_view_shows_deleted_user_hidden_post_attachments_t ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2314,7 +2314,7 @@ def test_private_thread_detail_view_doesnt_show_user_hidden_post_attachments_to_ text_attachment, ): post = thread_reply_factory( - user_private_thread, original=get_random_string(12), poster=user, is_hidden=True + user_private_thread, content=get_random_string(12), poster=user, is_hidden=True ) text_attachment.associate_with_post(post) @@ -2330,7 +2330,7 @@ def test_private_thread_detail_view_doesnt_show_user_hidden_post_attachments_to_ ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, text_attachment.name) assert_not_contains(response, text_attachment.get_absolute_url()) @@ -2345,7 +2345,7 @@ def test_private_thread_detail_view_doesnt_show_other_user_hidden_post_attachmen ): post = thread_reply_factory( user_private_thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, ) @@ -2363,7 +2363,7 @@ def test_private_thread_detail_view_doesnt_show_other_user_hidden_post_attachmen ) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, text_attachment.name) assert_not_contains(response, text_attachment.get_absolute_url()) @@ -2377,7 +2377,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_attachments_to_modera text_attachment, ): post = thread_reply_factory( - user_private_thread, original=get_random_string(12), poster=user, is_hidden=True + user_private_thread, content=get_random_string(12), poster=user, is_hidden=True ) text_attachment.associate_with_post(post) @@ -2393,7 +2393,7 @@ def test_private_thread_detail_view_shows_user_hidden_post_attachments_to_modera ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2428,7 +2428,7 @@ def test_private_thread_detail_view_shows_post_with_all_attachment_types_embedde other_user_broken_image_thumbnail_attachment, other_user_broken_video_attachment, ): - post = thread_reply_factory(user_private_thread, original=get_random_string(12)) + post = thread_reply_factory(user_private_thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -2502,7 +2502,7 @@ def test_private_thread_detail_view_shows_post_with_all_attachment_types_embedde other_user_broken_video_attachment.associate_with_post(post) other_user_broken_video_attachment.save() - post.parsed += ( + post.content_parsed += ( "\n" f'' "\n" @@ -2592,7 +2592,7 @@ def test_private_thread_detail_view_shows_post_with_all_attachment_types_embedde ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -2703,7 +2703,7 @@ def test_private_thread_detail_view_shows_deleted_user_post_embedded_attachments ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -2742,7 +2742,7 @@ def test_private_thread_detail_view_shows_deleted_user_post_embedded_attachments ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -2784,7 +2784,7 @@ def test_private_thread_detail_view_shows_user_post_embedded_attachments_to_user ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -2826,7 +2826,7 @@ def test_private_thread_detail_view_shows_other_user_post_embedded_attachments_t ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -2868,7 +2868,7 @@ def test_private_thread_detail_view_shows_user_post_embedded_attachments_to_mode ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -2914,7 +2914,7 @@ def test_private_thread_detail_view_shows_post_embedded_attachments_from_other_p ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -2960,7 +2960,7 @@ def test_private_thread_detail_view_doesnt_show_post_embedded_attachments_from_h ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3016,7 +3016,7 @@ def test_private_thread_detail_view_shows_post_embedded_attachments_from_post_on ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3065,7 +3065,7 @@ def test_private_thread_detail_view_shows_post_embedded_attachments_from_other_t ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3113,7 +3113,7 @@ def test_private_thread_detail_view_doesnt_show_post_embedded_attachments_from_i ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3160,7 +3160,7 @@ def test_private_thread_detail_view_doesnt_show_post_embedded_attachments_from_i ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3224,7 +3224,7 @@ def test_private_thread_detail_view_shows_post_embedded_attachments_from_other_c ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3283,7 +3283,7 @@ def test_private_thread_detail_view_doesnt_show_post_embedded_attachments_from_o ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3331,7 +3331,7 @@ def test_private_thread_detail_view_shows_post_embedded_attachments_from_private ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3376,7 +3376,7 @@ def test_private_thread_detail_doesnt_show_post_embedded_attachments_from_inacce ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3415,7 +3415,7 @@ def test_private_thread_detail_view_doesnt_show_unassociated_embedded_attachment ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{previous_post.parsed}" + f"{previous_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [previous_post.id]} post.save() @@ -4374,7 +4374,7 @@ def test_private_thread_detail_view_shows_post_with_previous_post_quote( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{previous_post.parsed}" + f"{previous_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [previous_post.id]} post.save() @@ -4413,7 +4413,7 @@ def test_private_thread_detail_view_shows_post_with_hidden_previous_post_quote( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{previous_post.parsed}" + f"{previous_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [previous_post.id]} post.save() @@ -4458,7 +4458,7 @@ def test_private_thread_detail_view_shows_post_with_quote_of_deleted_user_post_f ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{previous_post.parsed}" + f"{previous_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [previous_post.id]} post.save() @@ -4503,7 +4503,7 @@ def test_private_thread_detail_view_shows_post_with_quote_of_user_post_from_othe ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{previous_post.parsed}" + f"{previous_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [previous_post.id]} post.save() @@ -4549,7 +4549,7 @@ def test_private_thread_detail_view_shows_post_with_quote_of_other_user_post_fro ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -4587,7 +4587,7 @@ def test_private_thread_detail_view_shows_post_with_other_thread_deleted_user_po ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -4627,7 +4627,7 @@ def test_private_thread_detail_view_shows_post_with_other_thread_user_post_quote ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -4668,7 +4668,7 @@ def test_private_thread_detail_view_shows_post_with_other_thread_other_user_post ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -4709,7 +4709,7 @@ def test_private_thread_detail_view_shows_post_with_inaccessible_thread_quote( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -4749,7 +4749,7 @@ def test_private_thread_detail_view_shows_post_with_inaccessible_thread_post_quo ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -4802,7 +4802,7 @@ def test_private_thread_detail_view_shows_post_with_other_category_post_quote( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -4843,7 +4843,7 @@ def test_private_thread_detail_view_shows_post_with_other_category_inaccessible_ ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -4883,7 +4883,7 @@ def test_private_thread_detail_view_shows_post_with_private_thread_post_quote( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -4921,7 +4921,7 @@ def test_private_thread_detail_view_shows_post_with_inaccessible_private_thread_ ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' "

Lorem ipsum

" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [post.id + 100]} post.save() @@ -4957,7 +4957,7 @@ def test_private_thread_detail_view_shows_post_with_deleted_post_quote( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, " - {% rich_text post.parsed rich_text_data thread=thread %} + {% rich_text post.content_parsed rich_text_data thread=thread %} {% if attachments %} {% include "misago/post_feed/post_attachments.html" %} diff --git a/misago/test/posts.py b/misago/test/posts.py index a5e9d763e9..7848ff244d 100644 --- a/misago/test/posts.py +++ b/misago/test/posts.py @@ -21,8 +21,8 @@ def _post_factory( thread: Thread, *, poster: FactoryUserArg = "Poster", - original: str | None = None, - parsed: str | None = None, + content: str | None = None, + content_parsed: str | None = None, metadata: dict | None = None, posted_at: FactoryTimestampArg = True, updated_at: FactoryTimestampArg = None, @@ -52,20 +52,20 @@ def _post_factory( hidden_by ) - if not original: - original = f"{get_random_string(4)} {get_random_string(4)}" - if not parsed: - parsed = f"

{original}

" + if not content: + content = f"{get_random_string(4)} {get_random_string(4)}" + if not content_parsed: + content_parsed = f"

{content}

" if not search_document: - search_document = original + search_document = content return Post.objects.create( category=thread.category, thread=thread, poster=poster_obj, poster_name=poster_name, - original=original, - parsed=parsed, + content=content, + content_parsed=content_parsed, metadata=metadata or {}, posted_at=factory_timestamp_arg(posted_at), updated_at=factory_timestamp_arg(updated_at), @@ -100,8 +100,8 @@ def _thread_reply_factory( thread: Thread, *, poster: FactoryUserArg = "Poster", - original: str = "Hello world!", - parsed: str | None = None, + content: str = "Hello world!", + content_parsed: str | None = None, metadata: dict | None = None, posted_at: FactoryTimestampArg = True, updated_at: FactoryTimestampArg = None, @@ -121,14 +121,14 @@ def _thread_reply_factory( search_document: str | None = None, commit: bool = True, ): - if not parsed: - parsed = f"

{html.escape(original)}

" + if not content_parsed: + content_parsed = f"

{html.escape(content)}

" post = post_factory( thread, poster=poster, - original=original, - parsed=parsed, + content=content, + content_parsed=content_parsed, metadata=metadata, posted_at=posted_at, updated_at=updated_at, diff --git a/misago/threadevents/migrations/0001_threadevent.py b/misago/threadevents/migrations/0001_threadevent.py index ccc1128921..a7d180e481 100644 --- a/misago/threadevents/migrations/0001_threadevent.py +++ b/misago/threadevents/migrations/0001_threadevent.py @@ -10,7 +10,7 @@ class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ("misago_categories", "0013_new_behaviors"), - ("misago_threads", "0018_update_attachments_markup"), + ("misago_threads", "0018_post_content_parsed"), ] operations = [ diff --git a/misago/threads/checksums.py b/misago/threads/checksums.py index 49e99b0c17..268248b130 100644 --- a/misago/threads/checksums.py +++ b/misago/threads/checksums.py @@ -8,7 +8,7 @@ def is_post_valid(post): def make_post_checksum(post): post_seeds = [str(v) for v in (post.id, str(post.posted_at.date()))] - return checksums.make_checksum(post.parsed, post_seeds) + return checksums.make_checksum(post.content_parsed, post_seeds) def update_post_checksum(post): diff --git a/misago/threads/management/commands/parseposts.py b/misago/threads/management/commands/parseposts.py index 04eb159dfd..bd213f4ee2 100644 --- a/misago/threads/management/commands/parseposts.py +++ b/misago/threads/management/commands/parseposts.py @@ -27,14 +27,19 @@ def handle(self, *args, **options): queryset = Post.objects.select_related("thread") for post in queryset.iterator(chunk_size=50): - parsing_result = parse(post.original) + parsing_result = parse(post.content) - post.original = parsing_result.markup - post.parsed = parsing_result.html + post.content = parsing_result.markup + post.content_parsed = parsing_result.html post.metadata = parsing_result.metadata post.set_search_document(post.thread, parsing_result.text) post.save( - update_fields=["original", "parsed", "metadata", "search_document"] + update_fields=[ + "content", + "content_parsed", + "metadata", + "search_document", + ] ) post.set_search_vector() diff --git a/misago/threads/management/commands/rebuildpostssearch.py b/misago/threads/management/commands/rebuildpostssearch.py index e9a7edfe0b..35fa9674f0 100644 --- a/misago/threads/management/commands/rebuildpostssearch.py +++ b/misago/threads/management/commands/rebuildpostssearch.py @@ -27,7 +27,7 @@ def handle(self, *args, **options): queryset = Post.objects.select_related("thread") for post in queryset.iterator(chunk_size=50): - parsing_result = parse(post.original) + parsing_result = parse(post.content) if post.id == post.thread.first_post_id: post.search_document = f"{post.thread.title} {parsing_result.text}" diff --git a/misago/threads/merge.py b/misago/threads/merge.py index 7d11e6c654..816a1af1c1 100644 --- a/misago/threads/merge.py +++ b/misago/threads/merge.py @@ -263,12 +263,12 @@ def _merge_posts_action( for post in posts: if post.id > target.id: - target.original += f"\n\n{post.original}" - target.parsed += f"\n{post.parsed}" + target.content += f"\n\n{post.content}" + target.content_parsed += f"\n{post.content_parsed}" target.search_document += f"\n\n{post.search_document}" else: - target.original = f"{post.original}\n\n{target.original}" - target.parsed = f"{post.parsed}\n{target.parsed}" + target.content = f"{post.content}\n\n{target.content}" + target.content_parsed = f"{post.content_parsed}\n{target.content_parsed}" target.search_document = ( f"{post.search_document}\n\n{target.search_document}" ) diff --git a/misago/threads/migrations/0018_post_content_parsed.py b/misago/threads/migrations/0018_post_content_parsed.py new file mode 100644 index 0000000000..05cd5b703b --- /dev/null +++ b/misago/threads/migrations/0018_post_content_parsed.py @@ -0,0 +1,23 @@ +# Generated by Django 5.2.15 on 2026-08-09 02:44 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("misago_attachments", "0005_attachment_clean_names_populate_slugs"), + ("misago_threads", "0017_delete_subscription"), + ] + + operations = [ + migrations.RenameField( + model_name="post", + old_name="original", + new_name="content", + ), + migrations.RenameField( + model_name="post", + old_name="parsed", + new_name="content_parsed", + ), + ] diff --git a/misago/threads/migrations/0018_update_attachments_markup.py b/misago/threads/migrations/0018_update_attachments_markup.py deleted file mode 100644 index 821050981d..0000000000 --- a/misago/threads/migrations/0018_update_attachments_markup.py +++ /dev/null @@ -1,443 +0,0 @@ -# Generated by Django 4.2.10 on 2025-01-17 21:58 -import re -from typing import Optional - -from django.conf import settings -from django.db import migrations -from django.db.models import Q - - -def update_posts_attachments_markup(apps, _): - Attachment = apps.get_model("misago_attachments", "Attachment") - Post = apps.get_model("misago_threads", "Post") - - queryset = Post.objects.filter( - Q(original__contains="/a/") | Q(original__contains="/attachments/") - ).order_by("-id") - - for post in queryset.iterator(chunk_size=20): - update_post_attachments_markup(Attachment, post) - - -def update_post_attachments_markup(attachment_type, post): - original = parse(attachment_type, post.original) - if original == post.original: - return False - - post.original = original - post.save(update_fields=["original"]) - - return True - - -def parse( - attachment_type, - source: str, - from_state: Optional["ParsingState"] = None, -) -> str: - state = ParsingState(attachment_type, source) - - if from_state: - state.attachments_ids = from_state.attachments_ids - state.attachments_paths = from_state.attachments_paths - - while state.pos < state.maximum: - for rule in RULES: - if rule(state): - break - - return state.result - - -class ParsingState: - source: str - maximum: str - pos: str - result: str - - def __init__(self, attachment_type, source: str): - self.attachment_type = attachment_type - self.attachments_ids: dict = {} - self.attachments_paths: dict = {} - - self.source = source - self.maximum = len(source) - self.pos = 0 - - self.result = "" - - def get_attachment(self, *, id: int | None = None, path: str | None = None): - if id and path: - raise ValueError("'id' and 'path' options can't be used together") - - if id: - if id not in self.attachments_ids: - attachment = self.attachment_type.objects.filter(id=id).first() - self.attachments_ids[id] = attachment - return self.attachments_ids[id] - - if path: - if path not in self.attachments_paths: - attachment = self.attachment_type.objects.filter( - Q(upload=path) | Q(thumbnail=path) - ).first() - self.attachments_paths[path] = attachment - return self.attachments_paths[path] - - return None - - def push_attachment(self, attachment): - self.result += f"" - - -def update_image(state: ParsingState) -> bool: - pos = state.pos - if state.source[pos : pos + 2] != "![": - return False - - label = find_delimiters(state, pos + 1, "[]") - if not label: - return False - - url = find_delimiters(state, label[1], "()") - if not url: - return False - - end = url[1] - - attachment = parse_attachment_url(state, state.source[url[0] + 1 : url[1] - 1]) - if not attachment: - return None - - state.push_attachment(attachment) - state.pos = end - - return True - - -def update_short_image(state: ParsingState) -> bool: - pos = state.pos - if state.source[pos : pos + 2] != "!(": - return False - - url = find_delimiters(state, pos + 1, "()") - if not url: - return False - - end = url[1] - - attachment = parse_attachment_url(state, state.source[url[0] + 1 : url[1] - 1]) - if not attachment: - return None - - state.push_attachment(attachment) - state.pos = end - - return True - - -def update_image_bbcode(state: ParsingState) -> bool: - pos = state.pos - if state.source[pos : pos + 5].lower() != "[img]": - return False - - url = find_delimiters(state, pos, ("[img]", "[/img]")) - if not url: - return False - - end = url[1] - - attachment = parse_attachment_url(state, state.source[url[0] + 5 : url[1] - 6]) - if not attachment: - return None - - state.push_attachment(attachment) - state.pos = end - - return True - - -def update_autolink(state: ParsingState) -> bool: - pos = state.pos - if state.source[pos] != "<": - return False - - url = find_delimiters(state, pos, "<>") - if not url: - return False - - end = url[1] - - attachment = parse_attachment_url(state, state.source[url[0] + 1 : url[1] - 1]) - if not attachment: - return None - - state.push_attachment(attachment) - state.pos = end - - return True - - -def update_link(state: ParsingState) -> bool: - pos = state.pos - if state.source[pos] != "[": - return False - - label = find_delimiters(state, pos, "[]") - if not label: - return False - - label_markup = parse( - state.attachment_type, state.source[label[0] + 1 : label[1] - 1], state - ) - label_attachments = search_attachments(label_markup) - - url = find_delimiters(state, label[1], "()") - if not url: - return False - - end = url[1] - url_attachment = parse_attachment_url(state, state.source[url[0] + 1 : url[1] - 1]) - - if label_attachments and url_attachment: - state.result += label_markup - if url_attachment.id not in label_attachments: - state.result += " " - state.push_attachment(url_attachment) - - elif label_attachments: - state.result += label_markup - state.result += f" <{state.source[url[0] + 1 : url[1] - 1]}>" - - elif url_attachment: - state.result += f"{label_markup} " - state.push_attachment(url_attachment) - - else: - return False - - state.pos = end - return True - - -def update_url_bbcode(state: ParsingState) -> bool: - pos = state.pos - if state.source[pos : pos + 4].lower() != "[url": - return False - - opening = find_delimiters(state, pos, "[]") - if not opening: - return False - - args = state.source[state.pos + 4 : opening[1] - 1] - if args and args[0] == "=": - args = args[1:] - - args = args or None - - pos = opening[1] - maximum = state.maximum - while pos < maximum: - if pos == "\\": - pos += 2 - elif state.source[pos : pos + 6].lower() == "[/url]": - break - else: - pos += 1 - else: - return False - - content = state.source[opening[1] : pos] or None - if not content: - return False - - if args and content: - content_markup = parse(state.attachment_type, content, state) - content_attachments = search_attachments(content_markup) - arg_attachment = parse_attachment_url(state, args) - if arg_attachment and content_attachments: - state.result += content_markup - if arg_attachment.id not in content_attachments: - state.result += " " - state.push_attachment(arg_attachment) - elif arg_attachment: - state.result += f"{content} " - state.push_attachment(arg_attachment) - elif content_attachments: - state.result += f"<{args}> {content_markup}" - else: - return False - - elif content: - if content_attachment := parse_attachment_url(state, content): - state.push_attachment(content_attachment) - else: - return False - - else: - return False - - state.pos = pos + 6 - return True - - -def find_delimiters( - state: ParsingState, start: int, delimiters: str | tuple[str, str] -) -> tuple[int, int] | None: - source = state.source.lower() - - start_delimiter = delimiters[0] - start_delimiter_len = len(start_delimiter) - end_delimiter = delimiters[1] - end_delimiter_len = len(end_delimiter) - - result = [0, 0] - - pos = start - level = 0 - while pos < state.maximum: - if source[pos] == "\\": - pos += 2 - - elif source[pos : pos + start_delimiter_len] == start_delimiter: - if level == 0: - result[0] = pos - - level += 1 - pos += 1 - elif source[pos : pos + end_delimiter_len] == end_delimiter: - level -= 1 - if level == 0: - result[1] = pos + end_delimiter_len - return tuple(result) - - pos += 1 - - else: - pos += 1 - - else: - return None - - -def escape_character(state: ParsingState) -> bool: - if state.source[state.pos] != "\\": - return False - - state.result += state.source[state.pos : state.pos + 2] - state.pos += 2 - return True - - -def store_character(state: ParsingState) -> bool: - state.result += state.source[state.pos] - state.pos += 1 - return True - - -RULES = ( - update_image, - update_short_image, - update_image_bbcode, - update_autolink, - update_url_bbcode, - update_link, - escape_character, - store_character, -) - - -def parse_attachment_url(state: ParsingState, attachment_url: str): - clean_url = attachment_url.strip() - if not clean_url: - return None - - if f"{settings.MEDIA_URL}attachments/" in clean_url: - return parse_attachment_media_url(state, clean_url) - - if "/a/" not in clean_url: - return None - - clean_url = clean_url[clean_url.index("/a/") + 3 :] - if clean_url.startswith("thumb/"): - clean_url = clean_url[6:] - - if "/" in clean_url: - clean_url = clean_url[clean_url.index("/") + 1 :] - if "/" in clean_url: - clean_url = clean_url[: clean_url.index("/")] - - try: - attachment_id = int(clean_url) - except (ValueError, TypeError): - return None - - return state.get_attachment(id=attachment_id) - - -def parse_attachment_media_url(state: ParsingState, attachment_url: str): - attachments_media_url = f"{settings.MEDIA_URL}attachments/" - - file_path = attachment_url[ - attachment_url.index(attachments_media_url) + len(settings.MEDIA_URL) : - ] - - if " " in file_path: - file_path = file_path.split(" ", 1)[0] - if not file_path: - return None - - return state.get_attachment(path=file_path) - - -ATTACHMENT_ARGS_RE = re.compile( - r"([a-z0-9]|-|_|\.| )+? *: *(?P([1-9][0-9]*))", re.IGNORECASE -) - - -def search_attachments(source: str) -> list[int]: - results = [] - - pos = 0 - maximum = len(source) - while pos < maximum: - if source[pos] == "\\": - pos += 2 - - elif source[pos : pos + 12].lower() == "": - args_str = source[start + 12 : pos].strip() - if args_match := ATTACHMENT_ARGS_RE.match(args_str): - try: - attachment_id = int(args_match.group("id")) - results.append(attachment_id) - except (ValueError, TypeError): - pass - pos += 1 - else: - pos += 1 - else: - pos += 1 - - return results - - -class Migration(migrations.Migration): - atomic = False - - dependencies = [ - ("misago_attachments", "0005_attachment_clean_names_populate_slugs"), - ("misago_threads", "0017_delete_subscription"), - ] - - operations = [ - migrations.RunPython( - update_posts_attachments_markup, - migrations.RunPython.noop, - ), - ] diff --git a/misago/threads/migrations/0019_delete_legacy_events.py b/misago/threads/migrations/0019_delete_legacy_events.py index ccac7cdec2..402d46ac20 100644 --- a/misago/threads/migrations/0019_delete_legacy_events.py +++ b/misago/threads/migrations/0019_delete_legacy_events.py @@ -12,7 +12,7 @@ class Migration(migrations.Migration): atomic = False dependencies = [ - ("misago_threads", "0018_update_attachments_markup"), + ("misago_threads", "0018_post_content_parsed"), ("misago_threadevents", "0002_move_data"), ] diff --git a/misago/threads/models/post.py b/misago/threads/models/post.py index 4ea69854e8..2bf472830b 100644 --- a/misago/threads/models/post.py +++ b/misago/threads/models/post.py @@ -10,7 +10,6 @@ from ...conf import settings from ...core.utils import parse_iso8601_string -from ...markup import finalize_markup from ...plugins.models import PluginDataModel from ..checksums import is_post_valid, update_post_checksum @@ -28,8 +27,9 @@ class Post(PluginDataModel): on_delete=models.SET_NULL, ) poster_name = models.CharField(max_length=255) - original = models.TextField() - parsed = models.TextField() + + content = models.TextField() + content_parsed = models.TextField() checksum = models.CharField(max_length=64, default="-") metadata = models.JSONField(default=dict) @@ -133,8 +133,10 @@ def merge(self, other_post): if self.pk == other_post.pk: raise ValueError("post can't be merged with itself") - other_post.original = str("\n\n").join((other_post.original, self.original)) - other_post.parsed = str("\n").join((other_post.parsed, self.parsed)) + other_post.content = str("\n\n").join((other_post.content, self.content)) + other_post.content_parsed = str("\n").join( + (other_post.content_parsed, self.content_parsed) + ) update_post_checksum(other_post) if self.is_locked: @@ -172,15 +174,9 @@ def attachments(self): @property def sha256_checksum(self) -> str: return hashlib.sha256( - f"{self.id}:{self.updated_at or 0}:{self.parsed}".encode() + f"{self.id}:{self.updated_at or 0}:{self.content_parsed}".encode() ).hexdigest() - @property - def content(self): - if not hasattr(self, "_finalised_parsed"): - self._finalised_parsed = finalize_markup(self.parsed) - return self._finalised_parsed - @property def thread_type(self): return self.category.thread_type diff --git a/misago/threads/signals.py b/misago/threads/signals.py index 0d6e35db4b..2e0461f12a 100644 --- a/misago/threads/signals.py +++ b/misago/threads/signals.py @@ -139,7 +139,7 @@ def archive_user_attachments(sender, archive=None, **kwargs): def archive_user_posts(sender, archive=None, **kwargs): for post in sender.post_set.order_by("id").iterator(chunk_size=50): item_name = post.posted_at.strftime("%H%M%S-post") - archive.add_text(item_name, post.parsed, date=post.posted_at) + archive.add_text(item_name, post.content_parsed, date=post.posted_at) @receiver(archive_user_data) diff --git a/misago/threads/tests/test_merge_posts.py b/misago/threads/tests/test_merge_posts.py index b3e3cacee8..349a2d91ed 100644 --- a/misago/threads/tests/test_merge_posts.py +++ b/misago/threads/tests/test_merge_posts.py @@ -16,14 +16,14 @@ def posts(thread_reply_factory, thread): target = thread_reply_factory( thread, - original="Lorem ipsum", - parsed="

Lorem ipsum

", + content="Lorem ipsum", + content_parsed="

Lorem ipsum

", search_document="Lorem", ) other_post = thread_reply_factory( thread, - original="Dolor met", - parsed="

Dolor met

", + content="Dolor met", + content_parsed="

Dolor met

", search_document="Dolor", ) @@ -53,8 +53,8 @@ def test_get_post_merge_form_fields_returns_dict(): def test_get_merge_posts_merges_posts_contents(user, target, other_post): merge_posts(target, [other_post], {}, user) - assert target.original == "Lorem ipsum\n\nDolor met" - assert target.parsed == "

Lorem ipsum

\n

Dolor met

" + assert target.content == "Lorem ipsum\n\nDolor met" + assert target.content_parsed == "

Lorem ipsum

\n

Dolor met

" assert target.search_document == "Lorem\n\nDolor" @@ -63,8 +63,8 @@ def test_get_merge_posts_merges_posts_contents_chronologically( ): merge_posts(other_post, [target], {}, user) - assert other_post.original == "Lorem ipsum\n\nDolor met" - assert other_post.parsed == "

Lorem ipsum

\n

Dolor met

" + assert other_post.content == "Lorem ipsum\n\nDolor met" + assert other_post.content_parsed == "

Lorem ipsum

\n

Dolor met

" assert other_post.search_document == "Lorem\n\nDolor" diff --git a/misago/threads/tests/test_parseposts.py b/misago/threads/tests/test_parseposts.py index 40ea54910a..a49f6ad775 100644 --- a/misago/threads/tests/test_parseposts.py +++ b/misago/threads/tests/test_parseposts.py @@ -22,7 +22,7 @@ def test_parseposts_command_does_nothing_if_there_are_no_posts(db): def test_parseposts_command_reparses_existing_posts(post): - post.original = "Hello **world**!" + post.content = "Hello **world**!" post.metadata = {"outdated": True} post.save() @@ -31,5 +31,5 @@ def test_parseposts_command_reparses_existing_posts(post): assert command_output[-1] == "Parsed one post." post.refresh_from_db() - assert post.parsed == "

Hello world!

" + assert post.content_parsed == "

Hello world!

" assert post.metadata == {} diff --git a/misago/threads/tests/test_rebuildpostssearch.py b/misago/threads/tests/test_rebuildpostssearch.py index 2bd8b32202..4be1155d87 100644 --- a/misago/threads/tests/test_rebuildpostssearch.py +++ b/misago/threads/tests/test_rebuildpostssearch.py @@ -24,7 +24,7 @@ def test_rebuildpostssearch_command_does_nothing_if_there_are_no_posts(db): def test_rebuildpostssearch_command_updates_existing_posts_search_documents( thread, post ): - post.original = "Hello **world**!" + post.content = "Hello **world**!" post.save() command_output = call_command() diff --git a/misago/threads/tests/test_thread_detail_view_moderation_actions.py b/misago/threads/tests/test_thread_detail_view_moderation_actions.py index 5fe8e7365c..d68f650458 100644 --- a/misago/threads/tests/test_thread_detail_view_moderation_actions.py +++ b/misago/threads/tests/test_thread_detail_view_moderation_actions.py @@ -2793,8 +2793,8 @@ def test_thread_detail_view_merge_posts_moderation_action_merges_posts( thread, mock_posts_synchronize_categories, ): - target_post = thread_reply_factory(thread, poster=user, original="Target body") - other_post = thread_reply_factory(thread, poster=user, original="Other body") + target_post = thread_reply_factory(thread, poster=user, content="Target body") + other_post = thread_reply_factory(thread, poster=user, content="Other body") response = moderator_client.post( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}), @@ -2821,7 +2821,7 @@ def test_thread_detail_view_merge_posts_moderation_action_merges_posts( ) target_post.refresh_from_db() - assert target_post.original == "Target body\n\nOther body" + assert target_post.content == "Target body\n\nOther body" assert not target_post.last_edit_reason post_edit = PostEdit.objects.get(post=target_post) @@ -2845,8 +2845,8 @@ def test_thread_detail_view_merge_posts_moderation_action_merges_posts_in_htmx( thread, mock_posts_synchronize_categories, ): - target_post = thread_reply_factory(thread, poster=user, original="Target body") - other_post = thread_reply_factory(thread, poster=user, original="Other body") + target_post = thread_reply_factory(thread, poster=user, content="Target body") + other_post = thread_reply_factory(thread, poster=user, content="Other body") response = moderator_client.post( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}), @@ -2867,7 +2867,7 @@ def test_thread_detail_view_merge_posts_moderation_action_merges_posts_in_htmx( assert response.status_code == 200 target_post.refresh_from_db() - assert target_post.original == "Target body\n\nOther body" + assert target_post.content == "Target body\n\nOther body" assert not target_post.last_edit_reason post_edit = PostEdit.objects.get(post=target_post) @@ -2891,8 +2891,8 @@ def test_thread_detail_view_merge_posts_moderation_action_merges_posts_with_merg thread, mock_posts_synchronize_categories, ): - target_post = thread_reply_factory(thread, poster=user, original="Target body") - other_post = thread_reply_factory(thread, poster=user, original="Other body") + target_post = thread_reply_factory(thread, poster=user, content="Target body") + other_post = thread_reply_factory(thread, poster=user, content="Other body") response = moderator_client.post( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}), @@ -2920,7 +2920,7 @@ def test_thread_detail_view_merge_posts_moderation_action_merges_posts_with_merg ) target_post.refresh_from_db() - assert target_post.original == "Target body\n\nOther body" + assert target_post.content == "Target body\n\nOther body" assert target_post.last_edit_reason == "Test merge" post_edit = PostEdit.objects.get(post=target_post) @@ -2944,8 +2944,8 @@ def test_thread_detail_view_merge_posts_moderation_action_merges_other_post_into thread, mock_posts_synchronize_categories, ): - target_post = thread_reply_factory(thread, poster=user, original="Target body") - other_post = thread_reply_factory(thread, poster=user, original="Other body") + target_post = thread_reply_factory(thread, poster=user, content="Target body") + other_post = thread_reply_factory(thread, poster=user, content="Other body") select_thread_solution(thread, target_post, moderator) @@ -2977,7 +2977,7 @@ def test_thread_detail_view_merge_posts_moderation_action_merges_other_post_into assert thread.solution == target_post target_post.refresh_from_db() - assert target_post.original == "Target body\n\nOther body" + assert target_post.content == "Target body\n\nOther body" assert not target_post.last_edit_reason post_edit = PostEdit.objects.get(post=target_post) @@ -3001,8 +3001,8 @@ def test_thread_detail_view_merge_posts_moderation_action_merges_solution_into_t thread, mock_posts_synchronize_categories, ): - target_post = thread_reply_factory(thread, poster=user, original="Target body") - other_post = thread_reply_factory(thread, poster=user, original="Other body") + target_post = thread_reply_factory(thread, poster=user, content="Target body") + other_post = thread_reply_factory(thread, poster=user, content="Other body") select_thread_solution(thread, other_post, moderator) @@ -3034,7 +3034,7 @@ def test_thread_detail_view_merge_posts_moderation_action_merges_solution_into_t assert thread.solution == target_post target_post.refresh_from_db() - assert target_post.original == "Target body\n\nOther body" + assert target_post.content == "Target body\n\nOther body" assert not target_post.last_edit_reason post_edit = PostEdit.objects.get(post=target_post) @@ -3060,8 +3060,8 @@ def test_thread_detail_view_merge_posts_moderation_action_merges_posts_with_atta image_attachment, mock_posts_synchronize_categories, ): - target_post = thread_reply_factory(thread, poster=user, original="Target body") - other_post = thread_reply_factory(thread, poster=user, original="Other body") + target_post = thread_reply_factory(thread, poster=user, content="Target body") + other_post = thread_reply_factory(thread, poster=user, content="Other body") text_attachment.associate_with_post(target_post) text_attachment.save() @@ -3094,7 +3094,7 @@ def test_thread_detail_view_merge_posts_moderation_action_merges_posts_with_atta ) target_post.refresh_from_db() - assert target_post.original == "Target body\n\nOther body" + assert target_post.content == "Target body\n\nOther body" assert not target_post.last_edit_reason text_attachment.refresh_from_db() @@ -3128,8 +3128,8 @@ def test_thread_detail_view_merge_posts_moderation_action_orders_posts_from_olde thread, mock_posts_synchronize_categories, ): - target_post = thread_reply_factory(thread, poster=user, original="Target body") - other_post = thread_reply_factory(thread, poster=user, original="Other body") + target_post = thread_reply_factory(thread, poster=user, content="Target body") + other_post = thread_reply_factory(thread, poster=user, content="Other body") response = moderator_client.post( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}), @@ -3156,7 +3156,7 @@ def test_thread_detail_view_merge_posts_moderation_action_orders_posts_from_olde ) target_post.refresh_from_db() - assert target_post.original == "Target body\n\nOther body" + assert target_post.content == "Target body\n\nOther body" assert not target_post.last_edit_reason post_edit = PostEdit.objects.get(post=target_post) @@ -3178,7 +3178,7 @@ def test_thread_detail_view_merge_posts_moderation_action_validates_multiple_pos thread, mock_posts_synchronize_categories, ): - target_post = thread_reply_factory(thread, poster=user, original="Target body") + target_post = thread_reply_factory(thread, poster=user, content="Target body") response = moderator_client.post( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}), @@ -3187,7 +3187,7 @@ def test_thread_detail_view_merge_posts_moderation_action_validates_multiple_pos assert_contains(response, "Select at least two posts to merge.") target_post.refresh_from_db() - assert target_post.original == "Target body" + assert target_post.content == "Target body" assert not PostEdit.objects.exists() @@ -3202,8 +3202,8 @@ def test_thread_detail_view_merge_posts_moderation_action_validates_posts_are_by thread, mock_posts_synchronize_categories, ): - target_post = thread_reply_factory(thread, poster=user, original="Target body") - other_post = thread_reply_factory(thread, poster=other_user, original="Other body") + target_post = thread_reply_factory(thread, poster=user, content="Target body") + other_post = thread_reply_factory(thread, poster=other_user, content="Other body") response = moderator_client.post( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}), @@ -3212,10 +3212,10 @@ def test_thread_detail_view_merge_posts_moderation_action_validates_posts_are_by assert_contains(response, "Merged posts must belong to the same user.") target_post.refresh_from_db() - assert target_post.original == "Target body" + assert target_post.content == "Target body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" assert not PostEdit.objects.exists() @@ -3225,8 +3225,8 @@ def test_thread_detail_view_merge_posts_moderation_action_validates_posts_are_by def test_thread_detail_view_merge_posts_moderation_action_validates_posts_are_by_same_deleted_user( thread_reply_factory, moderator_client, thread, mock_posts_synchronize_categories ): - target_post = thread_reply_factory(thread, poster="John", original="Target body") - other_post = thread_reply_factory(thread, poster="Alice", original="Other body") + target_post = thread_reply_factory(thread, poster="John", content="Target body") + other_post = thread_reply_factory(thread, poster="Alice", content="Other body") response = moderator_client.post( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}), @@ -3235,10 +3235,10 @@ def test_thread_detail_view_merge_posts_moderation_action_validates_posts_are_by assert_contains(response, "Merged posts must belong to the same user.") target_post.refresh_from_db() - assert target_post.original == "Target body" + assert target_post.content == "Target body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" assert not PostEdit.objects.exists() @@ -4422,9 +4422,9 @@ def test_thread_detail_view_merge_post_moderation_action_merges_other_post_into_ mock_post_synchronize_categories, ): current_post = user_thread.first_post - other_post = thread_reply_factory(user_thread, poster=user, original="Other body") + other_post = thread_reply_factory(user_thread, poster=user, content="Other body") - current_post_content = current_post.original + current_post_content = current_post.content response = moderator_client.post( reverse( @@ -4469,7 +4469,7 @@ def test_thread_detail_view_merge_post_moderation_action_merges_other_post_into_ ) current_post.refresh_from_db() - assert current_post.original == f"{current_post_content}\n\nOther body" + assert current_post.content == f"{current_post_content}\n\nOther body" assert not current_post.last_edit_reason post_edit = PostEdit.objects.get(post=current_post) @@ -4494,9 +4494,9 @@ def test_thread_detail_view_merge_post_moderation_action_merges_other_post_into_ mock_post_synchronize_categories, ): current_post = user_thread.first_post - other_post = thread_reply_factory(user_thread, poster=user, original="Other body") + other_post = thread_reply_factory(user_thread, poster=user, content="Other body") - current_post_content = current_post.original + current_post_content = current_post.content response = moderator_client.post( reverse( @@ -4535,7 +4535,7 @@ def test_thread_detail_view_merge_post_moderation_action_merges_other_post_into_ assert response["hx-refresh"] == "true" current_post.refresh_from_db() - assert current_post.original == f"{current_post_content}\n\nOther body" + assert current_post.content == f"{current_post_content}\n\nOther body" assert not current_post.last_edit_reason post_edit = PostEdit.objects.get(post=current_post) @@ -4560,9 +4560,9 @@ def test_thread_detail_view_merge_post_moderation_action_merges_current_post_int mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - other_post = thread_reply_factory(user_thread, poster=user, original="Other body") + other_post = thread_reply_factory(user_thread, poster=user, content="Other body") response = moderator_client.post( reverse( @@ -4608,7 +4608,7 @@ def test_thread_detail_view_merge_post_moderation_action_merges_current_post_int ) other_post.refresh_from_db() - assert other_post.original == "Current body\n\nOther body" + assert other_post.content == "Current body\n\nOther body" assert not other_post.last_edit_reason post_edit = PostEdit.objects.get(post=other_post) @@ -4633,9 +4633,9 @@ def test_thread_detail_view_merge_post_moderation_action_merges_current_post_int mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - other_post = thread_reply_factory(user_thread, poster=user, original="Other body") + other_post = thread_reply_factory(user_thread, poster=user, content="Other body") response = moderator_client.post( reverse( @@ -4675,7 +4675,7 @@ def test_thread_detail_view_merge_post_moderation_action_merges_current_post_int assert response["hx-refresh"] == "true" other_post.refresh_from_db() - assert other_post.original == "Current body\n\nOther body" + assert other_post.content == "Current body\n\nOther body" assert not other_post.last_edit_reason post_edit = PostEdit.objects.get(post=other_post) @@ -4700,9 +4700,9 @@ def test_thread_detail_view_merge_post_moderation_action_merges_other_post_into_ mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - other_post = thread_reply_factory(user_thread, poster=user, original="Other body") + other_post = thread_reply_factory(user_thread, poster=user, content="Other body") response = moderator_client.post( reverse( @@ -4748,7 +4748,7 @@ def test_thread_detail_view_merge_post_moderation_action_merges_other_post_into_ ) current_post.refresh_from_db() - assert current_post.original == "Current body\n\nOther body" + assert current_post.content == "Current body\n\nOther body" assert not current_post.last_edit_reason post_edit = PostEdit.objects.get(post=current_post) @@ -4773,9 +4773,9 @@ def test_thread_detail_view_merge_post_moderation_action_merges_other_post_into_ mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - other_post = thread_reply_factory(user_thread, poster=user, original="Other body") + other_post = thread_reply_factory(user_thread, poster=user, content="Other body") response = moderator_client.post( reverse( @@ -4815,7 +4815,7 @@ def test_thread_detail_view_merge_post_moderation_action_merges_other_post_into_ assert response["hx-refresh"] == "true" current_post.refresh_from_db() - assert current_post.original == "Current body\n\nOther body" + assert current_post.content == "Current body\n\nOther body" assert not current_post.last_edit_reason post_edit = PostEdit.objects.get(post=current_post) @@ -4840,9 +4840,9 @@ def test_thread_detail_view_merge_post_moderation_action_merges_posts_with_merge mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - other_post = thread_reply_factory(user_thread, poster=user, original="Other body") + other_post = thread_reply_factory(user_thread, poster=user, content="Other body") response = moderator_client.post( reverse( @@ -4889,7 +4889,7 @@ def test_thread_detail_view_merge_post_moderation_action_merges_posts_with_merge ) current_post.refresh_from_db() - assert current_post.original == "Current body\n\nOther body" + assert current_post.content == "Current body\n\nOther body" assert current_post.last_edit_reason == "Test merge" post_edit = PostEdit.objects.get(post=current_post) @@ -4914,9 +4914,9 @@ def test_thread_detail_view_merge_post_moderation_action_merges_other_post_into_ mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - other_post = thread_reply_factory(user_thread, poster=user, original="Other body") + other_post = thread_reply_factory(user_thread, poster=user, content="Other body") select_thread_solution(user_thread, current_post, moderator) @@ -4967,7 +4967,7 @@ def test_thread_detail_view_merge_post_moderation_action_merges_other_post_into_ assert user_thread.solution == current_post current_post.refresh_from_db() - assert current_post.original == "Current body\n\nOther body" + assert current_post.content == "Current body\n\nOther body" assert not current_post.last_edit_reason post_edit = PostEdit.objects.get(post=current_post) @@ -4992,9 +4992,9 @@ def test_thread_detail_view_merge_post_moderation_action_merges_solution_into_cu mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - other_post = thread_reply_factory(user_thread, poster=user, original="Other body") + other_post = thread_reply_factory(user_thread, poster=user, content="Other body") select_thread_solution(user_thread, other_post, moderator) @@ -5045,7 +5045,7 @@ def test_thread_detail_view_merge_post_moderation_action_merges_solution_into_cu assert user_thread.solution == current_post current_post.refresh_from_db() - assert current_post.original == "Current body\n\nOther body" + assert current_post.content == "Current body\n\nOther body" assert not current_post.last_edit_reason post_edit = PostEdit.objects.get(post=current_post) @@ -5072,9 +5072,9 @@ def test_thread_detail_view_merge_post_moderation_action_merges_posts_with_attac mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - other_post = thread_reply_factory(user_thread, poster=user, original="Other body") + other_post = thread_reply_factory(user_thread, poster=user, content="Other body") text_attachment.associate_with_post(current_post) text_attachment.save() @@ -5126,7 +5126,7 @@ def test_thread_detail_view_merge_post_moderation_action_merges_posts_with_attac ) current_post.refresh_from_db() - assert current_post.original == "Current body\n\nOther body" + assert current_post.content == "Current body\n\nOther body" assert not current_post.last_edit_reason text_attachment.refresh_from_db() @@ -5161,9 +5161,9 @@ def test_thread_detail_view_merge_post_moderation_action_merges_posts_using_glob mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - other_post = thread_reply_factory(user_thread, poster=user, original="Other body") + other_post = thread_reply_factory(user_thread, poster=user, content="Other body") response = moderator_client.post( reverse( @@ -5202,7 +5202,7 @@ def test_thread_detail_view_merge_post_moderation_action_merges_posts_using_glob ) current_post.refresh_from_db() - assert current_post.original == "Current body\n\nOther body" + assert current_post.content == "Current body\n\nOther body" assert not current_post.last_edit_reason post_edit = PostEdit.objects.get(post=current_post) @@ -5225,9 +5225,9 @@ def test_thread_detail_view_merge_post_moderation_action_validates_other_post_li mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - other_post = thread_reply_factory(user_thread, poster=user, original="Other body") + other_post = thread_reply_factory(user_thread, poster=user, content="Other body") response = moderator_client.post( reverse( @@ -5259,10 +5259,10 @@ def test_thread_detail_view_merge_post_moderation_action_validates_other_post_li assert_contains(response, "Enter a valid link.") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" mock_post_synchronize_categories.delay.assert_not_called() @@ -5275,7 +5275,7 @@ def test_thread_detail_view_merge_post_moderation_action_validates_thread_post_l mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) response = moderator_client.post( @@ -5314,7 +5314,7 @@ def test_thread_detail_view_merge_post_moderation_action_validates_thread_post_l assert_contains(response, "Post doesn't exist") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" mock_post_synchronize_categories.delay.assert_not_called() @@ -5328,9 +5328,9 @@ def test_thread_detail_view_merge_post_moderation_action_validates_thread_post_l mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - other_post = thread_reply_factory(thread, poster=user, original="Other body") + other_post = thread_reply_factory(thread, poster=user, content="Other body") response = moderator_client.post( reverse( @@ -5368,10 +5368,10 @@ def test_thread_detail_view_merge_post_moderation_action_validates_thread_post_l assert_contains(response, "Enter a link to a post in the current thread.") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" mock_post_synchronize_categories.delay.assert_not_called() @@ -5384,7 +5384,7 @@ def test_thread_detail_view_merge_post_moderation_action_validates_thread_post_l mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) response = moderator_client.post( @@ -5423,7 +5423,7 @@ def test_thread_detail_view_merge_post_moderation_action_validates_thread_post_l assert_contains(response, "Can't merge a post with itself.") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" mock_post_synchronize_categories.delay.assert_not_called() @@ -5436,7 +5436,7 @@ def test_thread_detail_view_merge_post_moderation_action_validates_global_post_l mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) response = moderator_client.post( @@ -5468,7 +5468,7 @@ def test_thread_detail_view_merge_post_moderation_action_validates_global_post_l assert_contains(response, "Post doesn't exist") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" mock_post_synchronize_categories.delay.assert_not_called() @@ -5483,7 +5483,7 @@ def test_thread_detail_view_merge_post_moderation_action_validates_global_post_l mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) other_post = thread_factory(sibling_category).first_post @@ -5516,7 +5516,7 @@ def test_thread_detail_view_merge_post_moderation_action_validates_global_post_l assert_contains(response, "Post doesn't exist") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" mock_post_synchronize_categories.delay.assert_not_called() @@ -5530,9 +5530,9 @@ def test_thread_detail_view_merge_post_moderation_action_validates_global_post_l mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - other_post = thread_reply_factory(thread, poster=user, original="Other body") + other_post = thread_reply_factory(thread, poster=user, content="Other body") response = moderator_client.post( reverse( @@ -5563,10 +5563,10 @@ def test_thread_detail_view_merge_post_moderation_action_validates_global_post_l assert_contains(response, "Post doesn't exist in this thread") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" mock_post_synchronize_categories.delay.assert_not_called() @@ -5579,7 +5579,7 @@ def test_thread_detail_view_merge_post_moderation_action_validates_global_post_l mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) response = moderator_client.post( @@ -5611,7 +5611,7 @@ def test_thread_detail_view_merge_post_moderation_action_validates_global_post_l assert_contains(response, "Can't merge a post with itself.") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" mock_post_synchronize_categories.delay.assert_not_called() @@ -5624,9 +5624,9 @@ def test_thread_detail_view_merge_post_moderation_action_validates_first_post_me mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) - first_post_content = user_thread.first_post.original + first_post_content = user_thread.first_post.content response = moderator_client.post( reverse( @@ -5666,10 +5666,10 @@ def test_thread_detail_view_merge_post_moderation_action_validates_first_post_me ) current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" user_thread.first_post.refresh_from_db() - assert user_thread.first_post.original == first_post_content + assert user_thread.first_post.content == first_post_content mock_post_synchronize_categories.delay.assert_not_called() @@ -5683,10 +5683,10 @@ def test_thread_detail_view_merge_post_moderation_action_validates_posts_are_by_ mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster=user, original="Current body" + user_thread, poster=user, content="Current body" ) other_post = thread_reply_factory( - user_thread, poster=other_user, original="Other body" + user_thread, poster=other_user, content="Other body" ) response = moderator_client.post( @@ -5725,10 +5725,10 @@ def test_thread_detail_view_merge_post_moderation_action_validates_posts_are_by_ assert_contains(response, "Merged posts must belong to the same user.") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" mock_post_synchronize_categories.delay.assert_not_called() @@ -5740,11 +5740,9 @@ def test_thread_detail_view_merge_post_moderation_action_validates_posts_are_by_ mock_post_synchronize_categories, ): current_post = thread_reply_factory( - user_thread, poster="Bob", original="Current body" - ) - other_post = thread_reply_factory( - user_thread, poster="Elice", original="Other body" + user_thread, poster="Bob", content="Current body" ) + other_post = thread_reply_factory(user_thread, poster="Elice", content="Other body") response = moderator_client.post( reverse( @@ -5782,10 +5780,10 @@ def test_thread_detail_view_merge_post_moderation_action_validates_posts_are_by_ assert_contains(response, "Merged posts must belong to the same user.") current_post.refresh_from_db() - assert current_post.original == "Current body" + assert current_post.content == "Current body" other_post.refresh_from_db() - assert other_post.original == "Other body" + assert other_post.content == "Other body" mock_post_synchronize_categories.delay.assert_not_called() diff --git a/misago/threads/tests/test_thread_detail_view_posts.py b/misago/threads/tests/test_thread_detail_view_posts.py index 696213c14d..72f2da21f2 100644 --- a/misago/threads/tests/test_thread_detail_view_posts.py +++ b/misago/threads/tests/test_thread_detail_view_posts.py @@ -44,7 +44,7 @@ def test_thread_detail_view_returns_redirect_to_last_page_if_page_is_out_of_rang thread_reply_factory, user_client, thread ): for i in range(1, 20): - thread_reply_factory(thread, original=f"Reply no. {i}") + thread_reply_factory(thread, content=f"Reply no. {i}") response = user_client.get( reverse( @@ -110,7 +110,7 @@ def test_thread_detail_view_shows_first_page_in_multi_page_thread( thread_reply_factory, user_client, thread ): for i in range(1, 7): - thread_reply_factory(thread, original=f"Reply no. {i}") + thread_reply_factory(thread, content=f"Reply no. {i}") response = user_client.get( reverse( @@ -135,7 +135,7 @@ def test_thread_detail_view_shows_middle_page_in_multi_page_thread( thread_reply_factory, user_client, thread ): for i in range(1, 12): - thread_reply_factory(thread, original=f"Reply no. {i}") + thread_reply_factory(thread, content=f"Reply no. {i}") response = user_client.get( reverse( @@ -166,7 +166,7 @@ def test_thread_detail_view_shows_last_page_in_multi_page_thread( thread_reply_factory, user_client, thread ): for i in range(1, 7): - thread_reply_factory(thread, original=f"Reply no. {i}") + thread_reply_factory(thread, content=f"Reply no. {i}") response = user_client.get( reverse( @@ -190,86 +190,86 @@ def test_thread_detail_view_shows_last_page_in_multi_page_thread( def test_thread_detail_view_shows_deleted_user_post_to_anonymous_user( thread_reply_factory, client, thread ): - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) response = client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_thread_detail_view_shows_deleted_user_post_to_user( thread_reply_factory, user_client, thread ): - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_thread_detail_view_shows_deleted_user_post_to_moderator( thread_reply_factory, moderator_client, thread ): - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) response = moderator_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_thread_detail_view_shows_user_post_to_anonymous_user( thread_reply_factory, client, thread, user ): - post = thread_reply_factory(thread, original=get_random_string(12), poster=user) + post = thread_reply_factory(thread, content=get_random_string(12), poster=user) response = client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_thread_detail_view_shows_user_post_to_user( thread_reply_factory, user_client, thread, user ): - post = thread_reply_factory(thread, original=get_random_string(12), poster=user) + post = thread_reply_factory(thread, content=get_random_string(12), poster=user) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_thread_detail_view_shows_other_user_post_to_user( thread_reply_factory, user_client, thread, other_user ): post = thread_reply_factory( - thread, original=get_random_string(12), poster=other_user + thread, content=get_random_string(12), poster=other_user ) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_thread_detail_view_shows_user_post_to_moderator( thread_reply_factory, moderator_client, thread, user ): - post = thread_reply_factory(thread, original=get_random_string(12), poster=user) + post = thread_reply_factory(thread, content=get_random_string(12), poster=user) response = moderator_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_thread_detail_view_doesnt_show_deleted_user_post_locked_status_message_to_anonymous_user( thread_reply_factory, client, thread ): - post = thread_reply_factory(thread, original=get_random_string(12), is_locked=True) + post = thread_reply_factory(thread, content=get_random_string(12), is_locked=True) response = client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) @@ -281,7 +281,7 @@ def test_thread_detail_view_doesnt_show_user_post_locked_status_message_to_anony thread_reply_factory, client, user, thread ): post = thread_reply_factory( - thread, poster=user, original=get_random_string(12), is_locked=True + thread, poster=user, content=get_random_string(12), is_locked=True ) response = client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) @@ -293,7 +293,7 @@ def test_thread_detail_view_doesnt_show_user_post_locked_status_message_to_anony def test_thread_detail_view_doesnt_show_deleted_user_post_locked_status_message_to_user( thread_reply_factory, user_client, thread ): - post = thread_reply_factory(thread, original=get_random_string(12), is_locked=True) + post = thread_reply_factory(thread, content=get_random_string(12), is_locked=True) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) @@ -305,7 +305,7 @@ def test_thread_detail_view_doesnt_show_other_user_post_locked_status_message_to thread_reply_factory, user_client, other_user, thread ): post = thread_reply_factory( - thread, poster=other_user, original=get_random_string(12), is_locked=True + thread, poster=other_user, content=get_random_string(12), is_locked=True ) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) @@ -318,7 +318,7 @@ def test_thread_detail_view_shows_user_post_locked_status_message_to_user( thread_reply_factory, user_client, user, thread ): post = thread_reply_factory( - thread, poster=user, original=get_random_string(12), is_locked=True + thread, poster=user, content=get_random_string(12), is_locked=True ) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) @@ -330,7 +330,7 @@ def test_thread_detail_view_shows_user_post_locked_status_message_to_user( def test_thread_detail_view_shows_deleted_user_post_locked_status_message_to_moderator( thread_reply_factory, moderator_client, thread ): - post = thread_reply_factory(thread, original=get_random_string(12), is_locked=True) + post = thread_reply_factory(thread, content=get_random_string(12), is_locked=True) response = moderator_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) @@ -342,7 +342,7 @@ def test_thread_detail_view_shows_user_post_locked_status_message_to_moderator( thread_reply_factory, moderator_client, user, thread ): post = thread_reply_factory( - thread, poster=user, original=get_random_string(12), is_locked=True + thread, poster=user, content=get_random_string(12), is_locked=True ) response = moderator_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) @@ -357,7 +357,7 @@ def test_thread_detail_view_shows_locked_post_with_locked_by_user_at_timestamp_w post = thread_reply_factory( thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_at=True, locked_by=other_user, @@ -378,7 +378,7 @@ def test_thread_detail_view_shows_locked_post_with_locked_by_user_at_timestamp_s post = thread_reply_factory( thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_at=True, locked_by=other_user, @@ -398,7 +398,7 @@ def test_thread_detail_view_shows_locked_post_with_locked_by_deleted_user_at_tim post = thread_reply_factory( thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_at=True, locked_by="OtherUser", @@ -419,7 +419,7 @@ def test_thread_detail_view_shows_locked_post_with_locked_by_deleted_user_at_tim post = thread_reply_factory( thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_at=True, locked_by="OtherUser", @@ -439,7 +439,7 @@ def test_thread_detail_view_shows_locked_post_with_locked_with_at_timestamp_reas post = thread_reply_factory( thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_at=True, lock_reason="Lorem ipsum", @@ -459,7 +459,7 @@ def test_thread_detail_view_shows_locked_post_with_locked_with_at_timestamp_stat post = thread_reply_factory( thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_at=True, ) @@ -478,7 +478,7 @@ def test_thread_detail_view_shows_locked_post_with_locked_by_user_with_reason_st post = thread_reply_factory( thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_by=other_user, lock_reason="Lorem ipsum", @@ -498,7 +498,7 @@ def test_thread_detail_view_shows_locked_post_with_locked_by_user_status_message post = thread_reply_factory( thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_by=other_user, ) @@ -517,7 +517,7 @@ def test_thread_detail_view_shows_locked_post_with_locked_by_deleted_user_with_r post = thread_reply_factory( thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_by="OtherUser", lock_reason="Lorem ipsum", @@ -537,7 +537,7 @@ def test_thread_detail_view_shows_locked_post_with_locked_by_deleted_user_status post = thread_reply_factory( thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, locked_by="OtherUser", ) @@ -556,7 +556,7 @@ def test_thread_detail_view_shows_locked_post_with_lock_reason_status_message( post = thread_reply_factory( thread, poster=user, - original=get_random_string(12), + content=get_random_string(12), is_locked=True, lock_reason="Lorem ipsum", ) @@ -574,7 +574,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_user_a ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hidden_by=other_user, @@ -584,7 +584,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_user_a reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -595,7 +595,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_and_us ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hidden_by=other_user, @@ -604,7 +604,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_and_us reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -614,7 +614,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_delete ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hidden_by="DeletedModerator", @@ -624,7 +624,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_delete reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -634,7 +634,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_and_de ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hidden_by="DeletedModerator", @@ -643,7 +643,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_and_de reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -652,7 +652,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_and_re ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hide_reason="Lorem ipsum offtopic", @@ -661,7 +661,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_and_re reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -670,7 +670,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_to_ano ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, ) @@ -678,7 +678,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_to_ano reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_thread_detail_view_shows_deleted_user_hidden_post_with_user_and_reason_to_anonymous_user( @@ -686,7 +686,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_user_and_reason_ ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_by=other_user, hide_reason="Lorem ipsum offtopic", @@ -695,7 +695,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_user_and_reason_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -706,7 +706,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_user_to_anonymou ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_by=other_user, ) @@ -714,7 +714,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_user_to_anonymou reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -724,7 +724,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_deleted_user_and ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_by="DeletedModerator", hide_reason="Lorem ipsum offtopic", @@ -733,7 +733,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_deleted_user_and reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -743,7 +743,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_deleted_user_to_ ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_by="DeletedModerator", ) @@ -751,7 +751,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_deleted_user_to_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -760,7 +760,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_reason_to_anonym ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hide_reason="Lorem ipsum offtopic", ) @@ -768,7 +768,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_reason_to_anonym reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -777,7 +777,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_user_a ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hidden_by=other_user, @@ -787,7 +787,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_user_a reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -798,7 +798,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_and_us ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hidden_by=other_user, @@ -807,7 +807,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_and_us reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -817,7 +817,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_delete ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hidden_by="DeletedModerator", @@ -827,7 +827,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_delete reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -837,7 +837,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_and_de ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hidden_by="DeletedModerator", @@ -846,7 +846,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_and_de reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -855,7 +855,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_and_re ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, hide_reason="Lorem ipsum offtopic", @@ -864,7 +864,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_and_re reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -873,7 +873,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_to_use ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_at=True, ) @@ -881,7 +881,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_timestamp_to_use reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_thread_detail_view_shows_deleted_user_hidden_post_with_user_and_reason_to_user( @@ -889,7 +889,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_user_and_reason_ ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_by=other_user, hide_reason="Lorem ipsum offtopic", @@ -898,7 +898,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_user_and_reason_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -909,7 +909,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_user_to_user( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_by=other_user, ) @@ -917,7 +917,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_user_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -927,7 +927,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_deleted_user_and ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_by="DeletedModerator", hide_reason="Lorem ipsum offtopic", @@ -936,7 +936,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_deleted_user_and reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -946,7 +946,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_deleted_user_to_ ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hidden_by="DeletedModerator", ) @@ -954,7 +954,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_deleted_user_to_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -963,7 +963,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_reason_to_user( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), is_hidden=True, hide_reason="Lorem ipsum offtopic", ) @@ -971,19 +971,19 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_with_reason_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") def test_thread_detail_view_shows_deleted_user_hidden_post_to_user( thread_reply_factory, user_client, thread ): - post = thread_reply_factory(thread, original=get_random_string(12), is_hidden=True) + post = thread_reply_factory(thread, content=get_random_string(12), is_hidden=True) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_thread_detail_view_shows_user_hidden_post_with_timestamp_user_and_reason_to_user( @@ -991,7 +991,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_user_and_reaso ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1002,7 +1002,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_user_and_reaso reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -1013,7 +1013,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_and_user_to_us ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1023,7 +1023,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_and_user_to_us reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1033,7 +1033,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_deleted_user_a ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1044,7 +1044,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_deleted_user_a reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -1054,7 +1054,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_and_deleted_us ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1064,7 +1064,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_and_deleted_us reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -1073,7 +1073,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_and_reason_to_ ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1083,7 +1083,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_and_reason_to_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -1092,7 +1092,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_to_user( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1101,7 +1101,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_thread_detail_view_shows_user_hidden_post_with_user_and_reason_to_user( @@ -1109,7 +1109,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_user_and_reason_to_user( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by=other_user, @@ -1119,7 +1119,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_user_and_reason_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -1130,7 +1130,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_user_to_user( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by=other_user, @@ -1139,7 +1139,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_user_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1149,7 +1149,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_deleted_user_and_reason_ ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by="DeletedModerator", @@ -1159,7 +1159,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_deleted_user_and_reason_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -1169,7 +1169,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_deleted_user_to_user( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by="DeletedModerator", @@ -1178,7 +1178,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_deleted_user_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -1187,7 +1187,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_reason_to_user( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hide_reason="Lorem ipsum offtopic", @@ -1196,7 +1196,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_reason_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -1204,13 +1204,13 @@ def test_thread_detail_view_shows_user_hidden_post_to_user( thread_reply_factory, user_client, thread, user ): post = thread_reply_factory( - thread, original=get_random_string(12), poster=user, is_hidden=True + thread, content=get_random_string(12), poster=user, is_hidden=True ) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_user_and_reason_to_user( @@ -1218,7 +1218,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_user_and ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_at=True, @@ -1229,7 +1229,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_user_and reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -1240,7 +1240,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_and_user ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_at=True, @@ -1250,7 +1250,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_and_user reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1260,7 +1260,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_deleted_ ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_at=True, @@ -1271,7 +1271,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_deleted_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -1281,7 +1281,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_and_dele ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_at=True, @@ -1291,7 +1291,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_and_dele reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -1300,7 +1300,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_and_reas ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_at=True, @@ -1310,7 +1310,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_and_reas reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -1319,7 +1319,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_to_user( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_at=True, @@ -1328,7 +1328,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_timestamp_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_thread_detail_view_shows_other_user_hidden_post_with_user_and_reason_to_user( @@ -1336,7 +1336,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_user_and_reason_to ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_by=other_user, @@ -1346,7 +1346,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_user_and_reason_to reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) assert_contains(response, "Lorem ipsum offtopic") @@ -1357,7 +1357,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_user_to_user( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_by=other_user, @@ -1366,7 +1366,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_user_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1376,7 +1376,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_deleted_user_and_r ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_by="DeletedModerator", @@ -1386,7 +1386,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_deleted_user_and_r reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -1396,7 +1396,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_deleted_user_to_us ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hidden_by="DeletedModerator", @@ -1405,7 +1405,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_deleted_user_to_us reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "DeletedModerator") @@ -1414,7 +1414,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_reason_to_user( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=other_user, is_hidden=True, hide_reason="Lorem ipsum offtopic", @@ -1423,7 +1423,7 @@ def test_thread_detail_view_shows_other_user_hidden_post_with_reason_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_contains(response, "Lorem ipsum offtopic") @@ -1431,13 +1431,13 @@ def test_thread_detail_view_shows_other_user_hidden_post_to_user( thread_reply_factory, user_client, thread, other_user ): post = thread_reply_factory( - thread, original=get_random_string(12), poster=other_user, is_hidden=True + thread, content=get_random_string(12), poster=other_user, is_hidden=True ) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_thread_detail_view_shows_user_hidden_post_with_timestamp_user_and_reason_to_moderator( @@ -1445,7 +1445,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_user_and_reaso ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1456,7 +1456,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_user_and_reaso reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1468,7 +1468,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_and_user_to_mo ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1478,7 +1478,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_and_user_to_mo reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1489,7 +1489,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_deleted_user_a ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1500,7 +1500,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_deleted_user_a reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -1511,7 +1511,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_and_deleted_us ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1521,7 +1521,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_and_deleted_us reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, "DeletedModerator") @@ -1531,7 +1531,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_and_reason_to_ ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1541,7 +1541,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_and_reason_to_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, "Lorem ipsum offtopic") @@ -1551,7 +1551,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_to_moderator( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_at=True, @@ -1560,7 +1560,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_timestamp_to_moderator( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") @@ -1569,7 +1569,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_user_and_reason_to_moder ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by=other_user, @@ -1579,7 +1579,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_user_and_reason_to_moder reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1591,7 +1591,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_user_to_moderator( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by=other_user, @@ -1600,7 +1600,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_user_to_moderator( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, other_user.get_absolute_url()) assert_contains(response, other_user.username) @@ -1611,7 +1611,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_deleted_user_and_reason_ ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by="DeletedModerator", @@ -1621,7 +1621,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_deleted_user_and_reason_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, "DeletedModerator") assert_contains(response, "Lorem ipsum offtopic") @@ -1632,7 +1632,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_deleted_user_to_moderato ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hidden_by="DeletedModerator", @@ -1641,7 +1641,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_deleted_user_to_moderato reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, "DeletedModerator") @@ -1651,7 +1651,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_reason_to_moderator( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, hide_reason="Lorem ipsum offtopic", @@ -1660,7 +1660,7 @@ def test_thread_detail_view_shows_user_hidden_post_with_reason_to_moderator( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") assert_contains(response, "Lorem ipsum offtopic") @@ -1670,7 +1670,7 @@ def test_thread_detail_view_shows_user_hidden_post_to_moderator( ): post = thread_reply_factory( thread, - original=get_random_string(12), + content=get_random_string(12), poster=user, is_hidden=True, ) @@ -1678,7 +1678,7 @@ def test_thread_detail_view_shows_user_hidden_post_to_moderator( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, "Hidden and visible only to moderators.") @@ -1686,59 +1686,59 @@ def test_thread_detail_view_doesnt_show_unapproved_post_to_anonymous_user( thread_reply_factory, client, thread ): post = thread_reply_factory( - thread, original=get_random_string(12), is_unapproved=True + thread, content=get_random_string(12), is_unapproved=True ) response = client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_not_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_thread_detail_view_doesnt_show_unapproved_post_to_user( thread_reply_factory, user_client, thread ): post = thread_reply_factory( - thread, original=get_random_string(12), is_unapproved=True + thread, content=get_random_string(12), is_unapproved=True ) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_not_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) def test_thread_detail_view_shows_unapproved_post_to_poster( thread_reply_factory, user_client, thread, user ): post = thread_reply_factory( - thread, original=get_random_string(12), poster=user, is_unapproved=True + thread, content=get_random_string(12), poster=user, is_unapproved=True ) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_thread_detail_view_shows_deleted_user_unapproved_post_to_moderator( thread_reply_factory, moderator_client, thread ): post = thread_reply_factory( - thread, original=get_random_string(12), is_unapproved=True + thread, content=get_random_string(12), is_unapproved=True ) response = moderator_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) def test_thread_detail_view_doesnt_show_deleted_user_unapproved_post_to_anonymous_user( thread_reply_factory, client, thread ): post = thread_reply_factory( - thread, original=get_random_string(12), is_unapproved=True + thread, content=get_random_string(12), is_unapproved=True ) response = client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) @@ -1750,7 +1750,7 @@ def test_thread_detail_view_doesnt_show_deleted_user_unapproved_post_to_user( thread_reply_factory, user_client, thread ): post = thread_reply_factory( - thread, original=get_random_string(12), is_unapproved=True + thread, content=get_random_string(12), is_unapproved=True ) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) @@ -1762,7 +1762,7 @@ def test_thread_detail_view_doesnt_show_user_unapproved_post_to_anonymous_user( thread_reply_factory, client, other_user, thread ): post = thread_reply_factory( - thread, poster=other_user, original=get_random_string(12), is_unapproved=True + thread, poster=other_user, content=get_random_string(12), is_unapproved=True ) response = client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) @@ -1774,7 +1774,7 @@ def test_thread_detail_view_doesnt_show_user_unapproved_post_to_other_user( thread_reply_factory, user_client, other_user, thread ): post = thread_reply_factory( - thread, poster=other_user, original=get_random_string(12), is_unapproved=True + thread, poster=other_user, content=get_random_string(12), is_unapproved=True ) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) @@ -1786,7 +1786,7 @@ def test_thread_detail_view_shows_user_unapproved_post_to_user( thread_reply_factory, user_client, user, thread ): post = thread_reply_factory( - thread, poster=user, original=get_random_string(12), is_unapproved=True + thread, poster=user, content=get_random_string(12), is_unapproved=True ) response = user_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) @@ -1802,7 +1802,7 @@ def test_thread_detail_view_shows_user_unapproved_post_to_moderator( thread_reply_factory, moderator_client, user, thread ): post = thread_reply_factory( - thread, poster=user, original=get_random_string(12), is_unapproved=True + thread, poster=user, content=get_random_string(12), is_unapproved=True ) response = moderator_client.get( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) @@ -1843,7 +1843,7 @@ def test_thread_detail_view_shows_post_with_all_attachment_types( other_user_broken_image_thumbnail_attachment, other_user_broken_video_attachment, ): - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -1921,7 +1921,7 @@ def test_thread_detail_view_shows_post_with_all_attachment_types( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2004,7 +2004,7 @@ def test_thread_detail_view_shows_deleted_user_post_attachments_to_anonymous_use thread, user_text_attachment, ): - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) user_text_attachment.associate_with_post(post) user_text_attachment.save() @@ -2013,7 +2013,7 @@ def test_thread_detail_view_shows_deleted_user_post_attachments_to_anonymous_use reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, user_text_attachment.name) assert_contains(response, user_text_attachment.get_absolute_url()) @@ -2025,7 +2025,7 @@ def test_thread_detail_view_shows_deleted_user_post_attachments_to_user( thread, text_attachment, ): - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -2034,7 +2034,7 @@ def test_thread_detail_view_shows_deleted_user_post_attachments_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2046,7 +2046,7 @@ def test_thread_detail_view_shows_deleted_user_post_attachments_to_moderator( thread, text_attachment, ): - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -2055,7 +2055,7 @@ def test_thread_detail_view_shows_deleted_user_post_attachments_to_moderator( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2068,7 +2068,7 @@ def test_thread_detail_view_shows_user_post_attachments_to_anonymous_user( user, text_attachment, ): - post = thread_reply_factory(thread, original=get_random_string(12), poster=user) + post = thread_reply_factory(thread, content=get_random_string(12), poster=user) text_attachment.associate_with_post(post) text_attachment.save() @@ -2077,7 +2077,7 @@ def test_thread_detail_view_shows_user_post_attachments_to_anonymous_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2090,7 +2090,7 @@ def test_thread_detail_view_shows_user_post_attachments_to_user( user, text_attachment, ): - post = thread_reply_factory(thread, original=get_random_string(12), poster=user) + post = thread_reply_factory(thread, content=get_random_string(12), poster=user) text_attachment.associate_with_post(post) text_attachment.save() @@ -2099,7 +2099,7 @@ def test_thread_detail_view_shows_user_post_attachments_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2113,7 +2113,7 @@ def test_thread_detail_view_shows_other_user_post_attachments_to_user( text_attachment, ): post = thread_reply_factory( - thread, original=get_random_string(12), poster=other_user + thread, content=get_random_string(12), poster=other_user ) text_attachment.associate_with_post(post) @@ -2123,7 +2123,7 @@ def test_thread_detail_view_shows_other_user_post_attachments_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2136,7 +2136,7 @@ def test_thread_detail_view_shows_user_post_attachments_to_moderator( user, text_attachment, ): - post = thread_reply_factory(thread, original=get_random_string(12), poster=user) + post = thread_reply_factory(thread, content=get_random_string(12), poster=user) text_attachment.associate_with_post(post) text_attachment.save() @@ -2145,7 +2145,7 @@ def test_thread_detail_view_shows_user_post_attachments_to_moderator( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2158,7 +2158,7 @@ def test_thread_detail_view_doesnt_show_unapproved_post_attachments_to_anonymous text_attachment, ): post = thread_reply_factory( - thread, original=get_random_string(12), is_unapproved=True + thread, content=get_random_string(12), is_unapproved=True ) text_attachment.associate_with_post(post) @@ -2168,7 +2168,7 @@ def test_thread_detail_view_doesnt_show_unapproved_post_attachments_to_anonymous reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_not_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, text_attachment.name) assert_not_contains(response, text_attachment.get_absolute_url()) @@ -2181,7 +2181,7 @@ def test_thread_detail_view_doesnt_show_unapproved_post_attachments_to_user( text_attachment, ): post = thread_reply_factory( - thread, original=get_random_string(12), is_unapproved=True + thread, content=get_random_string(12), is_unapproved=True ) text_attachment.associate_with_post(post) @@ -2191,7 +2191,7 @@ def test_thread_detail_view_doesnt_show_unapproved_post_attachments_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_not_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, text_attachment.name) assert_not_contains(response, text_attachment.get_absolute_url()) @@ -2205,7 +2205,7 @@ def test_thread_detail_view_shows_unapproved_post_attachments_to_poster( text_attachment, ): post = thread_reply_factory( - thread, original=get_random_string(12), poster=user, is_unapproved=True + thread, content=get_random_string(12), poster=user, is_unapproved=True ) text_attachment.associate_with_post(post) @@ -2215,7 +2215,7 @@ def test_thread_detail_view_shows_unapproved_post_attachments_to_poster( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2228,7 +2228,7 @@ def test_thread_detail_view_shows_deleted_user_unapproved_post_attachments_to_mo text_attachment, ): post = thread_reply_factory( - thread, original=get_random_string(12), is_unapproved=True + thread, content=get_random_string(12), is_unapproved=True ) text_attachment.associate_with_post(post) @@ -2238,7 +2238,7 @@ def test_thread_detail_view_shows_deleted_user_unapproved_post_attachments_to_mo reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2252,7 +2252,7 @@ def test_thread_detail_view_shows_user_unapproved_post_attachments_to_moderator( text_attachment, ): post = thread_reply_factory( - thread, original=get_random_string(12), poster=user, is_unapproved=True + thread, content=get_random_string(12), poster=user, is_unapproved=True ) text_attachment.associate_with_post(post) @@ -2262,7 +2262,7 @@ def test_thread_detail_view_shows_user_unapproved_post_attachments_to_moderator( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2274,7 +2274,7 @@ def test_thread_detail_view_doesnt_show_deleted_user_hidden_post_attachments_to_ thread, text_attachment, ): - post = thread_reply_factory(thread, original=get_random_string(12), is_hidden=True) + post = thread_reply_factory(thread, content=get_random_string(12), is_hidden=True) text_attachment.associate_with_post(post) text_attachment.save() @@ -2283,7 +2283,7 @@ def test_thread_detail_view_doesnt_show_deleted_user_hidden_post_attachments_to_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, text_attachment.name) assert_not_contains(response, text_attachment.get_absolute_url()) @@ -2295,7 +2295,7 @@ def test_thread_detail_view_doesnt_show_deleted_user_hidden_post_attachments_to_ thread, text_attachment, ): - post = thread_reply_factory(thread, original=get_random_string(12), is_hidden=True) + post = thread_reply_factory(thread, content=get_random_string(12), is_hidden=True) text_attachment.associate_with_post(post) text_attachment.save() @@ -2304,7 +2304,7 @@ def test_thread_detail_view_doesnt_show_deleted_user_hidden_post_attachments_to_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, text_attachment.name) assert_not_contains(response, text_attachment.get_absolute_url()) @@ -2316,7 +2316,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_attachments_to_modera thread, text_attachment, ): - post = thread_reply_factory(thread, original=get_random_string(12), is_hidden=True) + post = thread_reply_factory(thread, content=get_random_string(12), is_hidden=True) text_attachment.associate_with_post(post) text_attachment.save() @@ -2325,7 +2325,7 @@ def test_thread_detail_view_shows_deleted_user_hidden_post_attachments_to_modera reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2339,7 +2339,7 @@ def test_thread_detail_view_doesnt_show_user_hidden_post_attachments_to_anonymou text_attachment, ): post = thread_reply_factory( - thread, original=get_random_string(12), poster=user, is_hidden=True + thread, content=get_random_string(12), poster=user, is_hidden=True ) text_attachment.associate_with_post(post) @@ -2349,7 +2349,7 @@ def test_thread_detail_view_doesnt_show_user_hidden_post_attachments_to_anonymou reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, text_attachment.name) assert_not_contains(response, text_attachment.get_absolute_url()) @@ -2363,7 +2363,7 @@ def test_thread_detail_view_doesnt_show_user_hidden_post_attachments_to_user( text_attachment, ): post = thread_reply_factory( - thread, original=get_random_string(12), poster=user, is_hidden=True + thread, content=get_random_string(12), poster=user, is_hidden=True ) text_attachment.associate_with_post(post) @@ -2373,7 +2373,7 @@ def test_thread_detail_view_doesnt_show_user_hidden_post_attachments_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, text_attachment.name) assert_not_contains(response, text_attachment.get_absolute_url()) @@ -2387,7 +2387,7 @@ def test_thread_detail_view_doesnt_show_other_user_hidden_post_attachments_to_us text_attachment, ): post = thread_reply_factory( - thread, original=get_random_string(12), poster=other_user, is_hidden=True + thread, content=get_random_string(12), poster=other_user, is_hidden=True ) text_attachment.associate_with_post(post) @@ -2397,7 +2397,7 @@ def test_thread_detail_view_doesnt_show_other_user_hidden_post_attachments_to_us reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_not_contains(response, post.original) + assert_not_contains(response, post.content) assert_not_contains(response, text_attachment.name) assert_not_contains(response, text_attachment.get_absolute_url()) @@ -2411,7 +2411,7 @@ def test_thread_detail_view_shows_user_hidden_post_attachments_to_moderator( text_attachment, ): post = thread_reply_factory( - thread, original=get_random_string(12), poster=user, is_hidden=True + thread, content=get_random_string(12), poster=user, is_hidden=True ) text_attachment.associate_with_post(post) @@ -2421,7 +2421,7 @@ def test_thread_detail_view_shows_user_hidden_post_attachments_to_moderator( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2442,7 +2442,7 @@ def test_thread_detail_view_shows_post_attachments_to_anonymous_user_without_per permission=CategoryPermission.ATTACHMENTS, ).delete() - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -2460,7 +2460,7 @@ def test_thread_detail_view_shows_post_attachments_to_anonymous_user_without_per reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2490,7 +2490,7 @@ def test_thread_detail_view_shows_post_attachments_to_user_without_permission( permission=CategoryPermission.ATTACHMENTS, ).delete() - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -2508,7 +2508,7 @@ def test_thread_detail_view_shows_post_attachments_to_user_without_permission( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2539,7 +2539,7 @@ def test_thread_detail_view_shows_post_attachments_to_uploader_without_permissio permission=CategoryPermission.ATTACHMENTS, ).delete() - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -2560,7 +2560,7 @@ def test_thread_detail_view_shows_post_attachments_to_uploader_without_permissio reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.get_absolute_url()) @@ -2592,7 +2592,7 @@ def test_thread_detail_view_shows_post_attachments_from_moderator_without_permis permission=CategoryPermission.ATTACHMENTS, ).delete() - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -2610,7 +2610,7 @@ def test_thread_detail_view_shows_post_attachments_from_moderator_without_permis reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2640,7 +2640,7 @@ def test_thread_detail_view_shows_post_attachments_to_admin_without_permission( permission=CategoryPermission.ATTACHMENTS, ).delete() - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -2658,7 +2658,7 @@ def test_thread_detail_view_shows_post_attachments_to_admin_without_permission( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_contains(response, text_attachment.name) assert_contains(response, text_attachment.get_absolute_url()) @@ -2702,7 +2702,7 @@ def test_thread_detail_view_shows_post_with_all_attachment_types_embedded( other_user_broken_image_thumbnail_attachment, other_user_broken_video_attachment, ): - post = thread_reply_factory(thread, original=get_random_string(12)) + post = thread_reply_factory(thread, content=get_random_string(12)) text_attachment.associate_with_post(post) text_attachment.save() @@ -2776,7 +2776,7 @@ def test_thread_detail_view_shows_post_with_all_attachment_types_embedded( other_user_broken_video_attachment.associate_with_post(post) other_user_broken_video_attachment.save() - post.parsed += ( + post.content_parsed += ( "\n" f'' "\n" @@ -2860,7 +2860,7 @@ def test_thread_detail_view_shows_post_with_all_attachment_types_embedded( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -2965,7 +2965,7 @@ def test_thread_detail_view_shows_deleted_user_post_embedded_attachments_to_anon reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -2998,7 +2998,7 @@ def test_thread_detail_view_shows_deleted_user_post_embedded_attachments_to_user reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3031,7 +3031,7 @@ def test_thread_detail_view_shows_deleted_user_post_embedded_attachments_to_mode reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3065,7 +3065,7 @@ def test_thread_detail_view_shows_user_post_embedded_attachments_to_anonymous_us reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3099,7 +3099,7 @@ def test_thread_detail_view_shows_user_post_embedded_attachments_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3135,7 +3135,7 @@ def test_thread_detail_view_shows_other_user_post_embedded_attachments_to_user( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3169,7 +3169,7 @@ def test_thread_detail_view_shows_user_post_embedded_attachments_to_moderator( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' "\n" @@ -3232,7 +3232,7 @@ def test_thread_detail_view_doesnt_show_post_embedded_attachments_to_anonymous_u reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' "\n" @@ -3303,7 +3303,7 @@ def test_thread_detail_view_doesnt_show_post_embedded_attachments_to_user_withou reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' "\n" @@ -3374,7 +3374,7 @@ def test_thread_detail_view_shows_post_embedded_attachments_to_uploader_without_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' "\n" @@ -3445,7 +3445,7 @@ def test_thread_detail_view_doesnt_show_post_embedded_attachments_to_moderator_w reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' "\n" @@ -3516,7 +3516,7 @@ def test_thread_detail_view_shows_post_embedded_attachments_to_admin_without_per reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3560,7 +3560,7 @@ def test_thread_detail_view_shows_post_embedded_attachments_from_other_post( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3598,7 +3598,7 @@ def test_thread_detail_view_doesnt_show_post_embedded_attachments_from_unapprove reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3641,7 +3641,7 @@ def test_thread_detail_view_doesnt_show_post_embedded_attachments_from_hidden_po reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3689,7 +3689,7 @@ def test_thread_detail_view_shows_post_embedded_attachments_from_post_on_other_p ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3735,7 +3735,7 @@ def test_thread_detail_view_doesnt_show_post_embedded_attachments_from_other_pos reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3773,7 +3773,7 @@ def test_thread_detail_view_shows_post_embedded_attachments_from_other_thread_po reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3813,7 +3813,7 @@ def test_thread_detail_view_doesnt_show_post_embedded_attachments_from_inaccessi reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3852,7 +3852,7 @@ def test_thread_detail_view_doesnt_show_post_embedded_attachments_from_inaccessi reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3908,7 +3908,7 @@ def test_thread_detail_view_shows_post_embedded_attachments_from_other_category( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3959,7 +3959,7 @@ def test_thread_detail_view_doesnt_show_post_embedded_attachments_from_other_cat reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -3999,7 +3999,7 @@ def test_thread_detail_view_shows_post_embedded_attachments_from_private_thread_ reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -4036,7 +4036,7 @@ def test_thread_detail_doesnt_show_post_embedded_attachments_from_inaccessible_p reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -4079,7 +4079,7 @@ def test_thread_detail_doesnt_show_post_embedded_attachments_from_private_thread reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -4116,7 +4116,7 @@ def test_thread_detail_doesnt_show_post_embedded_attachments_from_private_thread reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' ) @@ -4147,7 +4147,7 @@ def test_thread_detail_view_doesnt_show_unassociated_embedded_attachment( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{previous_post.parsed}" + f"{previous_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [previous_post.id]} post.save() @@ -5100,7 +5100,7 @@ def test_thread_detail_view_shows_post_with_previous_post_quote( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{previous_post.parsed}" + f"{previous_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [previous_post.id]} post.save() @@ -5131,7 +5131,7 @@ def test_thread_detail_view_shows_post_with_unapproved_previous_post_quote( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{previous_post.parsed}" + f"{previous_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [previous_post.id]} post.save() @@ -5162,7 +5162,7 @@ def test_thread_detail_view_shows_post_with_hidden_previous_post_quote( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{previous_post.parsed}" + f"{previous_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [previous_post.id]} post.save() @@ -5199,7 +5199,7 @@ def test_thread_detail_view_shows_post_with_quote_of_deleted_user_post_from_othe ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{previous_post.parsed}" + f"{previous_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [previous_post.id]} post.save() @@ -5238,7 +5238,7 @@ def test_thread_detail_view_shows_post_with_quote_of_user_post_from_other_page( ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{previous_post.parsed}" + f"{previous_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [previous_post.id]} post.save() @@ -5278,7 +5278,7 @@ def test_thread_detail_view_shows_post_with_quote_of_other_user_post_from_other_ ) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -5308,7 +5308,7 @@ def test_thread_detail_view_shows_post_with_other_thread_deleted_user_post_quote reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -5340,7 +5340,7 @@ def test_thread_detail_view_shows_post_with_other_thread_user_post_quote( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -5373,7 +5373,7 @@ def test_thread_detail_view_shows_post_with_other_thread_other_user_post_quote( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -5406,7 +5406,7 @@ def test_thread_detail_view_shows_post_with_inaccessible_thread_quote( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -5438,7 +5438,7 @@ def test_thread_detail_view_shows_post_with_inaccessible_thread_post_quote( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -5483,7 +5483,7 @@ def test_thread_detail_view_shows_post_with_other_category_post_quote( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -5516,7 +5516,7 @@ def test_thread_detail_view_shows_post_with_other_category_inaccessible_post_quo reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -5548,7 +5548,7 @@ def test_thread_detail_view_shows_post_with_private_thread_post_quote( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -5578,7 +5578,7 @@ def test_thread_detail_view_shows_post_with_inaccessible_private_thread_post_quo reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' - f"{other_post.parsed}" + f"{other_post.content_parsed}" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [other_post.id]} post.save() @@ -5614,7 +5614,7 @@ def test_thread_detail_view_shows_post_with_private_thread_post_quote_without_pr reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "' "

Lorem ipsum

" "" "\n" - f"{post.parsed}" + f"{post.content_parsed}" ) post.metadata = {"posts": [post.id + 100]} post.save() @@ -5642,7 +5642,7 @@ def test_thread_detail_view_shows_post_with_deleted_post_quote( reverse("misago:thread", kwargs={"thread_id": thread.id, "slug": thread.slug}) ) assert_contains(response, post.get_absolute_url()) - assert_contains(response, post.original) + assert_contains(response, post.content) assert_not_contains(response, "" - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_image_with_title( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f'This is link: ![Image](/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1 "Hello world")' - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_short_image( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: !(/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_short_image_with_title( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f'This is link: !(/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1 "Hello world")' - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_img_bbcode( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [img]/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1[/img]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_image( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: ![Image](/a/thumb/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_image_with_title( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f'This is link: ![Image](/a/thumb/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1 "Hello world")' - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_short_image( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: !(/a/thumb/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_short_image_with_title( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f'This is link: !(/a/thumb/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1 "Hello world")' - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_img_bbcode( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [img]/a/thumb/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1[/img]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_media_path_image( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: ![Image]({image_thumbnail_attachment.upload.url})" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_media_path_image_with_title( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f'This is link: ![Image]({image_thumbnail_attachment.upload.url} "Hello world")' - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_media_path_short_image( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: !({image_thumbnail_attachment.upload.url})" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_media_path_short_image_with_title( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f'This is link: !({image_thumbnail_attachment.upload.url} "Hello world")' - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_media_path_img_bbcode( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [img]{image_thumbnail_attachment.upload.url}[/img]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_media_path_image( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: ![Image]({image_thumbnail_attachment.thumbnail.url})" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_media_path_image_with_title( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f'This is link: ![Image]({image_thumbnail_attachment.thumbnail.url} "Hello world")' - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_media_path_short_image( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: !({image_thumbnail_attachment.thumbnail.url})" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_media_path_short_image_with_title( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f'This is link: !({image_thumbnail_attachment.thumbnail.url} "Hello world")' - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_media_path_img_bbcode( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [img]{image_thumbnail_attachment.thumbnail.url}[/img]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_absolute_media_path_image( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: ![Image](http://example.com{image_thumbnail_attachment.upload.url})" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_absolute_media_path_image_with_title( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f'This is link: ![Image](http://example.com{image_thumbnail_attachment.upload.url} "Hello world")' - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_absolute_media_path_short_image( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: !(http://example.com{image_thumbnail_attachment.upload.url})" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_absolute_media_path_short_image_with_title( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f'This is link: !(http://example.com{image_thumbnail_attachment.upload.url} "Hello world")' - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_absolute_media_path_img_bbcode( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [img]http://example.com{image_thumbnail_attachment.upload.url}[/img]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_absolute_media_path_image( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: ![Image](https://example.com{image_thumbnail_attachment.thumbnail.url})" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_absolute_media_path_image_with_title( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f'This is link: ![Image](https://example.com{image_thumbnail_attachment.thumbnail.url} "Hello world")' - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_absolute_media_path_short_image( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: !(https://example.com{image_thumbnail_attachment.thumbnail.url})" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_absolute_media_path_short_image_with_title( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f'This is link: !(https://example.com{image_thumbnail_attachment.thumbnail.url} "Hello world")' - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_absolute_media_path_img_bbcode( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [img]https://example.com{image_thumbnail_attachment.thumbnail.url}[/img]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_skips_autolink(post): - post.original = ( - "Hello world!" - "\n\n" - "This is link: " - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert not migration(Attachment, post) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_image_autolink(post, image_attachment): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert ( - f"" - ) in post.original - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_image_thumb_autolink( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert ( - f"" - ) in post.original - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_media_path_autolink( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: <{image_thumbnail_attachment.upload.url}>" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_media_path_autolink( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: <{image_thumbnail_attachment.thumbnail.url}>" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_absolute_media_path_autolink( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_replaces_attachment_thumb_absolute_media_path_autolink( - post, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_skips_link(post): - post.original = ( - "Hello world!" - "\n\n" - "This is link: [Link](https://example.com/image.png)" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert not migration(Attachment, post) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_skips_url_bbcode(post): - post.original = ( - "Hello world!" - "\n\n" - "This is link: [url]https://example.com/image.png[/url]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert not migration(Attachment, post) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_skips_url_bbcode_with_text(post): - post.original = ( - "Hello world!" - "\n\n" - "This is link: [url=https://example.com/image.png]Link[/url]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert not migration(Attachment, post) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_link_with_attachment_label( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [![attachment](/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)](https://example.com/image.png)" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_link_with_short_attachment_label( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [!(/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)](https://example.com/image.png)" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_attachment_link_with_label( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [some attachment](/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: some attachment " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_attachment_link_with_attachment_label( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [![attachment](/a/thumb/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)](/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_attachment_link_with_short_attachment_label( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [!(/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)](/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_url_bbcode_with_attachment( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [url]/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1[/url]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_url_bbcode_with_attachment_label( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [url=https://example.com/image.png]![attachment](/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)[/url]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_url_bbcode_with_short_attachment_label( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [url=https://example.com/image.png]!(/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)[/url]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_attachment_url_bbcode_with_label( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [url=/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1]some attachment[/url]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: some attachment " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_attachment_url_bbcode_with_attachment_label( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [url=/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1]![attachment](/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)[/url]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_attachment_url_bbcode_with_short_attachment_label( - post, image_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"This is link: [url=/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1]!(/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)[/url]" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"This is link: " - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_attachment_link_followed_by_other_attachment_link( - post, image_attachment, image_thumbnail_attachment -): - post.original = ( - "Hello world!" - "\n\n" - f"[![Zrzut ekranu 2025-01-5 o 13.30.00.png](/a/thumb/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)](/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)" - "\n\n" - f"[![Zrzut ekranu 2025-01-5 o 13.32.06.png](/a/thumb/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_thumbnail_attachment.id}/?shva=1)](/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_thumbnail_attachment.id}/?shva=1)" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"" - "\n\n" - f"" - "\n\n" - "I hope you've liked it!" - ) - - -@pytest.mark.xfail(reason="broken by misago.posts migration") -def test_update_post_attachments_markup_updates_attachment_link_with_attachment_having_space_in_name( - post, image_attachment -): - image_attachment.name = "Zrzut ekranu 2025-01-5 o 13.30.00.png" - image_attachment.save() - - post.original = ( - "Hello world!" - "\n\n" - f"[![Zrzut ekranu 2025-01-5 o 13.30.00.png](/a/thumb/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)](/a/sx3otAV3pIuLwIeUJmRLe4oOCUeH62K2kwbupiwqm8H4KMzN5WqjqkvwHUToxlQp/{image_attachment.id}/?shva=1)" - "\n\n" - "I hope you've liked it!" - ) - post.save() - - assert migration(Attachment, post) - - post.refresh_from_db() - assert post.original == ( - "Hello world!" - "\n\n" - f"" - "\n\n" - "I hope you've liked it!" - ) diff --git a/plugins/misago-dev-site-fixture/misago_dev_site_fixture/management/commands/loaddevfixture.py b/plugins/misago-dev-site-fixture/misago_dev_site_fixture/management/commands/loaddevfixture.py index d646188a7a..0f6b04a3f1 100644 --- a/plugins/misago-dev-site-fixture/misago_dev_site_fixture/management/commands/loaddevfixture.py +++ b/plugins/misago-dev-site-fixture/misago_dev_site_fixture/management/commands/loaddevfixture.py @@ -41,8 +41,8 @@ class ThreadData: class PostData: poster: str posted_at: datetime - original: str - parsed: str + content: str + content_parsed: str is_locked: bool = False is_hidden: bool = False is_unapproved: bool = False @@ -240,8 +240,8 @@ def random_user(): minute=randint(0, 59), second=randint(0, 59), ), - original="This thread shows timestamps for content from another year.", - parsed=( + content="This thread shows timestamps for content from another year.", + content_parsed=( "

This thread shows timestamps for content from another year.

" ), ) @@ -260,8 +260,8 @@ def random_user(): minute=randint(0, 59), second=randint(0, 59), ), - original="This thread shows timestamps for content from current year.", - parsed=( + content="This thread shows timestamps for content from current year.", + content_parsed=( "

This thread shows timestamps for content from current year.

" ), ) @@ -281,8 +281,8 @@ def random_user(): ) - timedelta(days=3) ), - original="This thread shows timestamps for content from current week.", - parsed=( + content="This thread shows timestamps for content from current week.", + content_parsed=( "

This thread shows timestamps for content from current week.

" ), ) @@ -295,8 +295,8 @@ def random_user(): PostData( poster=random_deleted_user(), posted_at=timezone.now() - timedelta(hours=24), - original="This thread shows timestamps for content from yesterday.", - parsed=( + content="This thread shows timestamps for content from yesterday.", + content_parsed=( "

This thread shows timestamps for content from yesterday.

" ), ) @@ -310,35 +310,35 @@ def random_user(): poster=moderator, posted_at=timezone.now() - timedelta(minutes=(60 * 3) + randint(0, 59)), - original="Post by a moderator.", - parsed="

Post by a moderator.

", + content="Post by a moderator.", + content_parsed="

Post by a moderator.

", ), PostData( poster=user, posted_at=timezone.now() - timedelta(minutes=(60 * 2) + randint(0, 59)), - original="Post by a registered user.", - parsed="

Post by a registered user.

", + content="Post by a registered user.", + content_parsed="

Post by a registered user.

", ), PostData( poster=banned_user, posted_at=timezone.now() - timedelta(minutes=60 + randint(0, 59)), - original="Post by a banned user.", - parsed="

Post by a banned user.

", + content="Post by a banned user.", + content_parsed="

Post by a banned user.

", ), PostData( poster=random_deleted_user(), posted_at=timezone.now() - timedelta(minutes=randint(0, 59)), - original="Post by a deleted user.", - parsed="

Post by a deleted user.

", + content="Post by a deleted user.", + content_parsed="

Post by a deleted user.

", ), PostData( poster=other_user, posted_at=timezone.now() - timedelta(minutes=(60 * 2) + randint(0, 59)), - original="Post by an other registered user.", - parsed="

Post by an other registered user.

", + content="Post by an other registered user.", + content_parsed="

Post by an other registered user.

", ), ], ), @@ -350,8 +350,8 @@ def random_user(): PostData( poster=moderator, posted_at=timezone.now() - timedelta(minutes=randint(0, 600)), - original="This thread is globally pinned.", - parsed="

This thread is globally pinned.

", + content="This thread is globally pinned.", + content_parsed="

This thread is globally pinned.

", ), ], ), @@ -363,8 +363,8 @@ def random_user(): PostData( poster=moderator, posted_at=timezone.now() - timedelta(minutes=randint(0, 600)), - original="This thread is pinned in a category.", - parsed="

This thread is pinned in a category.

", + content="This thread is pinned in a category.", + content_parsed="

This thread is pinned in a category.

", ), ], ), @@ -376,8 +376,8 @@ def random_user(): PostData( poster=user, posted_at=timezone.now() - timedelta(minutes=randint(0, 600)), - original="This thread is hidden.", - parsed="

This thread is hidden.

", + content="This thread is hidden.", + content_parsed="

This thread is hidden.

", ), ], ), @@ -389,8 +389,8 @@ def random_user(): PostData( poster=user, posted_at=timezone.now() - timedelta(minutes=randint(0, 600)), - original="This thread is unapproved.", - parsed="

This thread is unapproved.

", + content="This thread is unapproved.", + content_parsed="

This thread is unapproved.

", ), ], ), @@ -402,8 +402,8 @@ def random_user(): PostData( poster=user, posted_at=timezone.now() - timedelta(minutes=randint(0, 600)), - original="This thread is locked.", - parsed="

This thread is locked.

", + content="This thread is locked.", + content_parsed="

This thread is locked.

", ), ], ), @@ -415,16 +415,16 @@ def random_user(): poster=user, posted_at=timezone.now() - timedelta(minutes=400 - randint(0, 59)), - original="This post is locked.", - parsed="

This post is locked.

", + content="This post is locked.", + content_parsed="

This post is locked.

", is_locked=True, ), PostData( poster="JohnDoe", posted_at=timezone.now() - timedelta(minutes=300 - randint(0, 59)), - original="This post is hidden by deleted user.", - parsed="

This post is hidden by deleted user.

", + content="This post is hidden by deleted user.", + content_parsed="

This post is hidden by deleted user.

", is_hidden=True, hidden_by="JohnDoe", ), @@ -432,16 +432,16 @@ def random_user(): poster=other_user, posted_at=timezone.now() - timedelta(minutes=200 - randint(0, 59)), - original="This post is hidden by the moderator.", - parsed="

This post is hidden by the moderator.

", + content="This post is hidden by the moderator.", + content_parsed="

This post is hidden by the moderator.

", is_hidden=True, hidden_by=moderator, ), PostData( poster=user, posted_at=timezone.now() - timedelta(minutes=randint(0, 59)), - original="This post is unapproved.", - parsed="

This post is unapproved.

", + content="This post is unapproved.", + content_parsed="

This post is unapproved.

", is_unapproved=True, ), ], @@ -454,15 +454,15 @@ def random_user(): poster=random_deleted_user(), posted_at=timezone.now() - timedelta(minutes=300 + randint(0, 60)), - original="Thread by a deleted user.", - parsed="

Thread by a deleted user.

", + content="Thread by a deleted user.", + content_parsed="

Thread by a deleted user.

", ), PostData( poster=random_deleted_user(), posted_at=timezone.now() - timedelta(minutes=100 + randint(0, 60)), - original="Reply by a deleted user.", - parsed="

Reply by a deleted user.

", + content="Reply by a deleted user.", + content_parsed="

Reply by a deleted user.

", ), ], ), @@ -474,15 +474,15 @@ def random_user(): poster=random_registered_user(), posted_at=timezone.now() - timedelta(minutes=300 + randint(0, 60)), - original="Thread by a registered user.", - parsed="

Thread by a registered user.

", + content="Thread by a registered user.", + content_parsed="

Thread by a registered user.

", ), PostData( poster=random_deleted_user(), posted_at=timezone.now() - timedelta(minutes=100 + randint(0, 60)), - original="Reply by a deleted user.", - parsed="

Reply by a deleted user.

", + content="Reply by a deleted user.", + content_parsed="

Reply by a deleted user.

", ), ], ), @@ -494,15 +494,15 @@ def random_user(): poster=random_deleted_user(), posted_at=timezone.now() - timedelta(minutes=300 + randint(0, 60)), - original="Thread by a deleted user.", - parsed="

Thread by a deleted user.

", + content="Thread by a deleted user.", + content_parsed="

Thread by a deleted user.

", ), PostData( poster=random_registered_user(), posted_at=timezone.now() - timedelta(minutes=100 + randint(0, 60)), - original="Reply by a registered user.", - parsed="

Reply by a registered user.

", + content="Reply by a registered user.", + content_parsed="

Reply by a registered user.

", ), ], ), @@ -514,15 +514,15 @@ def random_user(): poster=random_deleted_user(), posted_at=timezone.now() - timedelta(minutes=300 + randint(0, 60)), - original="Original post.", - parsed="

Original post.

", + content="Original post.", + content_parsed="

Original post.

", ), PostData( poster=random_deleted_user(), posted_at=timezone.now() - timedelta(minutes=100 + randint(0, 60)), - original="Example reply.", - parsed="

Example reply.

", + content="Example reply.", + content_parsed="

Example reply.

", ), ], ), @@ -534,7 +534,7 @@ def random_user(): PostData( poster="Misago", posted_at=timezone.now(), - original=dedent( + content=dedent( """ This Misago site was pre-populated with some initial data to make starting development easier: @@ -581,7 +581,7 @@ def random_user(): - Password: `password` """ ).strip(), - parsed=( + content_parsed=( "

This Misago site was pre-populated with some initial data to make starting development easier:

" "
    " "
  • Example categories hierarchy
  • " @@ -644,8 +644,8 @@ def create_thread_with_specified_length(thread_length: int, title: str): PostData( poster=random_user(), posted_at=timestamp, - original=f"Post no. {i}", - parsed=f"

    Post no. {i}

    ", + content=f"Post no. {i}", + content_parsed=f"

    Post no. {i}

    ", ) ) @@ -735,8 +735,8 @@ def create_thread_with_specified_length(thread_length: int, title: str): poster=poster, poster_name=poster_name, posted_at=post_data.posted_at, - original=post_data.original, - parsed=post_data.parsed, + content=post_data.content, + content_parsed=post_data.content_parsed, is_locked=post_data.is_locked, is_hidden=post_data.is_hidden, is_unapproved=post_data.is_unapproved, @@ -746,7 +746,7 @@ def create_thread_with_specified_length(thread_length: int, title: str): hidden_by_slug=hidden_by_slug, ) - post.set_search_document(thread, post_data.original) + post.set_search_document(thread, post_data.content) post.set_search_vector() post.save() From 014735cebaa92c39d1da8cfd1893f10622732e8e Mon Sep 17 00:00:00 2001 From: rafalp Date: Tue, 11 Aug 2026 01:13:56 +0200 Subject: [PATCH 2/5] Rename post upgrading to post processing --- ....md => highlight-post-code-blocks-hook.md} | 22 ++--- .../hooks/post-needs-content-upgrade-hook.md | 83 ---------------- .../hooks/post-process-post-content-hook.md | 74 ++++++++++++++ dev-docs/plugins/hooks/reference.md | 6 +- .../should-post-process-post-content-hook.md | 85 ++++++++++++++++ .../hooks/upgrade-post-content-hook.md | 72 -------------- misago/posting/hooks/__init__.py | 12 +-- ...locks.py => highlight_post_code_blocks.py} | 29 +++--- .../hooks/post_needs_content_upgrade.py | 90 ----------------- ...ontent.py => post_process_post_content.py} | 32 +++---- .../hooks/should_post_process_post_content.py | 96 +++++++++++++++++++ .../{upgradepost.py => postprocess.py} | 32 ++++--- misago/posting/shortcuts.py | 10 +- misago/posting/state/base.py | 8 +- misago/posting/tasks.py | 10 +- ....py => test_highlight_post_code_blocks.py} | 30 +++--- .../tests/test_post_needs_content_upgrade.py | 19 ---- ...t.py => test_post_process_post_content.py} | 6 +- .../test_post_process_post_content_task.py | 43 +++++++++ .../test_should_post_process_post_content.py | 21 ++++ .../tests/test_upgrade_post_content_task.py | 41 -------- 21 files changed, 417 insertions(+), 404 deletions(-) rename dev-docs/plugins/hooks/{upgrade-post-code-blocks-hook.md => highlight-post-code-blocks-hook.md} (60%) delete mode 100644 dev-docs/plugins/hooks/post-needs-content-upgrade-hook.md create mode 100644 dev-docs/plugins/hooks/post-process-post-content-hook.md create mode 100644 dev-docs/plugins/hooks/should-post-process-post-content-hook.md delete mode 100644 dev-docs/plugins/hooks/upgrade-post-content-hook.md rename misago/posting/hooks/{upgrade_post_code_blocks.py => highlight_post_code_blocks.py} (60%) delete mode 100644 misago/posting/hooks/post_needs_content_upgrade.py rename misago/posting/hooks/{upgrade_post_content.py => post_process_post_content.py} (58%) create mode 100644 misago/posting/hooks/should_post_process_post_content.py rename misago/posting/{upgradepost.py => postprocess.py} (59%) rename misago/posting/tests/{test_upgrade_post_code_blocks.py => test_highlight_post_code_blocks.py} (75%) delete mode 100644 misago/posting/tests/test_post_needs_content_upgrade.py rename misago/posting/tests/{test_upgrade_post_content.py => test_post_process_post_content.py} (69%) create mode 100644 misago/posting/tests/test_post_process_post_content_task.py create mode 100644 misago/posting/tests/test_should_post_process_post_content.py delete mode 100644 misago/posting/tests/test_upgrade_post_content_task.py diff --git a/dev-docs/plugins/hooks/upgrade-post-code-blocks-hook.md b/dev-docs/plugins/hooks/highlight-post-code-blocks-hook.md similarity index 60% rename from dev-docs/plugins/hooks/upgrade-post-code-blocks-hook.md rename to dev-docs/plugins/hooks/highlight-post-code-blocks-hook.md index 52082bbb1a..e0f60bfd3a 100644 --- a/dev-docs/plugins/hooks/upgrade-post-code-blocks-hook.md +++ b/dev-docs/plugins/hooks/highlight-post-code-blocks-hook.md @@ -1,6 +1,6 @@ -# `upgrade_post_code_blocks_hook` +# `highlight_post_code_blocks_hook` -This hook wraps a standard Misago function used to upgrade a post's code blocks after it has been posted. +This hook wraps a standard Misago function used to highlight a post's code blocks after it has been saved. The standard code highlighting feature runs in a Celery task because Pygments can get stuck in an infinite loop due to unknown bugs or malicious input. @@ -10,15 +10,15 @@ The standard code highlighting feature runs in a Celery task because Pygments ca This hook can be imported from `misago.posting.hooks`: ```python -from misago.posting.hooks import upgrade_post_code_blocks_hook +from misago.posting.hooks import highlight_post_code_blocks_hook ``` ## Filter ```python -def custom_upgrade_post_code_blocks_filter( - action: UpgradePostCodeBlocksHookAction, post: Post +def custom_highlight_post_code_blocks_filter( + action: HighlightPostCodeBlocksHookAction, post: Post ): ... ``` @@ -41,11 +41,11 @@ The `Post` instance to update. ## Action ```python -def upgrade_post_code_blocks_action(post: Post): +def highlight_post_code_blocks_action(post: Post): ... ``` -Misago function used to upgrade a post's code blocks or the next filter function from another plugin. +Misago function used to highlight a post's code blocks after it has been saved. ### Arguments @@ -57,15 +57,15 @@ The `Post` instance to update. ## Example -The code below implements a custom filter function that highlights code using custom implementation: +The code below implements a custom filter function that highlights code using a custom implementation: ```python -from misago.posting.hooks import upgrade_post_code_blocks_hook +from misago.posting.hooks import highlight_post_code_blocks_hook from misago.threads.models import Post -@upgrade_post_code_blocks_hook.append_filter -def plugin_upgrade_post_code_blocks(action, post: Post): +@highlight_post_code_blocks_hook.append_filter +def plugin_highlight_post_code_blocks(action, post: Post): if post.metadata.get("highlight_code"): post.content_parsed = custom_highlight_code_util(post.content_parsed) post.metadata.pop("highlight_code") diff --git a/dev-docs/plugins/hooks/post-needs-content-upgrade-hook.md b/dev-docs/plugins/hooks/post-needs-content-upgrade-hook.md deleted file mode 100644 index 70682a10fc..0000000000 --- a/dev-docs/plugins/hooks/post-needs-content-upgrade-hook.md +++ /dev/null @@ -1,83 +0,0 @@ -# `post_needs_content_upgrade_hook` - -This hook wraps a standard Misago function used to check if post content needs an upgrade. - -If `True` is returned, a Celery task will be scheduled to upgrade the post content. - - -## Location - -This hook can be imported from `misago.posting.hooks`: - -```python -from misago.posting.hooks import post_needs_content_upgrade_hook -``` - - -## Filter - -```python -def custom_post_needs_content_upgrade_filter( - action: PostNeedsContentUpgradeHookAction, post: Post -) -> bool: - ... -``` - -A function implemented by a plugin that can be registered in this hook. - - -### Arguments - -The next function registered in this hook, either a custom function or Misago's default. - -See the [action](#action) section for details. - - -#### `post: Post` - -The `Post` instance to update. - - -### Return value - -Returns `bool` with `True` if post content needs upgrade. - - -## Action - -```python -def post_needs_content_upgrade_action(post: Post) -> bool: - ... -``` - -Misago function used to check if post content needs an upgrade. - - -### Arguments - -#### `post: Post` - -The `Post` instance to check. - - -### Return value - -Returns `bool` with `True` if post content needs upgrade. - - -## Example - -The code below implements a custom filter function that returns `True` if the post contains HTML markup that requires an upgrade. - -```python -from misago.posting.hooks import post_needs_content_upgrade_hook -from misago.threads.models import Post - - -@post_needs_content_upgrade_hook.append_filter -def post_needs_plugin_content_upgrade(action, post: Post) -> bool: - if " bool: + ... +``` + +A function implemented by a plugin that can be registered in this hook. + + +### Arguments + +#### `action: ShouldPostProcessPostContentHookAction` + +The next function registered in this hook, either a custom function or Misago's default. + +See the [action](#action) section for details. + + +#### `post: Post` + +The `Post` instance to check. + + +### Return value + +Returns `bool` with `True` if post content should be post-processed. + + +## Action + +```python +def should_post_process_post_content_action(post: Post) -> bool: + ... +``` + +Misago function used to determine whether post content should be post-processed. + + +### Arguments + +#### `post: Post` + +The `Post` instance to check. + + +### Return value + +Returns `bool` with `True` if post content should be post-processed. + + +## Example + +The code below implements a custom filter function that returns `True` if the post contains HTML markup that requires post-processing. + +```python +from misago.posting.hooks import should_post_process_post_content_hook +from misago.threads.models import Post + + +@should_post_process_post_content_hook.append_filter +def should_post_process_post_plugin_content(action, post: Post) -> bool: + if " bool: ... - - -class PostNeedsContentUpgradeHookFilter(Protocol): - """ - A function implemented by a plugin that can be registered in this hook. - - # Arguments - - The next function registered in this hook, either a custom function or - Misago's default. - - See the [action](#action) section for details. - - ## `post: Post` - - The `Post` instance to update. - - # Return value - - Returns `bool` with `True` if post content needs upgrade. - """ - - def __call__( - self, - action: PostNeedsContentUpgradeHookAction, - post: Post, - ) -> bool: ... - - -class PostNeedsContentUpgradeHook( - FilterHook[PostNeedsContentUpgradeHookAction, PostNeedsContentUpgradeHookFilter] -): - """ - This hook wraps a standard Misago function used to check if post content - needs an upgrade. - - If `True` is returned, a Celery task will be scheduled to upgrade the post content. - - # Example - - The code below implements a custom filter function that returns `True` - if the post contains HTML markup that requires an upgrade. - - ```python - from misago.posting.hooks import post_needs_content_upgrade_hook - from misago.threads.models import Post - - - @post_needs_content_upgrade_hook.append_filter - def post_needs_plugin_content_upgrade(action, post: Post) -> bool: - if " bool: - return super().__call__(action, post) - - -post_needs_content_upgrade_hook = PostNeedsContentUpgradeHook() diff --git a/misago/posting/hooks/upgrade_post_content.py b/misago/posting/hooks/post_process_post_content.py similarity index 58% rename from misago/posting/hooks/upgrade_post_content.py rename to misago/posting/hooks/post_process_post_content.py index 9f81755d41..5a5090592d 100644 --- a/misago/posting/hooks/upgrade_post_content.py +++ b/misago/posting/hooks/post_process_post_content.py @@ -4,9 +4,9 @@ from ...threads.models import Post -class UpgradePostContentHookAction(Protocol): +class PostProcessPostContentHookAction(Protocol): """ - Misago function used to upgrade post content or the next filter + Misago function used to post-process post content or the next filter function from another plugin. # Arguments @@ -19,7 +19,7 @@ class UpgradePostContentHookAction(Protocol): def __call__(self, post: Post): ... -class UpgradePostContentHookFilter(Protocol): +class PostProcessPostContentHookFilter(Protocol): """ A function implemented by a plugin that can be registered in this hook. @@ -35,32 +35,32 @@ class UpgradePostContentHookFilter(Protocol): The `Post` instance to update. """ - def __call__(self, action: UpgradePostContentHookAction, post: Post): ... + def __call__(self, action: PostProcessPostContentHookAction, post: Post): ... -class UpgradePostContentHook( - FilterHook[UpgradePostContentHookAction, UpgradePostContentHookFilter] +class PostProcessPostContentHook( + FilterHook[PostProcessPostContentHookAction, PostProcessPostContentHookFilter] ): """ - This hook wraps a standard Misago function used to upgrade post content - after it has been posted. + This hook wraps a standard Misago function used to post-process post content + after saving. - The upgrade process runs in a Celery task scheduled after the post is created, + The process runs in a Celery task scheduled after the post is created or updated, allowing slow and costly operations, such as embedding previews of linked sites, to be performed without slowing down the posting process. # Example - The code below implements a custom filter function that replaces custom - plugin's HTML with new version: + The code below implements a custom filter function that replaces a custom + plugin's HTML with a new version: ```python - from misago.posting.hooks import upgrade_post_content_hook + from misago.posting.hooks import post_process_post_content_hook from misago.threads.models import Post - @upgrade_post_content_hook.append_filter - def upgrade_post_plugin_html(action, post: Post): + @post_process_post_content_hook.append_filter + def enrich_post_plugin_html(action, post: Post): if " bool: ... + + +class ShouldPostProcessPostContentHookFilter(Protocol): + """ + A function implemented by a plugin that can be registered in this hook. + + # Arguments + + ## `action: ShouldPostProcessPostContentHookAction` + + The next function registered in this hook, either a custom function or + Misago's default. + + See the [action](#action) section for details. + + ## `post: Post` + + The `Post` instance to check. + + # Return value + + Returns `bool` with `True` if post content should be post-processed. + """ + + def __call__( + self, + action: ShouldPostProcessPostContentHookAction, + post: Post, + ) -> bool: ... + + +class ShouldPostProcessPostContentHook( + FilterHook[ + ShouldPostProcessPostContentHookAction, ShouldPostProcessPostContentHookFilter + ] +): + """ + This hook wraps a standard Misago function used to determine whether + post content should be post-processed. + + If True is returned, a Celery task will be scheduled to + post-process the post content. + + # Example + + The code below implements a custom filter function that returns `True` + if the post contains HTML markup that requires post-processing. + + ```python + from misago.posting.hooks import should_post_process_post_content_hook + from misago.threads.models import Post + + + @should_post_process_post_content_hook.append_filter + def should_post_process_post_plugin_content(action, post: Post) -> bool: + if " bool: + return super().__call__(action, post) + + +should_post_process_post_content_hook = ShouldPostProcessPostContentHook() diff --git a/misago/posting/upgradepost.py b/misago/posting/postprocess.py similarity index 59% rename from misago/posting/upgradepost.py rename to misago/posting/postprocess.py index 3cac278070..08b0163346 100644 --- a/misago/posting/upgradepost.py +++ b/misago/posting/postprocess.py @@ -4,29 +4,31 @@ from ..parser.highlighter import highlight_syntax from ..threads.models import Post from .hooks import ( - post_needs_content_upgrade_hook, - upgrade_post_code_blocks_hook, - upgrade_post_content_hook, + highlight_post_code_blocks_hook, + post_process_post_content_hook, + should_post_process_post_content_hook, ) -def post_needs_content_upgrade(post: Post) -> bool: - return post_needs_content_upgrade_hook(_post_needs_content_upgrade_action, post) +def should_post_process_post_content(post: Post) -> bool: + return should_post_process_post_content_hook( + _should_post_process_post_content_action, post + ) -def _post_needs_content_upgrade_action(post: Post) -> bool: +def _should_post_process_post_content_action(post: Post) -> bool: if post.metadata.get("highlight_code"): return True return False -def upgrade_post_content(post: Post): - upgrade_post_content_hook(_upgrade_post_content_action, post) +def post_process_post_content(post: Post): + post_process_post_content_hook(_post_process_post_content_action, post) -def _upgrade_post_content_action(post: Post): - upgrade_post_code_blocks(post) +def _post_process_post_content_action(post: Post): + highlight_post_code_blocks(post) CODE_BLOCK_PATTERN = re.compile( @@ -34,17 +36,17 @@ def _upgrade_post_content_action(post: Post): ) -def upgrade_post_code_blocks(post: Post): - upgrade_post_code_blocks_hook(_upgrade_post_code_blocks_action, post) +def highlight_post_code_blocks(post: Post): + highlight_post_code_blocks_hook(_highlight_post_code_blocks_action, post) -def _upgrade_post_code_blocks_action(post: Post): +def _highlight_post_code_blocks_action(post: Post): if "highlight_code" not in post.metadata: return if post.metadata["highlight_code"]: html = CODE_BLOCK_PATTERN.sub( - upgrade_post_code_blocks_syntax, post.content_parsed + highlight_post_code_blocks_syntax, post.content_parsed ) else: html = None @@ -58,7 +60,7 @@ def _upgrade_post_code_blocks_action(post: Post): post.save(update_fields=["metadata"]) -def upgrade_post_code_blocks_syntax(match) -> str: +def highlight_post_code_blocks_syntax(match) -> str: syntax: str | None = None code: str | None = None args = match.group("args") or "" diff --git a/misago/posting/shortcuts.py b/misago/posting/shortcuts.py index bb010f5cb0..52489a46e1 100644 --- a/misago/posting/shortcuts.py +++ b/misago/posting/shortcuts.py @@ -1,8 +1,6 @@ -from typing import Iterable - from ..threads.models import Post -from .tasks import upgrade_post_content -from .upgradepost import post_needs_content_upgrade +from .postprocess import should_post_process_post_content +from .tasks import post_process_post_content def save_edited_post(post: Post): @@ -11,5 +9,5 @@ def save_edited_post(post: Post): post.set_search_vector() post.save(update_fields=["search_vector"]) - if post_needs_content_upgrade(post): - upgrade_post_content.delay(post.id, post.sha256_checksum) + if should_post_process_post_content(post): + post_process_post_content.delay(post.id, post.sha256_checksum) diff --git a/misago/posting/state/base.py b/misago/posting/state/base.py index ba67ad269b..a06af1a14c 100644 --- a/misago/posting/state/base.py +++ b/misago/posting/state/base.py @@ -13,8 +13,8 @@ from ...parser.parse import ParsingResult from ...permissions.proxy import UserPermissionsProxy from ...threads.models import Post, Thread -from ..tasks import upgrade_post_content -from ..upgradepost import post_needs_content_upgrade +from ..postprocess import should_post_process_post_content +from ..tasks import post_process_post_content if TYPE_CHECKING: from ...users.models import User @@ -125,8 +125,8 @@ def set_post_message(self, parsing_result: ParsingResult): self.post.metadata = parsing_result.metadata def schedule_post_content_upgrade(self): - if post_needs_content_upgrade(self.post): - upgrade_post_content.delay(self.post.id, self.post.sha256_checksum) + if should_post_process_post_content(self.post): + post_process_post_content.delay(self.post.id, self.post.sha256_checksum) def set_attachments(self, attachments: list[Attachment]): self.attachments = attachments diff --git a/misago/posting/tasks.py b/misago/posting/tasks.py index 105d498e4d..72dcd4cad5 100644 --- a/misago/posting/tasks.py +++ b/misago/posting/tasks.py @@ -3,24 +3,24 @@ from celery import shared_task from ..threads.models import Post -from . import upgradepost +from . import postprocess logger = getLogger("misago.posting") @shared_task( - name="posting.upgrade-post-content", + name="posting.post-process-post-content", autoretry_for=(Post.DoesNotExist,), default_retry_delay=10, time_limit=20, serializer="json", ) -def upgrade_post_content(post_id: int, checksum: str): +def post_process_post_content(post_id: int, checksum: str): post = Post.objects.get(id=post_id) if post.sha256_checksum != checksum: return try: - upgradepost.upgrade_post_content(post) + postprocess.post_process_post_content(post) except Exception: - logger.exception("Unexpected error in 'upgrade_post_content'") + logger.exception("Unexpected error in 'post_process_post_content'") diff --git a/misago/posting/tests/test_upgrade_post_code_blocks.py b/misago/posting/tests/test_highlight_post_code_blocks.py similarity index 75% rename from misago/posting/tests/test_upgrade_post_code_blocks.py rename to misago/posting/tests/test_highlight_post_code_blocks.py index e7fff3bd81..3784a597d8 100644 --- a/misago/posting/tests/test_upgrade_post_code_blocks.py +++ b/misago/posting/tests/test_highlight_post_code_blocks.py @@ -1,15 +1,15 @@ from html import escape from ...html.element import html_element -from ..upgradepost import upgrade_post_code_blocks +from ..postprocess import highlight_post_code_blocks -def test_upgrade_post_code_blocks_upgrades_post_code(post): +def test_highlight_post_code_blocks_upgrades_post_code(post): post.content_parsed = html_element("misago-code", "add(1, 2)", {"syntax": "python"}) post.metadata["highlight_code"] = True post.save() - upgrade_post_code_blocks(post) + highlight_post_code_blocks(post) post.refresh_from_db() assert post.content_parsed.startswith('') @@ -18,14 +18,14 @@ def test_upgrade_post_code_blocks_upgrades_post_code(post): assert post.metadata == {} -def test_upgrade_post_code_blocks_upgrades_escaped_code(post): +def test_highlight_post_code_blocks_upgrades_escaped_code(post): post.content_parsed = html_element( "misago-code", escape('echo("")'), {"syntax": "php"} ) post.metadata["highlight_code"] = True post.save() - upgrade_post_code_blocks(post) + highlight_post_code_blocks(post) post.refresh_from_db() assert post.content_parsed.startswith('') @@ -35,14 +35,14 @@ def test_upgrade_post_code_blocks_upgrades_escaped_code(post): assert post.metadata == {} -def test_upgrade_post_code_blocks_upgrades_multiple_code_blocks(post): +def test_highlight_post_code_blocks_upgrades_multiple_code_blocks(post): post.content_parsed = html_element("misago-code", "add(1, 2)", {"syntax": "python"}) post.content_parsed += "

    Hello

    " post.content_parsed += html_element("misago-code", "add(1, 2)", {"syntax": "php"}) post.metadata["highlight_code"] = True post.save() - upgrade_post_code_blocks(post) + highlight_post_code_blocks(post) post.refresh_from_db() assert "

    Hello

    " in post.content_parsed @@ -50,14 +50,14 @@ def test_upgrade_post_code_blocks_upgrades_multiple_code_blocks(post): assert post.metadata == {} -def test_upgrade_post_code_blocks_handles_unsupported_syntax(post): +def test_highlight_post_code_blocks_handles_unsupported_syntax(post): post.content_parsed = html_element( "misago-code", "add(1, 2)", {"syntax": "invalid"} ) post.metadata["highlight_code"] = True post.save() - upgrade_post_code_blocks(post) + highlight_post_code_blocks(post) post.refresh_from_db() assert ( @@ -66,24 +66,24 @@ def test_upgrade_post_code_blocks_handles_unsupported_syntax(post): assert post.metadata == {} -def test_upgrade_post_code_blocks_handles_unspecified_syntax(post): +def test_highlight_post_code_blocks_handles_unspecified_syntax(post): post.content_parsed = html_element("misago-code", "add(1, 2)") post.metadata["highlight_code"] = True post.save() - upgrade_post_code_blocks(post) + highlight_post_code_blocks(post) post.refresh_from_db() assert post.content_parsed == "add(1, 2)" assert post.metadata == {} -def test_upgrade_post_code_blocks_skips_upgrade_if_metadata_flag_is_false(post): +def test_highlight_post_code_blocks_skips_upgrade_if_metadata_flag_is_false(post): post.content_parsed = html_element("misago-code", "add(1, 2)", {"syntax": "python"}) post.metadata["highlight_code"] = False post.save() - upgrade_post_code_blocks(post) + highlight_post_code_blocks(post) post.refresh_from_db() assert post.content_parsed == ( @@ -92,11 +92,11 @@ def test_upgrade_post_code_blocks_skips_upgrade_if_metadata_flag_is_false(post): assert post.metadata == {} -def test_upgrade_post_code_blocks_skips_upgrade_if_metadata_flag_is_not_set(post): +def test_highlight_post_code_blocks_skips_upgrade_if_metadata_flag_is_not_set(post): post.content_parsed = html_element("misago-code", "add(1, 2)", {"syntax": "python"}) post.save() - upgrade_post_code_blocks(post) + highlight_post_code_blocks(post) post.refresh_from_db() assert post.content_parsed == ( diff --git a/misago/posting/tests/test_post_needs_content_upgrade.py b/misago/posting/tests/test_post_needs_content_upgrade.py deleted file mode 100644 index 412065fa92..0000000000 --- a/misago/posting/tests/test_post_needs_content_upgrade.py +++ /dev/null @@ -1,19 +0,0 @@ -from ..upgradepost import post_needs_content_upgrade - - -def test_post_needs_content_upgrade_returns_true_if_post_has_code_to_highlight(post): - post.metadata["highlight_code"] = True - assert post_needs_content_upgrade(post) - - -def test_post_needs_content_upgrade_returns_false_if_post_has_no_code_to_highlight( - post, -): - post.metadata["highlight_code"] = False - assert not post_needs_content_upgrade(post) - - -def test_post_needs_content_upgrade_returns_false_if_post_metadata_has_no_highlight_code_entry( - post, -): - assert not post_needs_content_upgrade(post) diff --git a/misago/posting/tests/test_upgrade_post_content.py b/misago/posting/tests/test_post_process_post_content.py similarity index 69% rename from misago/posting/tests/test_upgrade_post_content.py rename to misago/posting/tests/test_post_process_post_content.py index 16919846e2..304fe51ced 100644 --- a/misago/posting/tests/test_upgrade_post_content.py +++ b/misago/posting/tests/test_post_process_post_content.py @@ -1,15 +1,15 @@ from ...html.element import html_element -from ..upgradepost import upgrade_post_content +from ..postprocess import post_process_post_content -def test_upgrade_post_content_upgrades_post_code(post): +def test_post_process_post_content_highlights_code(post): post.content_parsed = html_element( "misago-code", "
    add(1, 2)
    ", {"syntax": "python"} ) post.metadata["highlight_code"] = True post.save() - upgrade_post_content(post) + post_process_post_content(post) post.refresh_from_db() assert "span" in post.content_parsed diff --git a/misago/posting/tests/test_post_process_post_content_task.py b/misago/posting/tests/test_post_process_post_content_task.py new file mode 100644 index 0000000000..81c314a91e --- /dev/null +++ b/misago/posting/tests/test_post_process_post_content_task.py @@ -0,0 +1,43 @@ +import pytest + +from ...html.element import html_element +from ...threads.models import Post +from ..tasks import post_process_post_content + + +def test_post_process_post_content_task_raises_post_does_not_exist_for_invalid_post_id( + db, +): + with pytest.raises(Post.DoesNotExist): + post_process_post_content(1, "checksum") + + +def test_post_process_post_content_task_does_nothing_if_post_has_invalid_checksum(post): + post_process_post_content(post.id, "invalid-checksum") + + +def test_post_process_post_content_task_logs_exceptions(mocker, post): + mock_logger = mocker.patch("misago.posting.tasks.logger") + mock_post_process_post_content = mocker.patch( + "misago.posting.postprocess.post_process_post_content", + side_effect=ValueError(), + ) + + post_process_post_content(post.id, post.sha256_checksum) + + mock_logger.exception.assert_called_once() + mock_post_process_post_content.assert_called_once_with(post) + + +def test_post_process_post_content_task_highlights_post_code(post): + post.content_parsed = html_element( + "misago-code", "
    add(1, 2)
    ", {"syntax": "python"} + ) + post.metadata["highlight_code"] = True + post.save() + + post_process_post_content(post.id, post.sha256_checksum) + + post.refresh_from_db() + assert "span" in post.content_parsed + assert post.metadata == {} diff --git a/misago/posting/tests/test_should_post_process_post_content.py b/misago/posting/tests/test_should_post_process_post_content.py new file mode 100644 index 0000000000..0845f66154 --- /dev/null +++ b/misago/posting/tests/test_should_post_process_post_content.py @@ -0,0 +1,21 @@ +from ..postprocess import should_post_process_post_content + + +def test_should_post_process_post_content_returns_true_if_post_has_code_to_highlight( + post, +): + post.metadata["highlight_code"] = True + assert should_post_process_post_content(post) + + +def test_should_post_process_post_content_returns_false_if_post_has_no_code_to_highlight( + post, +): + post.metadata["highlight_code"] = False + assert not should_post_process_post_content(post) + + +def test_should_post_process_post_content_returns_false_if_post_metadata_has_no_highlight_code_entry( + post, +): + assert not should_post_process_post_content(post) diff --git a/misago/posting/tests/test_upgrade_post_content_task.py b/misago/posting/tests/test_upgrade_post_content_task.py deleted file mode 100644 index b3a6c0bdff..0000000000 --- a/misago/posting/tests/test_upgrade_post_content_task.py +++ /dev/null @@ -1,41 +0,0 @@ -import pytest - -from ...html.element import html_element -from ...threads.models import Post -from ..tasks import upgrade_post_content - - -def test_upgrade_post_content_task_raises_post_does_not_exist_for_invalid_post_id(db): - with pytest.raises(Post.DoesNotExist): - upgrade_post_content(1, "checksum") - - -def test_upgrade_post_content_task_does_nothing_if_post_has_invalid_checksum(post): - upgrade_post_content(post.id, "invalid-checksum") - - -def test_upgrade_post_content_task_logs_exceptions(mocker, post): - mock_logger = mocker.patch("misago.posting.tasks.logger") - mock_upgrade_post_content = mocker.patch( - "misago.posting.upgradepost.upgrade_post_content", - side_effect=ValueError(), - ) - - upgrade_post_content(post.id, post.sha256_checksum) - - mock_logger.exception.assert_called_once() - mock_upgrade_post_content.assert_called_once_with(post) - - -def test_upgrade_post_content_task_upgrades_post_code(post): - post.content_parsed = html_element( - "misago-code", "
    add(1, 2)
    ", {"syntax": "python"} - ) - post.metadata["highlight_code"] = True - post.save() - - upgrade_post_content(post.id, post.sha256_checksum) - - post.refresh_from_db() - assert "span" in post.content_parsed - assert post.metadata == {} From 2f40b4516be3a2b42ef4a38b9c83a8abb5598336 Mon Sep 17 00:00:00 2001 From: rafalp Date: Tue, 11 Aug 2026 01:30:02 +0200 Subject: [PATCH 3/5] Last minute name change --- ...t-hook.md => process-post-content-hook.md} | 18 ++++---- dev-docs/plugins/hooks/reference.md | 4 +- ...md => should-process-post-content-hook.md} | 28 ++++++------ misago/posting/hooks/__init__.py | 8 ++-- ...ost_content.py => process_post_content.py} | 22 +++++----- ...tent.py => should_process_post_content.py} | 34 +++++++-------- .../{postprocess.py => processcontent.py} | 18 ++++---- misago/posting/shortcuts.py | 8 ++-- misago/posting/state/base.py | 8 ++-- misago/posting/tasks.py | 10 ++--- misago/posting/tests/conftest.py | 4 +- .../tests/test_highlight_post_code_blocks.py | 2 +- misago/posting/tests/test_post_edit_state.py | 4 +- .../test_post_process_post_content_task.py | 43 ------------------- ...ontent.py => test_process_post_content.py} | 6 +-- .../tests/test_process_post_content_task.py | 43 +++++++++++++++++++ misago/posting/tests/test_reply_state.py | 4 +- .../test_should_post_process_post_content.py | 21 --------- .../tests/test_should_process_post_content.py | 21 +++++++++ misago/posting/tests/test_start_state.py | 4 +- 20 files changed, 152 insertions(+), 158 deletions(-) rename dev-docs/plugins/hooks/{post-process-post-content-hook.md => process-post-content-hook.md} (67%) rename dev-docs/plugins/hooks/{should-post-process-post-content-hook.md => should-process-post-content-hook.md} (54%) rename misago/posting/hooks/{post_process_post_content.py => process_post_content.py} (68%) rename misago/posting/hooks/{should_post_process_post_content.py => should_process_post_content.py} (58%) rename misago/posting/{postprocess.py => processcontent.py} (76%) delete mode 100644 misago/posting/tests/test_post_process_post_content_task.py rename misago/posting/tests/{test_post_process_post_content.py => test_process_post_content.py} (69%) create mode 100644 misago/posting/tests/test_process_post_content_task.py delete mode 100644 misago/posting/tests/test_should_post_process_post_content.py create mode 100644 misago/posting/tests/test_should_process_post_content.py diff --git a/dev-docs/plugins/hooks/post-process-post-content-hook.md b/dev-docs/plugins/hooks/process-post-content-hook.md similarity index 67% rename from dev-docs/plugins/hooks/post-process-post-content-hook.md rename to dev-docs/plugins/hooks/process-post-content-hook.md index 822f937f3f..d5e79a019b 100644 --- a/dev-docs/plugins/hooks/post-process-post-content-hook.md +++ b/dev-docs/plugins/hooks/process-post-content-hook.md @@ -1,6 +1,6 @@ -# `post_process_post_content_hook` +# `process_post_content_hook` -This hook wraps a standard Misago function used to post-process post content after saving. +This hook wraps a standard Misago function used to process post content after saving. The process runs in a Celery task scheduled after the post is created or updated, allowing slow and costly operations, such as embedding previews of linked sites, to be performed without slowing down the posting process. @@ -10,16 +10,14 @@ The process runs in a Celery task scheduled after the post is created or updated This hook can be imported from `misago.posting.hooks`: ```python -from misago.posting.hooks import post_process_post_content_hook +from misago.posting.hooks import process_post_content_hook ``` ## Filter ```python -def custom_post_process_post_content_filter( - action: PostProcessPostContentHookAction, post: Post -): +def custom_process_post_content_filter(action: ProcessPostContentHookAction, post: Post): ... ``` @@ -41,11 +39,11 @@ The `Post` instance to update. ## Action ```python -def post_process_post_content_action(post: Post): +def process_post_content_action(post: Post): ... ``` -Misago function used to post-process post content or the next filter function from another plugin. +Misago function used to process post content or the next filter function from another plugin. ### Arguments @@ -60,11 +58,11 @@ The `Post` instance to update. The code below implements a custom filter function that replaces a custom plugin's HTML with a new version: ```python -from misago.posting.hooks import post_process_post_content_hook +from misago.posting.hooks import process_post_content_hook from misago.threads.models import Post -@post_process_post_content_hook.append_filter +@process_post_content_hook.append_filter def enrich_post_plugin_html(action, post: Post): if " bool: ... ``` @@ -28,7 +28,7 @@ A function implemented by a plugin that can be registered in this hook. ### Arguments -#### `action: ShouldPostProcessPostContentHookAction` +#### `action: ShouldProcessPostContentHookAction` The next function registered in this hook, either a custom function or Misago's default. @@ -42,17 +42,17 @@ The `Post` instance to check. ### Return value -Returns `bool` with `True` if post content should be post-processed. +Returns `bool` with `True` if post content should be processed. ## Action ```python -def should_post_process_post_content_action(post: Post) -> bool: +def should_process_post_content_action(post: Post) -> bool: ... ``` -Misago function used to determine whether post content should be post-processed. +Misago function used to determine whether post content should be processed. ### Arguments @@ -64,19 +64,19 @@ The `Post` instance to check. ### Return value -Returns `bool` with `True` if post content should be post-processed. +Returns `bool` with `True` if post content should be processed. ## Example -The code below implements a custom filter function that returns `True` if the post contains HTML markup that requires post-processing. +The code below implements a custom filter function that returns `True` if the post contains HTML markup that requires processing. ```python -from misago.posting.hooks import should_post_process_post_content_hook +from misago.posting.hooks import should_process_post_content_hook from misago.threads.models import Post -@should_post_process_post_content_hook.append_filter +@should_process_post_content_hook.append_filter def should_post_process_post_plugin_content(action, post: Post) -> bool: if " bool: ... -class ShouldPostProcessPostContentHookFilter(Protocol): +class ShouldProcessPostContentHookFilter(Protocol): """ A function implemented by a plugin that can be registered in this hook. # Arguments - ## `action: ShouldPostProcessPostContentHookAction` + ## `action: ShouldProcessPostContentHookAction` The next function registered in this hook, either a custom function or Misago's default. @@ -42,39 +42,37 @@ class ShouldPostProcessPostContentHookFilter(Protocol): # Return value - Returns `bool` with `True` if post content should be post-processed. + Returns `bool` with `True` if post content should be processed. """ def __call__( self, - action: ShouldPostProcessPostContentHookAction, + action: ShouldProcessPostContentHookAction, post: Post, ) -> bool: ... -class ShouldPostProcessPostContentHook( - FilterHook[ - ShouldPostProcessPostContentHookAction, ShouldPostProcessPostContentHookFilter - ] +class ShouldProcessPostContentHook( + FilterHook[ShouldProcessPostContentHookAction, ShouldProcessPostContentHookFilter] ): """ This hook wraps a standard Misago function used to determine whether - post content should be post-processed. + post content should be processed. If True is returned, a Celery task will be scheduled to - post-process the post content. + process the post content. # Example The code below implements a custom filter function that returns `True` - if the post contains HTML markup that requires post-processing. + if the post contains HTML markup that requires processing. ```python - from misago.posting.hooks import should_post_process_post_content_hook + from misago.posting.hooks import should_process_post_content_hook from misago.threads.models import Post - @should_post_process_post_content_hook.append_filter + @should_process_post_content_hook.append_filter def should_post_process_post_plugin_content(action, post: Post) -> bool: if " bool: def __call__( self, - action: ShouldPostProcessPostContentHookAction, + action: ShouldProcessPostContentHookAction, post: Post, ) -> bool: return super().__call__(action, post) -should_post_process_post_content_hook = ShouldPostProcessPostContentHook() +should_process_post_content_hook = ShouldProcessPostContentHook() diff --git a/misago/posting/postprocess.py b/misago/posting/processcontent.py similarity index 76% rename from misago/posting/postprocess.py rename to misago/posting/processcontent.py index 08b0163346..5356ded6fc 100644 --- a/misago/posting/postprocess.py +++ b/misago/posting/processcontent.py @@ -5,29 +5,27 @@ from ..threads.models import Post from .hooks import ( highlight_post_code_blocks_hook, - post_process_post_content_hook, - should_post_process_post_content_hook, + process_post_content_hook, + should_process_post_content_hook, ) -def should_post_process_post_content(post: Post) -> bool: - return should_post_process_post_content_hook( - _should_post_process_post_content_action, post - ) +def should_process_post_content(post: Post) -> bool: + return should_process_post_content_hook(_should_process_post_content_action, post) -def _should_post_process_post_content_action(post: Post) -> bool: +def _should_process_post_content_action(post: Post) -> bool: if post.metadata.get("highlight_code"): return True return False -def post_process_post_content(post: Post): - post_process_post_content_hook(_post_process_post_content_action, post) +def process_post_content(post: Post): + process_post_content_hook(_process_post_content_action, post) -def _post_process_post_content_action(post: Post): +def _process_post_content_action(post: Post): highlight_post_code_blocks(post) diff --git a/misago/posting/shortcuts.py b/misago/posting/shortcuts.py index 52489a46e1..91f31efe7a 100644 --- a/misago/posting/shortcuts.py +++ b/misago/posting/shortcuts.py @@ -1,6 +1,6 @@ from ..threads.models import Post -from .postprocess import should_post_process_post_content -from .tasks import post_process_post_content +from .processcontent import should_process_post_content +from .tasks import process_post_content def save_edited_post(post: Post): @@ -9,5 +9,5 @@ def save_edited_post(post: Post): post.set_search_vector() post.save(update_fields=["search_vector"]) - if should_post_process_post_content(post): - post_process_post_content.delay(post.id, post.sha256_checksum) + if should_process_post_content(post): + process_post_content.delay(post.id, post.sha256_checksum) diff --git a/misago/posting/state/base.py b/misago/posting/state/base.py index a06af1a14c..c215ac09b3 100644 --- a/misago/posting/state/base.py +++ b/misago/posting/state/base.py @@ -13,8 +13,8 @@ from ...parser.parse import ParsingResult from ...permissions.proxy import UserPermissionsProxy from ...threads.models import Post, Thread -from ..postprocess import should_post_process_post_content -from ..tasks import post_process_post_content +from ..processcontent import should_process_post_content +from ..tasks import process_post_content if TYPE_CHECKING: from ...users.models import User @@ -125,8 +125,8 @@ def set_post_message(self, parsing_result: ParsingResult): self.post.metadata = parsing_result.metadata def schedule_post_content_upgrade(self): - if should_post_process_post_content(self.post): - post_process_post_content.delay(self.post.id, self.post.sha256_checksum) + if should_process_post_content(self.post): + process_post_content.delay(self.post.id, self.post.sha256_checksum) def set_attachments(self, attachments: list[Attachment]): self.attachments = attachments diff --git a/misago/posting/tasks.py b/misago/posting/tasks.py index 72dcd4cad5..dc1dd89e29 100644 --- a/misago/posting/tasks.py +++ b/misago/posting/tasks.py @@ -3,24 +3,24 @@ from celery import shared_task from ..threads.models import Post -from . import postprocess +from . import processcontent logger = getLogger("misago.posting") @shared_task( - name="posting.post-process-post-content", + name="posting.process-post-content", autoretry_for=(Post.DoesNotExist,), default_retry_delay=10, time_limit=20, serializer="json", ) -def post_process_post_content(post_id: int, checksum: str): +def process_post_content(post_id: int, checksum: str): post = Post.objects.get(id=post_id) if post.sha256_checksum != checksum: return try: - postprocess.post_process_post_content(post) + processcontent.process_post_content(post) except Exception: - logger.exception("Unexpected error in 'post_process_post_content'") + logger.exception("Unexpected error in 'process_post_content'") diff --git a/misago/posting/tests/conftest.py b/misago/posting/tests/conftest.py index 912b0a09fb..05f79ff533 100644 --- a/misago/posting/tests/conftest.py +++ b/misago/posting/tests/conftest.py @@ -11,8 +11,8 @@ def mock_notify_on_new_thread_reply(mocker): @pytest.fixture -def mock_upgrade_post_content(mocker): - return mocker.patch("misago.posting.state.base.upgrade_post_content") +def mock_process_post_content(mocker): + return mocker.patch("misago.posting.state.base.process_post_content") @pytest.fixture diff --git a/misago/posting/tests/test_highlight_post_code_blocks.py b/misago/posting/tests/test_highlight_post_code_blocks.py index 3784a597d8..56ead4a6c4 100644 --- a/misago/posting/tests/test_highlight_post_code_blocks.py +++ b/misago/posting/tests/test_highlight_post_code_blocks.py @@ -1,7 +1,7 @@ from html import escape from ...html.element import html_element -from ..postprocess import highlight_post_code_blocks +from ..processcontent import highlight_post_code_blocks def test_highlight_post_code_blocks_upgrades_post_code(post): diff --git a/misago/posting/tests/test_post_edit_state.py b/misago/posting/tests/test_post_edit_state.py index 7e60ab3af7..f030f82be8 100644 --- a/misago/posting/tests/test_post_edit_state.py +++ b/misago/posting/tests/test_post_edit_state.py @@ -123,7 +123,7 @@ def test_post_edit_state_save_deletes_unused_attachments( def test_post_edit_state_schedules_post_upgrade_for_post_with_code_block( - mock_upgrade_post_content, user_request, other_user_thread + mock_process_post_content, user_request, other_user_thread ): state = PostEditState(user_request, other_user_thread.first_post) state.set_post_message(parse("Hello world\n[code=python]add(1, 3)[/code]")) @@ -132,7 +132,7 @@ def test_post_edit_state_schedules_post_upgrade_for_post_with_code_block( assert state.post.id assert state.post.thread == state.thread - mock_upgrade_post_content.delay.assert_called_once_with( + mock_process_post_content.delay.assert_called_once_with( state.post.id, state.post.sha256_checksum ) diff --git a/misago/posting/tests/test_post_process_post_content_task.py b/misago/posting/tests/test_post_process_post_content_task.py deleted file mode 100644 index 81c314a91e..0000000000 --- a/misago/posting/tests/test_post_process_post_content_task.py +++ /dev/null @@ -1,43 +0,0 @@ -import pytest - -from ...html.element import html_element -from ...threads.models import Post -from ..tasks import post_process_post_content - - -def test_post_process_post_content_task_raises_post_does_not_exist_for_invalid_post_id( - db, -): - with pytest.raises(Post.DoesNotExist): - post_process_post_content(1, "checksum") - - -def test_post_process_post_content_task_does_nothing_if_post_has_invalid_checksum(post): - post_process_post_content(post.id, "invalid-checksum") - - -def test_post_process_post_content_task_logs_exceptions(mocker, post): - mock_logger = mocker.patch("misago.posting.tasks.logger") - mock_post_process_post_content = mocker.patch( - "misago.posting.postprocess.post_process_post_content", - side_effect=ValueError(), - ) - - post_process_post_content(post.id, post.sha256_checksum) - - mock_logger.exception.assert_called_once() - mock_post_process_post_content.assert_called_once_with(post) - - -def test_post_process_post_content_task_highlights_post_code(post): - post.content_parsed = html_element( - "misago-code", "
    add(1, 2)
    ", {"syntax": "python"} - ) - post.metadata["highlight_code"] = True - post.save() - - post_process_post_content(post.id, post.sha256_checksum) - - post.refresh_from_db() - assert "span" in post.content_parsed - assert post.metadata == {} diff --git a/misago/posting/tests/test_post_process_post_content.py b/misago/posting/tests/test_process_post_content.py similarity index 69% rename from misago/posting/tests/test_post_process_post_content.py rename to misago/posting/tests/test_process_post_content.py index 304fe51ced..82092cdd76 100644 --- a/misago/posting/tests/test_post_process_post_content.py +++ b/misago/posting/tests/test_process_post_content.py @@ -1,15 +1,15 @@ from ...html.element import html_element -from ..postprocess import post_process_post_content +from ..processcontent import process_post_content -def test_post_process_post_content_highlights_code(post): +def test_process_post_content_highlights_code(post): post.content_parsed = html_element( "misago-code", "
    add(1, 2)
    ", {"syntax": "python"} ) post.metadata["highlight_code"] = True post.save() - post_process_post_content(post) + process_post_content(post) post.refresh_from_db() assert "span" in post.content_parsed diff --git a/misago/posting/tests/test_process_post_content_task.py b/misago/posting/tests/test_process_post_content_task.py new file mode 100644 index 0000000000..468d8a29cb --- /dev/null +++ b/misago/posting/tests/test_process_post_content_task.py @@ -0,0 +1,43 @@ +import pytest + +from ...html.element import html_element +from ...threads.models import Post +from ..tasks import process_post_content + + +def test_process_post_content_task_raises_post_does_not_exist_for_invalid_post_id( + db, +): + with pytest.raises(Post.DoesNotExist): + process_post_content(1, "checksum") + + +def test_process_post_content_task_does_nothing_if_post_has_invalid_checksum(post): + process_post_content(post.id, "invalid-checksum") + + +def test_process_post_content_task_logs_exceptions(mocker, post): + mock_logger = mocker.patch("misago.posting.tasks.logger") + mock_process_post_content = mocker.patch( + "misago.posting.processcontent.process_post_content", + side_effect=ValueError(), + ) + + process_post_content(post.id, post.sha256_checksum) + + mock_logger.exception.assert_called_once() + mock_process_post_content.assert_called_once_with(post) + + +def test_process_post_content_task_highlights_post_code(post): + post.content_parsed = html_element( + "misago-code", "
    add(1, 2)
    ", {"syntax": "python"} + ) + post.metadata["highlight_code"] = True + post.save() + + process_post_content(post.id, post.sha256_checksum) + + post.refresh_from_db() + assert "span" in post.content_parsed + assert post.metadata == {} diff --git a/misago/posting/tests/test_reply_state.py b/misago/posting/tests/test_reply_state.py index 5ef00c266e..701e0593e0 100644 --- a/misago/posting/tests/test_reply_state.py +++ b/misago/posting/tests/test_reply_state.py @@ -168,7 +168,7 @@ def test_reply_state_updates_existing_post_attachments( def test_reply_state_schedules_post_upgrade_for_post_with_code_block( - mock_upgrade_post_content, user_request, other_user_thread + mock_process_post_content, user_request, other_user_thread ): state = ReplyState(user_request, other_user_thread) state.set_post_message(parse("Hello world\n[code=python]add(1, 3)[/code]")) @@ -177,6 +177,6 @@ def test_reply_state_schedules_post_upgrade_for_post_with_code_block( assert state.post.id assert state.post.thread == state.thread - mock_upgrade_post_content.delay.assert_called_once_with( + mock_process_post_content.delay.assert_called_once_with( state.post.id, state.post.sha256_checksum ) diff --git a/misago/posting/tests/test_should_post_process_post_content.py b/misago/posting/tests/test_should_post_process_post_content.py deleted file mode 100644 index 0845f66154..0000000000 --- a/misago/posting/tests/test_should_post_process_post_content.py +++ /dev/null @@ -1,21 +0,0 @@ -from ..postprocess import should_post_process_post_content - - -def test_should_post_process_post_content_returns_true_if_post_has_code_to_highlight( - post, -): - post.metadata["highlight_code"] = True - assert should_post_process_post_content(post) - - -def test_should_post_process_post_content_returns_false_if_post_has_no_code_to_highlight( - post, -): - post.metadata["highlight_code"] = False - assert not should_post_process_post_content(post) - - -def test_should_post_process_post_content_returns_false_if_post_metadata_has_no_highlight_code_entry( - post, -): - assert not should_post_process_post_content(post) diff --git a/misago/posting/tests/test_should_process_post_content.py b/misago/posting/tests/test_should_process_post_content.py new file mode 100644 index 0000000000..0539ef76e9 --- /dev/null +++ b/misago/posting/tests/test_should_process_post_content.py @@ -0,0 +1,21 @@ +from ..processcontent import should_process_post_content + + +def test_should_process_post_content_returns_true_if_post_has_code_to_highlight( + post, +): + post.metadata["highlight_code"] = True + assert should_process_post_content(post) + + +def test_should_process_post_content_returns_false_if_post_has_no_code_to_highlight( + post, +): + post.metadata["highlight_code"] = False + assert not should_process_post_content(post) + + +def test_should_process_post_content_returns_false_if_post_metadata_has_no_highlight_code_entry( + post, +): + assert not should_process_post_content(post) diff --git a/misago/posting/tests/test_start_state.py b/misago/posting/tests/test_start_state.py index b2e8290bd6..16f03f6783 100644 --- a/misago/posting/tests/test_start_state.py +++ b/misago/posting/tests/test_start_state.py @@ -152,7 +152,7 @@ def test_start_state_delete_attachments_excludes_unknown_attachments( def test_start_state_schedules_post_upgrade_for_post_with_code_block( - mock_upgrade_post_content, user_request, default_category + mock_process_post_content, user_request, default_category ): state = StartState(user_request, default_category) state.set_thread_title("Test thread") @@ -164,6 +164,6 @@ def test_start_state_schedules_post_upgrade_for_post_with_code_block( assert state.post.id assert state.post.thread == state.thread - mock_upgrade_post_content.delay.assert_called_once_with( + mock_process_post_content.delay.assert_called_once_with( state.post.id, state.post.sha256_checksum ) From c1e85021e762f3dde2db3444d35fed5fdc9af01e Mon Sep 17 00:00:00 2001 From: rafalp Date: Tue, 11 Aug 2026 02:03:51 +0200 Subject: [PATCH 4/5] Rename validate_posted_contents to validate_posting --- dev-docs/plugins/hooks/reference.md | 2 +- ...tents-hook.md => validate-posting-hook.md} | 24 ++++++------ misago/posting/hooks/__init__.py | 4 +- ...posted_contents.py => validate_posting.py} | 30 +++++++-------- misago/posting/tests/conftest.py | 6 +-- ...d_contents.py => test_validate_posting.py} | 38 +++++++++---------- misago/posting/validators.py | 8 ++-- misago/posting/views/edit.py | 4 +- misago/posting/views/reply.py | 4 +- misago/posting/views/start.py | 4 +- misago/threads/tests/conftest.py | 2 +- 11 files changed, 61 insertions(+), 65 deletions(-) rename dev-docs/plugins/hooks/{validate-posted-contents-hook.md => validate-posting-hook.md} (52%) rename misago/posting/hooks/{validate_posted_contents.py => validate_posting.py} (63%) rename misago/posting/tests/{test_validate_posted_contents.py => test_validate_posting.py} (63%) diff --git a/dev-docs/plugins/hooks/reference.md b/dev-docs/plugins/hooks/reference.md index 5839de7866..94d17e9af0 100644 --- a/dev-docs/plugins/hooks/reference.md +++ b/dev-docs/plugins/hooks/reference.md @@ -244,7 +244,7 @@ Hooks instances are importable from the following Python modules: - [`save_thread_start_state_hook`](./save-thread-start-state-hook.md) - [`should_process_post_content_hook`](./should-process-post-content-hook.md) - [`validate_post_hook`](./validate-post-hook.md) -- [`validate_posted_contents_hook`](./validate-posted-contents-hook.md) +- [`validate_posting_hook`](./validate-posting-hook.md) - [`validate_thread_title_hook`](./validate-thread-title-hook.md) diff --git a/dev-docs/plugins/hooks/validate-posted-contents-hook.md b/dev-docs/plugins/hooks/validate-posting-hook.md similarity index 52% rename from dev-docs/plugins/hooks/validate-posted-contents-hook.md rename to dev-docs/plugins/hooks/validate-posting-hook.md index 04f9d049cf..bf309823a6 100644 --- a/dev-docs/plugins/hooks/validate-posted-contents-hook.md +++ b/dev-docs/plugins/hooks/validate-posting-hook.md @@ -1,6 +1,6 @@ -# `validate_posted_contents_hook` +# `validate_posting_hook` -This hook enables plugins to run additional validation against posted contents. +This hook enables plugins to perform additional validation of the posting formset and state. ## Location @@ -8,48 +8,48 @@ This hook enables plugins to run additional validation against posted contents. This hook can be imported from `misago.posting.hooks`: ```python -from misago.posting.hooks import validate_posted_contents_hook +from misago.posting.hooks import validate_posting_hook ``` ## Action ```python -def custom_validate_posted_contents_filter( +def custom_validate_posting_filter( formset: Union['Formset', 'TabbedFormset'], state: 'State' ): ... ``` -A function that Misago uses to run additional validation against user-posted contents. +A function that Misago uses to perform additional validation of a posting. -It should either do nothing, raise `ValidationError`, or add one or more `ValidationError` instances to `formset` calling it's `add_error(ValidationError)` method, +It should either do nothing, raise a `ValidationError`, or add one or more `ValidationError` instances to formset by calling its `add_error()` method. ### Arguments #### `formset: Formset` -An instance of the `Formset` subclass specific to the posted contents. +An instance of the `Formset` subclass specific to the posting. #### `state: State` -An instance of the `State` subclass specific to the posted contents. +An instance of the `State` subclass specific to the posting. ## Example -The code below implements a custom validator that ch +The code below implements custom anti-spam validation that checks both the thread title and post content. ```python from django.core.exceptions import ValidationError from misago.posting.forms.title import PREFIX as THREAD_TITLE_FORM -from misago.posting.hooks import validate_posted_contents_hook +from misago.posting.hooks import validate_posting_hook -@validate_posted_contents_hook.append_action -def validate_posted_contents_are_not_spam(formset, state): +@validate_posting_hook.append_action +def validate_posting_are_not_spam(formset, state): # Exclude moderators from the check if state.request.user_permissions.is_category_moderator(state.category.id): return diff --git a/misago/posting/hooks/__init__.py b/misago/posting/hooks/__init__.py index a95e6f3473..917da8c35f 100644 --- a/misago/posting/hooks/__init__.py +++ b/misago/posting/hooks/__init__.py @@ -38,7 +38,7 @@ from .save_thread_start_state import save_thread_start_state_hook from .should_process_post_content import should_process_post_content_hook from .validate_post import validate_post_hook -from .validate_posted_contents import validate_posted_contents_hook +from .validate_posting import validate_posting_hook from .validate_thread_title import validate_thread_title_hook __all__ = [ @@ -70,6 +70,6 @@ "save_thread_start_state_hook", "should_process_post_content_hook", "validate_post_hook", - "validate_posted_contents_hook", + "validate_posting_hook", "validate_thread_title_hook", ] diff --git a/misago/posting/hooks/validate_posted_contents.py b/misago/posting/hooks/validate_posting.py similarity index 63% rename from misago/posting/hooks/validate_posted_contents.py rename to misago/posting/hooks/validate_posting.py index 05f79e0eae..2201029f1a 100644 --- a/misago/posting/hooks/validate_posted_contents.py +++ b/misago/posting/hooks/validate_posting.py @@ -9,45 +9,45 @@ from ..state import State -class ValidatePostedContentsHookAction(Protocol): +class ValidatePostingHookAction(Protocol): """ - A function that Misago uses to run additional validation against user-posted - contents. + A function that Misago uses to perform additional validation of a posting. - It should either do nothing, raise `ValidationError`, or add one or more - `ValidationError` instances to `formset` calling it's `add_error(ValidationError)` - method, + It should either do nothing, raise a `ValidationError`, or add one or more + `ValidationError` instances to formset by calling its `add_error()` method. # Arguments ## `formset: Formset` - An instance of the `Formset` subclass specific to the posted contents. + An instance of the `Formset` subclass specific to the posting. ## `state: State` - An instance of the `State` subclass specific to the posted contents. + An instance of the `State` subclass specific to the posting. """ def __call__(self, formset: Union["Formset", "TabbedFormset"], state: "State"): ... -class ValidatePostedContentsHook(ActionHook[ValidatePostedContentsHookAction]): +class ValidatePostingHook(ActionHook[ValidatePostingHookAction]): """ - This hook enables plugins to run additional validation against posted contents. + This hook enables plugins to perform additional validation + of the posting formset and state. # Example - The code below implements a custom validator that ch + The code below implements custom anti-spam validation + that checks both the thread title and post content. ```python from django.core.exceptions import ValidationError from misago.posting.forms.title import PREFIX as THREAD_TITLE_FORM - from misago.posting.hooks import validate_posted_contents_hook + from misago.posting.hooks import validate_posting_hook - @validate_posted_contents_hook.append_action - def validate_posted_contents_are_not_spam(formset, state): + @validate_posting_hook.append_action + def validate_posting_are_not_spam(formset, state): # Exclude moderators from the check if state.request.user_permissions.is_category_moderator(state.category.id): return @@ -86,4 +86,4 @@ def __call__(self, formset: Union["Formset", "TabbedFormset"], state: "State"): formset.add_error(e) -validate_posted_contents_hook = ValidatePostedContentsHook() +validate_posting_hook = ValidatePostingHook() diff --git a/misago/posting/tests/conftest.py b/misago/posting/tests/conftest.py index 05f79ff533..c1cd0be27c 100644 --- a/misago/posting/tests/conftest.py +++ b/misago/posting/tests/conftest.py @@ -2,7 +2,7 @@ from django.core.exceptions import ValidationError from ...permissions.proxy import UserPermissionsProxy -from ..hooks import validate_posted_contents_hook +from ..hooks import validate_posting_hook @pytest.fixture @@ -29,9 +29,9 @@ def user_request(rf, cache_versions, dynamic_settings, user): @pytest.fixture def posted_contents_validator(): - validate_posted_contents_hook.append_action(validate_spam_contents) + validate_posting_hook.append_action(validate_spam_contents) yield - validate_posted_contents_hook.clear_actions() + validate_posting_hook.clear_actions() def validate_spam_contents(formset, state): diff --git a/misago/posting/tests/test_validate_posted_contents.py b/misago/posting/tests/test_validate_posting.py similarity index 63% rename from misago/posting/tests/test_validate_posted_contents.py rename to misago/posting/tests/test_validate_posting.py index 80d2769048..1474c5721c 100644 --- a/misago/posting/tests/test_validate_posted_contents.py +++ b/misago/posting/tests/test_validate_posting.py @@ -16,68 +16,64 @@ ThreadReplyState, ThreadStartState, ) -from ..validators import validate_posted_contents +from ..validators import validate_posting -def test_validate_posted_contents_validates_new_thread(user_request, default_category): +def test_validate_posting_validates_new_thread(user_request, default_category): formset = get_thread_start_formset(user_request, default_category) state = ThreadStartState(user_request, default_category) - assert validate_posted_contents(formset, state) + assert validate_posting(formset, state) -def test_validate_posted_contents_validates_new_private_thread( +def test_validate_posting_validates_new_private_thread( user_request, private_threads_category ): formset = get_private_thread_start_formset(user_request, private_threads_category) state = PrivateThreadStartState(user_request, private_threads_category) - assert validate_posted_contents(formset, state) + assert validate_posting(formset, state) -def test_validate_posted_contents_validates_new_thread_reply( - user_request, other_user_thread -): +def test_validate_posting_validates_new_thread_reply(user_request, other_user_thread): formset = get_thread_reply_formset(user_request, other_user_thread) state = ThreadReplyState(user_request, other_user_thread) - assert validate_posted_contents(formset, state) + assert validate_posting(formset, state) -def test_validate_posted_contents_validates_new_private_thread_reply( +def test_validate_posting_validates_new_private_thread_reply( user_request, user_private_thread ): formset = get_private_thread_reply_formset(user_request, user_private_thread) state = PrivateThreadReplyState(user_request, user_private_thread) - assert validate_posted_contents(formset, state) + assert validate_posting(formset, state) -def test_validate_posted_contents_validates_edited_thread(user_request, user_thread): +def test_validate_posting_validates_edited_thread(user_request, user_thread): formset = get_thread_edit_formset(user_request, user_thread.first_post) state = ThreadPostEditState(user_request, user_thread.first_post) - assert validate_posted_contents(formset, state) + assert validate_posting(formset, state) -def test_validate_posted_contents_validates_edited_private_thread( +def test_validate_posting_validates_edited_private_thread( user_request, user_private_thread ): formset = get_private_thread_edit_formset( user_request, user_private_thread.first_post ) state = PrivateThreadPostEditState(user_request, user_private_thread.first_post) - assert validate_posted_contents(formset, state) + assert validate_posting(formset, state) -def test_validate_posted_contents_validates_edited_thread_post( - user_request, user_thread -): +def test_validate_posting_validates_edited_thread_post(user_request, user_thread): formset = get_thread_post_edit_formset(user_request, user_thread.first_post) state = ThreadPostEditState(user_request, user_thread.first_post) - assert validate_posted_contents(formset, state) + assert validate_posting(formset, state) -def test_validate_posted_contents_validates_edited_private_thread_post( +def test_validate_posting_validates_edited_private_thread_post( user_request, user_private_thread ): formset = get_private_thread_post_edit_formset( user_request, user_private_thread.first_post ) state = PrivateThreadPostEditState(user_request, user_private_thread.first_post) - assert validate_posted_contents(formset, state) + assert validate_posting(formset, state) diff --git a/misago/posting/validators.py b/misago/posting/validators.py index 6d82c066ae..f4fa6c92a9 100644 --- a/misago/posting/validators.py +++ b/misago/posting/validators.py @@ -9,7 +9,7 @@ from .floodcontrol import flood_control from .hooks import ( validate_post_hook, - validate_posted_contents_hook, + validate_posting_hook, validate_thread_title_hook, ) @@ -23,7 +23,7 @@ "validate_poll_choices", "validate_poll_question", "validate_post", - "validate_posted_contents", + "validate_posting", "validate_thread_title", ] @@ -157,10 +157,10 @@ def _validate_thread_title_action( ) -def validate_posted_contents( +def validate_posting( formset: Union["Formset", "TabbedFormset"], state: "State" ) -> bool: - validate_posted_contents_hook(formset, state) + validate_posting_hook(formset, state) return not bool(formset.errors) diff --git a/misago/posting/views/edit.py b/misago/posting/views/edit.py index 8212ebbe42..1f6be0bde4 100644 --- a/misago/posting/views/edit.py +++ b/misago/posting/views/edit.py @@ -39,7 +39,7 @@ get_private_thread_post_edit_state, get_thread_post_edit_state, ) -from ..validators import validate_posted_contents +from ..validators import validate_posting class EditView(BaseThreadView): @@ -151,7 +151,7 @@ def get_formset(self, request: HttpRequest, post: Post) -> Formset: raise NotImplementedError() def is_valid(self, formset: Formset, state: PostEditState) -> bool: - return formset.is_valid() and validate_posted_contents(formset, state) + return formset.is_valid() and validate_posting(formset, state) def render( self, diff --git a/misago/posting/views/reply.py b/misago/posting/views/reply.py index 30df16db51..0761cf2c96 100644 --- a/misago/posting/views/reply.py +++ b/misago/posting/views/reply.py @@ -50,7 +50,7 @@ get_private_thread_reply_state, get_thread_reply_state, ) -from ..validators import validate_flood_control, validate_posted_contents +from ..validators import validate_flood_control, validate_posting class ReplyView(BaseThreadView): @@ -233,7 +233,7 @@ def is_valid(self, formset: Formset, state: ReplyState) -> bool: return ( formset.is_valid() and (state.is_merged or validate_flood_control(formset, state)) - and validate_posted_contents(formset, state) + and validate_posting(formset, state) ) def post_state_save( diff --git a/misago/posting/views/start.py b/misago/posting/views/start.py index 90928c7294..a34a5eb906 100644 --- a/misago/posting/views/start.py +++ b/misago/posting/views/start.py @@ -34,7 +34,7 @@ get_private_thread_start_state, get_thread_start_state, ) -from ..validators import validate_flood_control, validate_posted_contents +from ..validators import validate_flood_control, validate_posting class StartView(BaseThreadView): @@ -120,7 +120,7 @@ def is_valid(self, formset: Formset | TabbedFormset, state: StartState) -> bool: return ( formset.is_valid() and validate_flood_control(formset, state) - and validate_posted_contents(formset, state) + and validate_posting(formset, state) ) def post_state_save( diff --git a/misago/threads/tests/conftest.py b/misago/threads/tests/conftest.py index 64ab6b434d..98f16b0a6a 100644 --- a/misago/threads/tests/conftest.py +++ b/misago/threads/tests/conftest.py @@ -3,7 +3,7 @@ from ...categories.models import Category from ...permissions.enums import CategoryPermission -from ...posting.hooks import validate_posted_contents_hook +from ...posting.hooks import validate_posting_hook from ...testutils import grant_category_group_permissions From 909dd952e38954fb7061d9eb4919a71004bebcdc Mon Sep 17 00:00:00 2001 From: rafalp Date: Tue, 11 Aug 2026 02:11:11 +0200 Subject: [PATCH 5/5] Rename posting validators --- dev-docs/plugins/hooks/reference.md | 2 +- ...-hook.md => validate-post-content-hook.md} | 24 +++++++------- misago/posting/forms/post.py | 6 ++-- misago/posting/hooks/__init__.py | 4 +-- ...idate_post.py => validate_post_content.py} | 32 +++++++++---------- misago/posting/state/base.py | 2 +- misago/posting/state/reply.py | 4 +-- misago/posting/tests/test_post_edit_state.py | 18 +++++------ .../tests/test_private_thread_reply_state.py | 4 +-- .../tests/test_private_thread_start_state.py | 6 ++-- misago/posting/tests/test_reply_state.py | 16 +++++----- misago/posting/tests/test_start_state.py | 16 +++++----- misago/posting/tests/test_state.py | 8 ++--- .../posting/tests/test_thread_reply_state.py | 4 +-- .../posting/tests/test_thread_start_state.py | 4 +-- ..._post.py => test_validate_post_content.py} | 24 +++++++------- misago/posting/validators.py | 20 ++++++------ 17 files changed, 98 insertions(+), 96 deletions(-) rename dev-docs/plugins/hooks/{validate-post-hook.md => validate-post-content-hook.md} (76%) rename misago/posting/hooks/{validate_post.py => validate_post_content.py} (77%) rename misago/posting/tests/{test_validate_post.py => test_validate_post_content.py} (54%) diff --git a/dev-docs/plugins/hooks/reference.md b/dev-docs/plugins/hooks/reference.md index 94d17e9af0..6d89b72a65 100644 --- a/dev-docs/plugins/hooks/reference.md +++ b/dev-docs/plugins/hooks/reference.md @@ -243,7 +243,7 @@ Hooks instances are importable from the following Python modules: - [`save_thread_reply_state_hook`](./save-thread-reply-state-hook.md) - [`save_thread_start_state_hook`](./save-thread-start-state-hook.md) - [`should_process_post_content_hook`](./should-process-post-content-hook.md) -- [`validate_post_hook`](./validate-post-hook.md) +- [`validate_post_content_hook`](./validate-post-content-hook.md) - [`validate_posting_hook`](./validate-posting-hook.md) - [`validate_thread_title_hook`](./validate-thread-title-hook.md) diff --git a/dev-docs/plugins/hooks/validate-post-hook.md b/dev-docs/plugins/hooks/validate-post-content-hook.md similarity index 76% rename from dev-docs/plugins/hooks/validate-post-hook.md rename to dev-docs/plugins/hooks/validate-post-content-hook.md index 26083e5028..5413f8c844 100644 --- a/dev-docs/plugins/hooks/validate-post-hook.md +++ b/dev-docs/plugins/hooks/validate-post-content-hook.md @@ -1,8 +1,8 @@ -# `validate_post_hook` +# `validate_post_content_hook` -This hook allows plugins to replace or extend the standard logic used to validate post contents. +This hook allows plugins to replace or extend the standard logic used to validate post content. -Post contents are represented as a `ParsingResult` object with the following attributes: +Post content is represented as a `ParsingResult` object with the following attributes: - `markup: str`: The original markup posted by the user. - `tokens: list[Token]`: A token stream returned by the parser. - `html: str`: An HTML representation of the parsed markup. - `text: str`: A plain text representation of the parsed markup. @@ -12,15 +12,15 @@ Post contents are represented as a `ParsingResult` object with the following att This hook can be imported from `misago.posting.hooks`: ```python -from misago.posting.hooks import validate_post_hook +from misago.posting.hooks import validate_post_content_hook ``` ## Filter ```python -def custom_validate_post_filter( - action: ValidatePostHookAction, +def custom_validate_post_content_filter( + action: ValidatePostContentHookAction, value: ParsingResult, min_length: int, max_length: int, @@ -34,7 +34,7 @@ A function implemented by a plugin that can be registered in this hook. ### Arguments -#### `action: ValidatePostHookAction` +#### `action: ValidatePostContentHookAction` The next function registered in this hook, either a custom function or Misago's default. @@ -64,7 +64,7 @@ The request object or `None` if not provided. ## Action ```python -def validate_post_action( +def validate_post_content_action( value: ParsingResult, min_length: int, max_length: int, @@ -73,7 +73,7 @@ def validate_post_action( ... ``` -Misago function for validating the contents of a post. Raises `ValidationError` if the post contents are invalid. +Misago function for validating the content of a post. Raises `ValidationError` if the post content is invalid. ### Arguments @@ -105,11 +105,11 @@ Raises the minimal required length of a post for new users. ```python from django.http import HttpRequest from misago.parser.parse import ParsingResult -from misago.posting.hooks import validate_post_hook +from misago.posting.hooks import validate_post_content_hook -@validate_post_hook.append_filter -def validate_post_for_new_users( +@validate_post_content_hook.append_filter +def validate_post_content_for_new_users( action, value: ParsingResult, min_length: int, diff --git a/misago/posting/forms/post.py b/misago/posting/forms/post.py index ea691055cb..aff4484d62 100644 --- a/misago/posting/forms/post.py +++ b/misago/posting/forms/post.py @@ -14,7 +14,7 @@ from ...attachments.validators import validate_post_attachments_limit from ...parser.parse import ParsingResult, parse from ..state import State -from ..validators import validate_post +from ..validators import validate_post_content from .attachments import MultipleFileField from .base import PostingForm @@ -186,7 +186,7 @@ def clean_post(self): data = self.cleaned_data["post"] parsing_result = parse(data) - validate_post( + validate_post_content( parsing_result, self.request.settings.post_length_min, self.request.settings.post_length_max, @@ -235,7 +235,7 @@ def clean(self): return cleaned_data def update_state(self, state: State): - state.set_post_message(self.parsing_result) + state.set_post_content(self.parsing_result) state.set_attachments(self.attachments) state.set_delete_attachments(self.deleted_attachments) diff --git a/misago/posting/hooks/__init__.py b/misago/posting/hooks/__init__.py index 917da8c35f..f48fd8ed79 100644 --- a/misago/posting/hooks/__init__.py +++ b/misago/posting/hooks/__init__.py @@ -37,7 +37,7 @@ from .save_thread_reply_state import save_thread_reply_state_hook from .save_thread_start_state import save_thread_start_state_hook from .should_process_post_content import should_process_post_content_hook -from .validate_post import validate_post_hook +from .validate_post_content import validate_post_content_hook from .validate_posting import validate_posting_hook from .validate_thread_title import validate_thread_title_hook @@ -69,7 +69,7 @@ "save_thread_reply_state_hook", "save_thread_start_state_hook", "should_process_post_content_hook", - "validate_post_hook", + "validate_post_content_hook", "validate_posting_hook", "validate_thread_title_hook", ] diff --git a/misago/posting/hooks/validate_post.py b/misago/posting/hooks/validate_post_content.py similarity index 77% rename from misago/posting/hooks/validate_post.py rename to misago/posting/hooks/validate_post_content.py index 76f297a1f0..32daf6d0da 100644 --- a/misago/posting/hooks/validate_post.py +++ b/misago/posting/hooks/validate_post_content.py @@ -6,10 +6,10 @@ from ...plugins.hooks import FilterHook -class ValidatePostHookAction(Protocol): +class ValidatePostContentHookAction(Protocol): """ - Misago function for validating the contents of a post. - Raises `ValidationError` if the post contents are invalid. + Misago function for validating the content of a post. + Raises `ValidationError` if the post content is invalid. # Arguments @@ -39,13 +39,13 @@ def __call__( ) -> None: ... -class ValidatePostHookFilter(Protocol): +class ValidatePostContentHookFilter(Protocol): """ A function implemented by a plugin that can be registered in this hook. # Arguments - ## `action: ValidatePostHookAction` + ## `action: ValidatePostContentHookAction` The next function registered in this hook, either a custom function or Misago's default. @@ -71,7 +71,7 @@ class ValidatePostHookFilter(Protocol): def __call__( self, - action: ValidatePostHookAction, + action: ValidatePostContentHookAction, value: ParsingResult, min_length: int, max_length: int, @@ -79,17 +79,17 @@ def __call__( ) -> None: ... -class ValidatePostHook( +class ValidatePostContentHook( FilterHook[ - ValidatePostHookAction, - ValidatePostHookFilter, + ValidatePostContentHookAction, + ValidatePostContentHookFilter, ] ): """ This hook allows plugins to replace or extend the standard logic used to - validate post contents. + validate post content. - Post contents are represented as a `ParsingResult` object with the following + Post content is represented as a `ParsingResult` object with the following attributes: - `markup: str`: The original markup posted by the user. @@ -104,11 +104,11 @@ class ValidatePostHook( ```python from django.http import HttpRequest from misago.parser.parse import ParsingResult - from misago.posting.hooks import validate_post_hook + from misago.posting.hooks import validate_post_content_hook - @validate_post_hook.append_filter - def validate_post_for_new_users( + @validate_post_content_hook.append_filter + def validate_post_content_for_new_users( action, value: ParsingResult, min_length: int, @@ -126,7 +126,7 @@ def validate_post_for_new_users( def __call__( self, - action: ValidatePostHookAction, + action: ValidatePostContentHookAction, value: ParsingResult, min_length: int, max_length: int, @@ -135,4 +135,4 @@ def __call__( return super().__call__(action, value, min_length, max_length, request) -validate_post_hook = ValidatePostHook() +validate_post_content_hook = ValidatePostContentHook() diff --git a/misago/posting/state/base.py b/misago/posting/state/base.py index c215ac09b3..3fff9d9b29 100644 --- a/misago/posting/state/base.py +++ b/misago/posting/state/base.py @@ -117,7 +117,7 @@ def set_thread_title(self, title: str): self.thread.title = title self.thread.slug = slugify(title) - def set_post_message(self, parsing_result: ParsingResult): + def set_post_content(self, parsing_result: ParsingResult): self.parsing_result = parsing_result self.post.content = parsing_result.markup diff --git a/misago/posting/state/reply.py b/misago/posting/state/reply.py index a0f3345088..dfe22cded4 100644 --- a/misago/posting/state/reply.py +++ b/misago/posting/state/reply.py @@ -37,12 +37,12 @@ def __init__(self, request: HttpRequest, thread: Thread, post: Post | None = Non if self.post.id: self.store_object_state(self.post) - def set_post_message(self, parsing_result: ParsingResult): + def set_post_content(self, parsing_result: ParsingResult): if self.post.id: markup = "\n\n".join([self.post.content, parsing_result.markup]) parsing_result = parse(markup) - super().set_post_message(parsing_result) + super().set_post_content(parsing_result) def require_approval(self) -> bool: return False diff --git a/misago/posting/tests/test_post_edit_state.py b/misago/posting/tests/test_post_edit_state.py index f030f82be8..7a5aeb1bf3 100644 --- a/misago/posting/tests/test_post_edit_state.py +++ b/misago/posting/tests/test_post_edit_state.py @@ -18,7 +18,7 @@ def test_post_edit_state_save_updates_thread_title(user_request, other_user_thre def test_post_edit_state_save_updates_post(user, user_request, other_user_thread): state = PostEditState(user_request, other_user_thread.first_post) - state.set_post_message(parse("Edit reply")) + state.set_post_content(parse("Edit reply")) state.save() post = other_user_thread.first_post @@ -45,7 +45,7 @@ def test_post_edit_state_save_updates_post_attachments( assert not attachment.post state = PostEditState(user_request, other_user_thread.first_post) - state.set_post_message(parse("Edit reply")) + state.set_post_content(parse("Edit reply")) state.set_attachments([attachment]) state.save() @@ -73,7 +73,7 @@ def test_post_edit_state_save_deletes_post_attachments( attachment = attachment_factory(text_file, uploader=user, post=post) state = PostEditState(user_request, other_user_thread.first_post) - state.set_post_message(parse("Edit reply")) + state.set_post_content(parse("Edit reply")) state.set_attachments([attachment, post_attachment]) state.set_delete_attachments([attachment]) state.save() @@ -102,7 +102,7 @@ def test_post_edit_state_save_deletes_unused_attachments( unused_attachment = attachment_factory(text_file, uploader=user) state = PostEditState(user_request, other_user_thread.first_post) - state.set_post_message(parse("Edit reply")) + state.set_post_content(parse("Edit reply")) state.set_attachments([unused_attachment, post_attachment]) state.set_delete_attachments([unused_attachment]) state.save() @@ -126,7 +126,7 @@ def test_post_edit_state_schedules_post_upgrade_for_post_with_code_block( mock_process_post_content, user_request, other_user_thread ): state = PostEditState(user_request, other_user_thread.first_post) - state.set_post_message(parse("Hello world\n[code=python]add(1, 3)[/code]")) + state.set_post_content(parse("Hello world\n[code=python]add(1, 3)[/code]")) state.save() assert state.post.id @@ -141,7 +141,7 @@ def test_post_edit_state_changes_test_returns_false_if_nothing_changed( user_request, other_user_thread ): state = PostEditState(user_request, other_user_thread.first_post) - state.set_post_message(parse(other_user_thread.first_post.content)) + state.set_post_content(parse(other_user_thread.first_post.content)) assert not state.is_post_changed() @@ -152,7 +152,7 @@ def test_post_edit_state_changes_test_returns_true_if_thread_title_changed( state = PostEditState(user_request, other_user_thread.first_post) state.set_thread_title("New title") - state.set_post_message(parse(other_user_thread.first_post.content)) + state.set_post_content(parse(other_user_thread.first_post.content)) assert state.is_post_changed() @@ -165,7 +165,7 @@ def test_post_edit_state_changes_test_returns_true_if_post_contents_changed( post.save() state = PostEditState(user_request, other_user_thread.first_post) - state.set_post_message(parse("Lorem\nIpsum\nDolor")) + state.set_post_content(parse("Lorem\nIpsum\nDolor")) assert state.is_post_changed() @@ -178,7 +178,7 @@ def test_post_edit_state_changes_test_returns_false_if_only_new_line_characters_ post.save() state = PostEditState(user_request, other_user_thread.first_post) - state.set_post_message(parse("Lorem\nIpsum")) + state.set_post_content(parse("Lorem\nIpsum")) assert not state.is_post_changed() diff --git a/misago/posting/tests/test_private_thread_reply_state.py b/misago/posting/tests/test_private_thread_reply_state.py index 9eb81af762..7e2eb59337 100644 --- a/misago/posting/tests/test_private_thread_reply_state.py +++ b/misago/posting/tests/test_private_thread_reply_state.py @@ -4,7 +4,7 @@ def test_private_thread_reply_state_save(user_request, user_private_thread): state = PrivateThreadReplyState(user_request, user_private_thread) - state.set_post_message(parse("Test reply")) + state.set_post_content(parse("Test reply")) state.save() @@ -15,7 +15,7 @@ def test_private_thread_reply_state_saves_unapproved_post( user.save() state = PrivateThreadReplyState(user_request, other_user_private_thread) - state.set_post_message(parse("Test reply")) + state.set_post_content(parse("Test reply")) state.save() other_user_private_thread.refresh_from_db() diff --git a/misago/posting/tests/test_private_thread_start_state.py b/misago/posting/tests/test_private_thread_start_state.py index a9bb49ba7f..7846db64d7 100644 --- a/misago/posting/tests/test_private_thread_start_state.py +++ b/misago/posting/tests/test_private_thread_start_state.py @@ -8,7 +8,7 @@ def test_private_thread_start_state_save_sets_request_user_as_thread_owner( ): state = PrivateThreadStartState(user_request, private_threads_category) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) state.set_members([other_user]) state.save() @@ -24,7 +24,7 @@ def test_private_thread_start_state_save_adds_members_to_saved_thread( ): state = PrivateThreadStartState(user_request, private_threads_category) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) state.set_members([other_user]) state.save() @@ -43,7 +43,7 @@ def test_private_thread_start_state_saves_unapproved_thread( state = PrivateThreadStartState(user_request, private_threads_category) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) state.set_members([other_user]) state.save() diff --git a/misago/posting/tests/test_reply_state.py b/misago/posting/tests/test_reply_state.py index 701e0593e0..cf1da5a51a 100644 --- a/misago/posting/tests/test_reply_state.py +++ b/misago/posting/tests/test_reply_state.py @@ -25,7 +25,7 @@ def test_reply_state_initializes_post(user_request, other_user_thread): def test_reply_state_save_saves_post(user_request, other_user_thread): state = ReplyState(user_request, other_user_thread) - state.set_post_message(parse("Test reply")) + state.set_post_content(parse("Test reply")) state.save() assert state.post.id @@ -34,7 +34,7 @@ def test_reply_state_save_saves_post(user_request, other_user_thread): def test_reply_state_updates_thread(user_request, other_user_thread): state = ReplyState(user_request, other_user_thread) - state.set_post_message(parse("Test reply")) + state.set_post_content(parse("Test reply")) state.save() other_user_thread.refresh_from_db() @@ -48,7 +48,7 @@ def test_reply_state_updates_thread(user_request, other_user_thread): def test_reply_state_updates_category(user_request, other_user_thread): state = ReplyState(user_request, other_user_thread) - state.set_post_message(parse("Test reply")) + state.set_post_content(parse("Test reply")) state.save() category = other_user_thread.category @@ -66,7 +66,7 @@ def test_reply_state_updates_category(user_request, other_user_thread): def test_reply_state_updates_user(user_request, other_user_thread, user): state = ReplyState(user_request, other_user_thread) - state.set_post_message(parse("Test reply")) + state.set_post_content(parse("Test reply")) state.save() user.refresh_from_db() @@ -82,7 +82,7 @@ def test_reply_state_updates_existing_post(user, user_request, user_thread): post_parsed = post.content_parsed state = ReplyState(user_request, user_thread, post) - state.set_post_message(parse("Test reply")) + state.set_post_content(parse("Test reply")) state.save() post.refresh_from_db() @@ -127,7 +127,7 @@ def test_reply_state_assigns_attachments_to_category_thread_and_post( assert not attachment.post state = ReplyState(user_request, other_user_thread) - state.set_post_message(parse("Test reply")) + state.set_post_content(parse("Test reply")) state.set_attachments([attachment]) state.save() @@ -150,7 +150,7 @@ def test_reply_state_updates_existing_post_attachments( assert not attachment.post state = ReplyState(user_request, user_thread, post) - state.set_post_message(parse("Test reply")) + state.set_post_content(parse("Test reply")) state.set_attachments([attachment]) state.save() @@ -171,7 +171,7 @@ def test_reply_state_schedules_post_upgrade_for_post_with_code_block( mock_process_post_content, user_request, other_user_thread ): state = ReplyState(user_request, other_user_thread) - state.set_post_message(parse("Hello world\n[code=python]add(1, 3)[/code]")) + state.set_post_content(parse("Hello world\n[code=python]add(1, 3)[/code]")) state.save() assert state.post.id diff --git a/misago/posting/tests/test_start_state.py b/misago/posting/tests/test_start_state.py index 16f03f6783..9b8ef349d2 100644 --- a/misago/posting/tests/test_start_state.py +++ b/misago/posting/tests/test_start_state.py @@ -31,7 +31,7 @@ def test_start_state_stores_category_state(user_request, default_category): def test_start_state_save_saves_thread_and_post(user_request, default_category): state = StartState(user_request, default_category) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) state.save() state.save_action(user_request, state) @@ -45,7 +45,7 @@ def test_start_state_save_saves_thread_and_post(user_request, default_category): def test_start_state_save_saves_post_search_document(user_request, default_category): state = StartState(user_request, default_category) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) state.save() state.save_action(user_request, state) @@ -55,7 +55,7 @@ def test_start_state_save_saves_post_search_document(user_request, default_categ def test_start_state_updates_category(user_request, default_category): state = StartState(user_request, default_category) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) state.save() state.save_action(user_request, state) @@ -74,7 +74,7 @@ def test_start_state_updates_category(user_request, default_category): def test_start_state_updates_user(user_request, default_category, user): state = StartState(user_request, default_category) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) state.save() state.save_action(user_request, state) @@ -94,7 +94,7 @@ def test_start_state_assigns_attachments_to_category_thread_and_post( state = StartState(user_request, default_category) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) state.set_attachments([attachment]) state.save() state.save_action(user_request, state) @@ -116,7 +116,7 @@ def test_start_state_deletes_unused_attachments( state = StartState(user_request, default_category) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) state.set_attachments([attachment]) state.set_delete_attachments([attachment]) state.save() @@ -139,7 +139,7 @@ def test_start_state_delete_attachments_excludes_unknown_attachments( state = StartState(user_request, default_category) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) state.set_delete_attachments([attachment]) state.save() state.save_action(user_request, state) @@ -156,7 +156,7 @@ def test_start_state_schedules_post_upgrade_for_post_with_code_block( ): state = StartState(user_request, default_category) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world\n[code=python]add(1, 3)[/code]")) + state.set_post_content(parse("Hello world\n[code=python]add(1, 3)[/code]")) state.save() state.save_action(user_request, state) diff --git a/misago/posting/tests/test_state.py b/misago/posting/tests/test_state.py index 1f7bcbf7b3..eabb786bb4 100644 --- a/misago/posting/tests/test_state.py +++ b/misago/posting/tests/test_state.py @@ -70,22 +70,22 @@ def test_state_set_thread_title_updates_thread_title_and_slug(user_request, thre assert state.thread.slug == "test-thread" -def test_state_set_post_message_updates_post_contents(user_request, post): +def test_state_set_post_content_updates_post_contents(user_request, post): state = State(user_request) state.post = post - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) assert post.content == "Hello world" assert post.content_parsed == "

    Hello world

    " assert post.metadata == {} -def test_state_set_post_message_stores_attachments_ids_in_post_metadata( +def test_state_set_post_content_stores_attachments_ids_in_post_metadata( user_request, post ): state = State(user_request) state.post = post - state.set_post_message(parse("")) + state.set_post_content(parse("")) assert post.content == "" assert post.content_parsed == ( diff --git a/misago/posting/tests/test_thread_reply_state.py b/misago/posting/tests/test_thread_reply_state.py index 66b8414f42..b9cb5d3ce2 100644 --- a/misago/posting/tests/test_thread_reply_state.py +++ b/misago/posting/tests/test_thread_reply_state.py @@ -4,7 +4,7 @@ def test_thread_reply_state_save(user_request, other_user_thread): state = ThreadReplyState(user_request, other_user_thread) - state.set_post_message(parse("Test reply")) + state.set_post_content(parse("Test reply")) state.save() @@ -15,7 +15,7 @@ def test_thread_reply_state_saves_unapproved_post( user.save() state = ThreadReplyState(user_request, other_user_thread) - state.set_post_message(parse("Test reply")) + state.set_post_content(parse("Test reply")) state.save() default_category.refresh_from_db() diff --git a/misago/posting/tests/test_thread_start_state.py b/misago/posting/tests/test_thread_start_state.py index 1797cae84d..d608e38fcc 100644 --- a/misago/posting/tests/test_thread_start_state.py +++ b/misago/posting/tests/test_thread_start_state.py @@ -17,7 +17,7 @@ def test_thread_start_state_creates_thread_with_poll(user_request, default_categ ) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) state.set_poll(poll) state.save() @@ -38,7 +38,7 @@ def test_thread_start_state_saves_unapproved_thread( state = ThreadStartState(user_request, default_category) state.set_thread_title("Test thread") - state.set_post_message(parse("Hello world")) + state.set_post_content(parse("Hello world")) state.save() assert state.thread.is_unapproved diff --git a/misago/posting/tests/test_validate_post.py b/misago/posting/tests/test_validate_post_content.py similarity index 54% rename from misago/posting/tests/test_validate_post.py rename to misago/posting/tests/test_validate_post_content.py index 8e1aca05d0..1cae9a06fe 100644 --- a/misago/posting/tests/test_validate_post.py +++ b/misago/posting/tests/test_validate_post_content.py @@ -2,24 +2,24 @@ from django.core.exceptions import ValidationError from ...parser.parse import parse -from ..validators import validate_post +from ..validators import validate_post_content -def test_validate_post_passes_valid_value(): - validate_post(parse("valid value"), 1, 100) +def test_validate_post_content_passes_valid_value(): + validate_post_content(parse("valid value"), 1, 100) -def test_validate_post_raises_error_for_empty_value(): +def test_validate_post_content_raises_error_for_empty_value(): with pytest.raises(ValidationError) as exc_info: - validate_post(parse(""), 1, 100) + validate_post_content(parse(""), 1, 100) - assert str(exc_info.value.message) == "Posted message has no content." + assert str(exc_info.value.message) == "Posted message can't be empty." assert exc_info.value.code == "required" -def test_validate_post_raises_error_for_too_short_value(): +def test_validate_post_content_raises_error_for_too_short_value(): with pytest.raises(ValidationError) as exc_info: - validate_post(parse("short"), 10, 100) + validate_post_content(parse("short"), 10, 100) assert str(exc_info.value.message) == ( "Posted message must be at least %(limit_value)s " @@ -29,9 +29,9 @@ def test_validate_post_raises_error_for_too_short_value(): assert exc_info.value.params == {"limit_value": 10, "show_value": 5} -def test_validate_post_raises_error_for_too_long_value(): +def test_validate_post_content_raises_error_for_too_long_value(): with pytest.raises(ValidationError) as exc_info: - validate_post(parse("lorem ipsum dolor met"), 1, 10) + validate_post_content(parse("lorem ipsum dolor met"), 1, 10) assert str(exc_info.value.message) == ( "Posted message cannot be longer than %(limit_value)s " @@ -41,5 +41,5 @@ def test_validate_post_raises_error_for_too_long_value(): assert exc_info.value.params == {"limit_value": 10, "show_value": 21} -def test_validate_post_disables_max_length_validation(): - validate_post(parse("lorem ipsum dolor met"), 1, 0) +def test_validate_post_content_disables_max_length_validation(): + validate_post_content(parse("lorem ipsum dolor met"), 1, 0) diff --git a/misago/posting/validators.py b/misago/posting/validators.py index f4fa6c92a9..235ef9a4cb 100644 --- a/misago/posting/validators.py +++ b/misago/posting/validators.py @@ -8,7 +8,7 @@ from ..parser.parse import ParsingResult from .floodcontrol import flood_control from .hooks import ( - validate_post_hook, + validate_post_content_hook, validate_posting_hook, validate_thread_title_hook, ) @@ -22,20 +22,20 @@ "validate_flood_control", "validate_poll_choices", "validate_poll_question", - "validate_post", + "validate_post_content", "validate_posting", "validate_thread_title", ] -def validate_post( +def validate_post_content( value: ParsingResult, min_length: int, max_length: int, request: HttpRequest | None = None, ): - validate_post_hook( - _validate_post_action, + validate_post_content_hook( + _validate_post_content_action, value, min_length, max_length, @@ -43,7 +43,7 @@ def validate_post( ) -def _validate_post_action( +def _validate_post_content_action( value: ParsingResult, min_length: int, max_length: int, @@ -52,14 +52,16 @@ def _validate_post_action( length = len(value.text) if not length: raise ValidationError( - message=pgettext("post validator", "Posted message has no content."), + message=pgettext( + "post content validator", "Posted message can't be empty." + ), code="required", ) if length < min_length: raise ValidationError( message=npgettext( - "post validator", + "post content validator", "Posted message must be at least %(limit_value)s character long (it has %(show_value)s).", "Posted message must be at least %(limit_value)s characters long (it has %(show_value)s).", min_length, @@ -74,7 +76,7 @@ def _validate_post_action( if max_length and length > max_length: raise ValidationError( message=npgettext( - "post validator", + "post content validator", "Posted message cannot be longer than %(limit_value)s character (it currently has %(show_value)s).", "Posted message cannot be longer than %(limit_value)s characters (it currently has %(show_value)s).", max_length,