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,16 +55,22 @@
<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>
<h3>From:</h3> {% if event.instructor is None %}
<div>{{ event.instructor.member.account_name }}</div> <div>No instructor has been defined for this event</div>
<div>{{ event.instructor.member.address_street }}</div> {% elif event.instructor.member is None %}
<div> <div>Instructor is not a member, so no address information is known</div>
{{ event.instructor.member.address_city }}, {% else %}
{{ event.instructor.member.address_state_province }} <h3>From:</h3>
{{ event.instructor.member.address_postal_code }} <div>{{ event.instructor.member.account_name }}</div>
</div> <div>{{ event.instructor.member.address_street }}</div>
<div>{{ event.instructor.member.email }}</div> <div>
<div>{{ event.instructor.member.phone }}</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> </div>
</div> </div>