From 0f30358357332f5971a7a3f4620da7b6707c2343 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Wed, 1 May 2024 14:35:12 -0400 Subject: [PATCH] membershipworks: Handle events without instructors better --- membershipworks/models.py | 2 ++ .../membershipworks/event_invoice.dj.html | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/membershipworks/models.py b/membershipworks/models.py index 4098eff..b599b59 100644 --- a/membershipworks/models.py +++ b/membershipworks/models.py @@ -556,6 +556,8 @@ class EventExt(Event): return reverse("membershipworks:event-detail", kwargs={"eid": self.eid}) def user_is_instructor(self, user: AbstractBaseUser) -> bool: + if self.instructor is None: + return False member = Member.from_user(user) if member is not None: return self.instructor.member == member diff --git a/membershipworks/templates/membershipworks/event_invoice.dj.html b/membershipworks/templates/membershipworks/event_invoice.dj.html index eda8c23..716a2cb 100644 --- a/membershipworks/templates/membershipworks/event_invoice.dj.html +++ b/membershipworks/templates/membershipworks/event_invoice.dj.html @@ -55,16 +55,22 @@
-

From:

-
{{ event.instructor.member.account_name }}
-
{{ event.instructor.member.address_street }}
-
- {{ event.instructor.member.address_city }}, - {{ event.instructor.member.address_state_province }} - {{ event.instructor.member.address_postal_code }} -
-
{{ event.instructor.member.email }}
-
{{ event.instructor.member.phone }}
+ {% if event.instructor is None %} +
No instructor has been defined for this event
+ {% elif event.instructor.member is None %} +
Instructor is not a member, so no address information is known
+ {% else %} +

From:

+
{{ event.instructor.member.account_name }}
+
{{ event.instructor.member.address_street }}
+
+ {{ event.instructor.member.address_city }}, + {{ event.instructor.member.address_state_province }} + {{ event.instructor.member.address_postal_code }} +
+
{{ event.instructor.member.email }}
+
{{ event.instructor.member.phone }}
+ {% endif %}