From ebaeedb076534dfe4751675bee7654cc9ffcc97e Mon Sep 17 00:00:00 2001 From: Joel Addison Date: Tue, 16 Apr 2024 21:55:03 +1000 Subject: [PATCH] Fix display of registration on dashboard Ensure the registration information is displayed to any user who can use a component of the section, regardless of if there are available categories for them to purchase from. --- pinaxcon/templates/dashboard.html | 4 ++-- .../templatetags/registrasion_tags.py | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pinaxcon/templates/dashboard.html b/pinaxcon/templates/dashboard.html index ae336c11..ea74ad20 100644 --- a/pinaxcon/templates/dashboard.html +++ b/pinaxcon/templates/dashboard.html @@ -16,8 +16,8 @@ {% block content %} -{% available_categories as categories %} -{% if categories %} +{% registration_available as show_registration %} +{% if show_registration %} {% include "symposion/dashboard/_categories.html" %} {% endif %} diff --git a/vendor/registrasion/registrasion/templatetags/registrasion_tags.py b/vendor/registrasion/registrasion/templatetags/registrasion_tags.py index 4c4a324e..73af25c6 100644 --- a/vendor/registrasion/registrasion/templatetags/registrasion_tags.py +++ b/vendor/registrasion/registrasion/templatetags/registrasion_tags.py @@ -21,6 +21,25 @@ def user_for_context(context): return context.request.user +@register.simple_tag(takes_context=True) +def registration_available(context): + ''' Checks if registration is available for the user. ''' + user = user_for_context(context) + if user.is_staff: + # Staff can always see registration - not necessarily all parts. + return True + + if user.attendee.completed_registration: + # Always show to someone who has completed registration already. + return True + + if available_categories(context): + # Not yet registered, but has categories available to purchase from. + return True + + return False + + @register.simple_tag(takes_context=True) def available_categories(context): ''' Gets all of the currently available products. @@ -49,6 +68,7 @@ def missing_categories(context): return sorted(set(i for i in missing), key=attrgetter("order")) + @register.simple_tag(takes_context=True) def available_credit(context): ''' Calculates the sum of unclaimed credit from this user's credit notes.