Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension user field addition #4396

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

frankduncan
Copy link
Contributor

@frankduncan frankduncan commented Feb 12, 2025

Adds template hooks in necessary places to allow adding fields to the User object. The first commit is an example replacement for the {% include "includes/head_end.html" %} in hypha/templates/base.html, with an improvement that if you have multiple extensions that want to add things to the <head> of every hypha page, they won't overwrite each other and can remain uncoupled.

This also adds in hooks into the user create/update forms in wagtail, as those aren't built on the WAGTAIL_CUSTOM_FIELDS like the main profile update page is.

This depends on #4395

This is pulled from https://github.com/nitely/django-hooks with
everything except the template hooks removed.
This gives any extension the ability to add css and javascript to every
page in hypha.
Allows extensions that want to add new fields to users to have those
fields present in the wagtail admin.
@frjo frjo added Type: Feature This is something new (not an enhancement of an existing thing). Type: Patch Mini change, used in release drafter labels Mar 7, 2025
@frjo
Copy link
Member

frjo commented Mar 7, 2025

@frankduncan The template hooks feature are now merged in. Can you make this PR only add the hooks in the templates, thanks!

Did you have plans to add tests to make sure the various hooks still exist?

@@ -8,6 +9,8 @@
{% include "wagtailadmin/shared/field_as_li.html" with field=form.email %}
{% include "wagtailadmin/shared/field_as_li.html" with field=form.full_name %}

{% hook 'wagtail_user_edit' %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be called wagtail_user_create, thoughts? I believe the context for edit and create will be different.

For a specific plugin, if it's needs to the same thing at the both the places, it can implement both the hooks, but those plugins that need to insert different code at different places, might not get an option to do so.

Also, this could introduce bug due to it's non-explicit nature of the hook name.

My 2 cents!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I'll update when I make the PR.

@frankduncan
Copy link
Contributor Author

@frjo Yeah, I'll add tests and clean up this branch. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature This is something new (not an enhancement of an existing thing). Type: Patch Mini change, used in release drafter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants