Skip to content

Wagtail hooks

hypha.apply.users.wagtail_hooks

register_admin_urls

register_admin_urls()
Source code in hypha/apply/users/wagtail_hooks.py
@hooks.register("register_admin_urls")
def register_admin_urls():
    return [
        re_path(r"^users/$", index, name="index"),
    ]

register_viewset

register_viewset()
Source code in hypha/apply/users/wagtail_hooks.py
@hooks.register("register_admin_viewset")
def register_viewset():
    return CustomGroupViewSet("groups", url_prefix="groups")

notify_after_create_user

notify_after_create_user(request, user)
Source code in hypha/apply/users/wagtail_hooks.py
@hooks.register("after_create_user")
def notify_after_create_user(request, user):
    messenger(
        MESSAGES.STAFF_ACCOUNT_CREATED,
        request=request,
        user=request.user,
        source=user,
    )

    site = Site.find_for_request(request)
    send_activation_email(user, site)

notify_after_edit_user

notify_after_edit_user(request, user)
Source code in hypha/apply/users/wagtail_hooks.py
@hooks.register("after_edit_user")
def notify_after_edit_user(request, user):
    roles = list(user.groups.values_list("name", flat=True))
    if user.is_superuser:
        roles.append("Administrator")
    if roles:
        roles = ", ".join(roles)
        messenger(
            MESSAGES.STAFF_ACCOUNT_EDITED,
            request=request,
            user=request.user,
            source=user,
            roles=roles,
        )