membershipworks: Handle events without instructors better
All checks were successful
Ruff / ruff (push) Successful in 29s
Test / test (push) Successful in 4m59s

This commit is contained in:
Adam Goldsmith 2024-05-01 14:35:12 -04:00
parent b1daa21e2c
commit 0f30358357
2 changed files with 18 additions and 10 deletions

View File

@ -556,6 +556,8 @@ class EventExt(Event):
return reverse("membershipworks:event-detail", kwargs={"eid": self.eid}) return reverse("membershipworks:event-detail", kwargs={"eid": self.eid})
def user_is_instructor(self, user: AbstractBaseUser) -> bool: def user_is_instructor(self, user: AbstractBaseUser) -> bool:
if self.instructor is None:
return False
member = Member.from_user(user) member = Member.from_user(user)
if member is not None: if member is not None:
return self.instructor.member == member return self.instructor.member == member

View File

@ -55,6 +55,11 @@
<div class="vr d-none d-md-block m-4 p-0"></div> <div class="vr d-none d-md-block m-4 p-0"></div>
<div class="col-12 col-md-4"> <div class="col-12 col-md-4">
<div> <div>
{% if event.instructor is None %}
<div>No instructor has been defined for this event</div>
{% elif event.instructor.member is None %}
<div>Instructor is not a member, so no address information is known</div>
{% else %}
<h3>From:</h3> <h3>From:</h3>
<div>{{ event.instructor.member.account_name }}</div> <div>{{ event.instructor.member.account_name }}</div>
<div>{{ event.instructor.member.address_street }}</div> <div>{{ event.instructor.member.address_street }}</div>
@ -65,6 +70,7 @@
</div> </div>
<div>{{ event.instructor.member.email }}</div> <div>{{ event.instructor.member.email }}</div>
<div>{{ event.instructor.member.phone }}</div> <div>{{ event.instructor.member.phone }}</div>
{% endif %}
</div> </div>
</div> </div>
</div> </div>