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

Wagtail 6.1 #6

Merged
merged 4 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Unreleased
==========
- Add support for Wagtail 5.2 and 6.0
- Add support for Wagtail 5.2 and 6.x
- Drop support for Wagtail < 5.2
- Update `otp_form` to be compatible with Wagtail 5.2 and 6.0
- Update `otp_form` to be compatible with Wagtail 5.2 and 6.x
- Add support for Django 5.0


Expand Down
5 changes: 4 additions & 1 deletion src/wagtail_2fa/templates/wagtail_2fa/device_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ <h2>

{# Users can only add devices to their own account #}
{% if user_id == request.user.id %}
<a href="{% url 'wagtail_2fa_device_new' %}" class="button bicolor icon icon-plus">{% trans 'New device' %}</a>
<a href="{% url 'wagtail_2fa_device_new' %}" class="button bicolor button--icon">
<span class="icon-wrapper"><svg class="icon icon-plus icon" aria-hidden="true"><use href="#icon-plus"></use></svg></span>
{% trans 'New device' %}
</a>
{% endif %}
</div>
{% endblock %}
29 changes: 20 additions & 9 deletions src/wagtail_2fa/wagtail_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
from django.urls import path, reverse
from django.utils.translation import gettext_lazy as _

from wagtail import hooks
from wagtail import hooks, VERSION as WAGTAIL_VERSION
from wagtail.admin.menu import MenuItem
from wagtail.users.widgets import UserListingButton


from wagtail_2fa import views


Expand Down Expand Up @@ -68,14 +69,24 @@ def register(request):
}


@hooks.register("register_user_listing_buttons")
def register_user_listing_buttons(context, user):
yield UserListingButton(
_("Manage 2FA"),
reverse("wagtail_2fa_device_list", kwargs={"user_id": user.id}),
attrs={"title": _("Edit this user")},
priority=100,
)
if WAGTAIL_VERSION >= (6, 1):
@hooks.register("register_user_listing_buttons")
def register_user_listing_buttons(user, request_user):
yield UserListingButton(
_("Manage 2FA"),
reverse("wagtail_2fa_device_list", kwargs={"user_id": user.id}),
attrs={"title": _("Edit this user")},
priority=100,
)
else:
@hooks.register("register_user_listing_buttons")
def register_user_listing_buttons(context, user):
yield UserListingButton(
_("Manage 2FA"),
reverse("wagtail_2fa_device_list", kwargs={"user_id": user.id}),
attrs={"title": _("Edit this user")},
priority=100,
)


@hooks.register("register_permissions")
Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tox]
envlist =
python{3.8,3.9,3.10}-django3.2-wagtail5.2
python{3.8,3.9,3.10,3.11}-django4.2-wagtail{5.2,6.0}
python{3.11,3.12}-django5.0-wagtail{5.2,6.0}
python{3.8,3.9,3.10,3.11}-django4.2-wagtail{5.2,6.0,6.1}
python{3.11,3.12}-django5.0-wagtail{5.2,6.0,6.1}

[gh-actions]
python =
Expand All @@ -28,6 +28,7 @@ deps =
django5.0: Django>=5.0,<5.1
wagtail5.2: wagtail>=5.2,<6.0
wagtail6.0: wagtail>=6.0,<6.1
wagtail6.1: wagtail>=6.1,<6.2

extras = test

Expand Down