This hook wraps the standard function that Misago uses to get the template context data for the private thread detail view.
This hook can be imported from misago.privatethreads.hooks:
from misago.privatethreads.hooks import get_private_thread_detail_view_context_data_hookdef custom_get_private_thread_detail_view_context_data_filter(
action: GetPrivateThreadDetailViewContextDataHookAction,
request: HttpRequest,
thread: Thread,
page: int | None=None,
) -> 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 Thread instance.
An int with page number or None.
A Python dict with context data to use to render the private thread detail view.
def get_private_thread_detail_view_context_data_action(
request: HttpRequest, thread: Thread, page: int | None=None
) -> dict:
...Misago function used to get the template context data for the private thread detail view.
The request object.
A Thread instance.
An int with page number or None.
A Python dict with context data to use to render the private thread detail view.
The code below implements a custom filter function that adds custom context data to the thread detail view:
from django.http import HttpRequest
from misago.privatethreads.hooks import get_private_thread_detail_view_context_data_hook
from misago.threads.models import Thread
@get_private_thread_detail_view_context_data_hook.append_filter
def include_custom_context(
action,
request: HttpRequest,
thread: dict,
page: int | None = None,
) -> dict:
context = action(request, thread, page)
context["plugin_data"] = "..."
return context