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})
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

View File

@ -55,16 +55,22 @@
<div class="vr d-none d-md-block m-4 p-0"></div>
<div class="col-12 col-md-4">
<div>
<h3>From:</h3>
<div>{{ event.instructor.member.account_name }}</div>
<div>{{ event.instructor.member.address_street }}</div>
<div>
{{ event.instructor.member.address_city }},
{{ event.instructor.member.address_state_province }}
{{ event.instructor.member.address_postal_code }}
</div>
<div>{{ event.instructor.member.email }}</div>
<div>{{ event.instructor.member.phone }}</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>
<div>{{ event.instructor.member.account_name }}</div>
<div>{{ event.instructor.member.address_street }}</div>
<div>
{{ event.instructor.member.address_city }},
{{ event.instructor.member.address_state_province }}
{{ event.instructor.member.address_postal_code }}
</div>
<div>{{ event.instructor.member.email }}</div>
<div>{{ event.instructor.member.phone }}</div>
{% endif %}
</div>
</div>
</div>