This hook wraps the standard function that Misago uses to update user group's description.
This hook can be imported from misago.users.hooks:
from misago.users.hooks import update_group_description_hookdef custom_update_group_description_filter(
action: UpdateGroupDescriptionHookAction, group: Group, **kwargs
) -> Group:
...A function implemented by a plugin that can be registered in this hook.
Misago function used to update an existing user group's description or the next filter function from another plugin.
See the action section for details.
A group instance to update.
A dict with group description's attributes to update.
Optional arguments in kwargs that are not used to update the group but are still provided for use by plugins:
The request object or None if it was not provided.
Bound Form instance that was used to update this group's description.
An updated Group instance.
def update_group_description_action(group: Group, **kwargs) -> Group:
...Misago function used to update an existing user group's description or the next filter function from another plugin.
A group instance to update.
A dict with group description's attributes to update.
Optional arguments in kwargs that are not used to update the group but are still provided for use by plugins:
The request object or None if it was not provided.
Bound Form instance that was used to update this group's description.
An updated Group instance.
The code below implements a custom filter function that stores an ID of user who last modified the group description, if its available:
from django.http import HttpRequest
from misago.users.models import Group
@update_group_description_hook.append_filter
def set_group_description_updated_by_id(action, **kwargs) -> Group:
# request key is guaranteed to be set in `kwargs`
if kwargs["request"] and kwargs["request"].user.id:
group.description.plugin_data["updated_by"] = kwargs["request"].user.id
# Call the next function in chain
return action(group, **kwargs)