diff --git a/fedireads/templates/snippets/follow_request_buttons.html b/fedireads/templates/snippets/follow_request_buttons.html index 856fac51..fb25a194 100644 --- a/fedireads/templates/snippets/follow_request_buttons.html +++ b/fedireads/templates/snippets/follow_request_buttons.html @@ -1,3 +1,5 @@ +{% load fr_display %} +{% if request.user|follow_request_exists:user %}
+{% endif %} diff --git a/fedireads/templatetags/fr_display.py b/fedireads/templatetags/fr_display.py index 33336d91..43a84b02 100644 --- a/fedireads/templatetags/fr_display.py +++ b/fedireads/templatetags/fr_display.py @@ -88,6 +88,20 @@ def get_user_liked(user, status): return False +@register.filter(name='follow_request_exists') +def follow_request_exists(user, requester): + ''' see if there is a pending follow request for a user ''' + try: + models.UserFollowRequest.objects.filter( + user_subject=requester, + user_object=user, + ).get() + return True + except models.UserFollowRequest.DoesNotExist: + return False + + + @register.simple_tag(takes_context=True) def shelve_button_identifier(context, book): ''' check what shelf a user has a book on, if any '''