This hook wraps the standard function that Misago uses to get the template context data for the attachment details page.
This hook can be imported from misago.attachments.hooks:
from misago.attachments.hooks import get_attachment_details_page_context_data_hookdef custom_get_attachment_details_page_context_data_filter(
action: GetAttachmentDetailsPageContextDataHookAction,
request: HttpRequest,
attachment: Attachment,
) -> dict:
...A function implemented by a plugin that can be registered in this hook.
Misago function used to get the template context data for the attachment details page.
See the action section for details.
The request object.
The Attachment instance.
A Python dict with context data to use to render the attachment details page.
def get_attachment_details_page_context_data_action(request: HttpRequest, attachment: Attachment) -> dict:
...Misago function used to get the template context data for the attachment details page.
The request object.
The Attachment instance.
A Python dict with context data to use to render the attachment details page.
The code below implements a custom filter function that adds custom context data to the attachment details page:
from django.http import HttpRequest
from misago.attachments.hooks import get_attachment_details_page_context_data_hook
@get_attachment_details_page_context_data_hook.append_filter
def include_custom_context(action, request: HttpRequest, attachment: Attachment) -> dict:
context = action(request, attachment)
context["plugin_data"] = "..."
return context