From 7caede6d1f69ae321f9425fcdda8df83f66b7eb1 Mon Sep 17 00:00:00 2001 From: Anthony Date: Wed, 29 May 2024 10:27:51 -0700 Subject: [PATCH] Add invitation template filter (#11368) Because Django. This is just a wrapper for working around Django templates and calling ``Invitation.can_revoke_invitation`` with arguments. --- readthedocs/invitations/templatetags/__init__.py | 0 .../invitations/templatetags/invitations.py | 14 ++++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 readthedocs/invitations/templatetags/__init__.py create mode 100644 readthedocs/invitations/templatetags/invitations.py diff --git a/readthedocs/invitations/templatetags/__init__.py b/readthedocs/invitations/templatetags/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/readthedocs/invitations/templatetags/invitations.py b/readthedocs/invitations/templatetags/invitations.py new file mode 100644 index 00000000000..afecea355cd --- /dev/null +++ b/readthedocs/invitations/templatetags/invitations.py @@ -0,0 +1,14 @@ +"""Invitation template filters.""" + +from django import template + +from readthedocs.invitations.models import Invitation + +register = template.Library() + + +@register.filter +def can_revoke_invitation(user, object): + if isinstance(object, Invitation): + return object.can_revoke_invitation(user) + return False