Commit aae44beb authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch '278-commissielid-sinds-negeert-voorgaande-lidmaatschappen' into 'master'

Display correct initial join date for consecutive committee memberships

Closes #278

See merge request !313
parents 39e94fc4 6513ef7a
......@@ -177,6 +177,17 @@ class CommitteeMembership(models.Model, metaclass=ModelTranslateMeta):
def initial_connected_membership(self):
""" Find the oldest membership directly connected to the current one"""
qs = CommitteeMembership.objects.filter(committee=self.committee,
if qs.count() >= 1: # should actually only be one; should be unique
return qs.first().initial_connected_membership
return self
def is_active(self):
"""Is this membership currently active"""
......@@ -22,13 +22,15 @@ def committee_detail(request, id):
memberships = (CommitteeMembership
for membership in memberships:
member = membership.member
member.chair = membership.chair
member.committee_since = membership.since
member.committee_since = membership.initial_connected_membership.since
members.append(member) # list comprehension would be more pythonic?
members.sort(key=lambda x: x.committee_since)
return render(request, 'activemembers/committee_detail.html',
{'committee': committee,
'members': members})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment