This hook wraps a standard Misago function used to get the template context data for the private thread post edits page.
This hook can be imported from misago.edits.hooks:
from misago.edits.hooks import get_private_thread_post_edits_view_context_data_hookdef custom_get_private_thread_post_edits_view_context_data_filter(
action: GetPrivateThreadPostEditsViewContextDataHookAction,
request: HttpRequest,
post: Post,
page: Page,
) -> dict:
...A function implemented by a plugin that can be registered in this hook.
Next function registered in this hook, either a custom function or Misago's standard one.
See the action section for details.
The request object.
A Post instance whose edits are being displayed.
A Page instance that may or may not include a PostEdit instance in its object_list attribute.
A Python dict with context data to use to render the post edits page.
def get_private_thread_post_edits_view_context_data_action(request: HttpRequest, post: Post, page: Page) -> dict:
...Misago function used to get the template context data for the private thread post edits page.
The request object.
A Post instance whose edits are being displayed.
A Page instance that may or may not include a PostEdit instance in its object_list attribute.
A Python dict with context data to use to render the post edits page.
The code below implements a custom filter function that displays a template with the editor's IP address in the post_edit_diff_plugins_top plugin outlet.
from django.core.paginator import Page
from django.http import HttpRequest
from misago.edits.hooks import get_private_thread_post_edits_view_context_data_hook
from misago.edits.models import PostEdit
from misago.threads.models import Post
@get_private_thread_post_edits_view_context_data_hook.append_filter
def set_thread_post_edits_view_editor_ip_address(
action,
request: HttpRequest,
post: Post,
page: Page,
) -> dict:
context = action(request, post, page)
if not page.object_list:
return context
post_edit = page.object_list[0]
context["post_edit_diff_plugins_top"].append({
"template_name": "my_plugin/post_edit_diff.html",
"user_ip": post_edit.plugin_data.get("user_ip"),
})
return context