We planned to upgrade GitLab and Mattermost to the latest version this Friday morning. Expect some downtime!

Commit a868eb8e authored by Joost Rijneveld's avatar Joost Rijneveld

members: properly filter ex members;

The ex-members tab now only displays:
- legacy users that have no memberships at all
- users that have had a 'member' or 'honorary' membership
  and do not currently have an active membership
parent d898b530
......@@ -46,9 +46,11 @@ def index(request):
elif query_filter == 'old':
members_query &= Q(starting_year__lt=start_year)
elif query_filter == 'ex':
# Filter out all current members and current honorary members
memberships_query &= Q(type='member') | Q(type='honorary')
memberships = models.Membership.objects.filter(memberships_query)
members_query &= ~Q(user__in=memberships.values('user'))
memberships_query = Q(type='member') & Q(until__lte=datetime.now())
# Members_query contains users that are not currently (honorary)member
elif query_filter == 'honor':
memberships_query = Q(until__gt=datetime.now().date()) | Q(until=None)
memberships_query &= Q(type='honorary')
......@@ -60,8 +62,17 @@ def index(request):
Q(user__last_name__icontains=key) |
memberships = models.Membership.objects.filter(memberships_query)
members_query &= Q(user__in=memberships.values('user'))
if query_filter == 'ex':
memberships_query = Q(type='member') | Q(type='honorary')
memberships = models.Membership.objects.filter(memberships_query)
all_memberships = models.Membership.objects.all()
# Only keep members that were once members, or are legacy users that
# do not have any memberships at all
members_query &= (Q(user__in=memberships.values('user')) |
memberships = models.Membership.objects.filter(memberships_query)
members_query &= Q(user__in=memberships.values('user'))
members = models.Member.objects.filter(members_query).order_by(
'-starting_year', 'user__first_name')
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