Unverified Commit e7460386 authored by Joost Rijneveld's avatar Joost Rijneveld
Browse files

committees: combine adjacent memberships

parent 4140eac1
......@@ -249,9 +249,11 @@ class CommitteeMembership(models.Model, metaclass=ModelTranslateMeta):
@property
def initial_connected_membership(self):
""" Find the oldest membership directly connected to the current one"""
qs = CommitteeMembership.objects.filter(committee=self.committee,
qs = CommitteeMembership.objects.filter(
committee=self.committee,
member=self.member,
until=self.since)
until__lte=self.since,
until__gte=self.since - datetime.timedelta(days=1))
if qs.count() >= 1: # should actually only be one; should be unique
return qs.first().initial_connected_membership
else:
......
Markdown is supported
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