Unverified Commit afa9ea75 authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Clarify some docs

parent c0e270d7
......@@ -33,6 +33,7 @@ class ActiveMemberManager(MemberManager):
"""Get all active members, i.e. who have a committee membership"""
def get_queryset(self):
"""Select all committee members"""
active_memberships = (CommitteeMembership
......@@ -46,6 +47,9 @@ class CurrentMemberManager(MemberManager):
"""Get all members with an active membership"""
def get_queryset(self):
Select all members who have a current membership
return (super().get_queryset()
.filter(Q(membership__until__isnull=True) |
......@@ -53,6 +57,18 @@ class CurrentMemberManager(MemberManager):
def with_birthdays_in_range(self, from_date, to_date):
Select all who are currently a Thalia member and have a
birthday within the specified range
:param from_date: the start of the range (inclusive)
:param to_date: the end of the range (inclusive)
:paramtype from_date: datetime
:paramtype to_date: datetime
:return: the filtered queryset
:rtype: Queryset
queryset = (self.get_queryset()
......@@ -91,6 +107,12 @@ class Member(User):
def current_membership(self):
The currently active membership of the user. None if not active.
:return: the currently active membership or None
:rtype: Membership or None
membership = self.latest_membership
if membership and not membership.is_active():
return None
......@@ -98,20 +120,24 @@ class Member(User):
def latest_membership(self):
"""Get the most recent membership of this user"""
if not self.membership_set.exists():
return None
return self.membership_set.latest('since')
def earliest_membership(self):
"""Get the earliest membership of this user"""
if not self.membership_set.exists():
return None
return self.membership_set.earliest('since')
def has_been_member(self):
"""Has this user ever been a member?"""
return self.membership_set.filter(type='member').count() > 0
def has_been_honorary_member(self):
"""Has this user ever been an honorary member?"""
return self.membership_set.filter(type='honorary').count() > 0
def has_active_membership(self):
......@@ -128,12 +154,20 @@ class Member(User):
def all_with_membership(cls, membership_type):
Get all users who have a specific membership.
:param membership_type: The membership to select by
:return: List of users
:rtype: [Member]
return [x for x in cls.objects.all()
if x.current_membership and
x.current_membership.type == membership_type]
def can_attend_events(self):
"""May this user attend events"""
if not self.profile:
return False
......@@ -142,6 +176,7 @@ class Member(User):
self.current_membership is not None)
def get_committees(self):
"""Get the committees this user is a member of"""
return Committee.unfiltered_objects.filter(
Q(committeemembership__member=self) &
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