'Get a queryset of memberships.
Args:
username (unicode, optional): The username to filter on.
course_ids (list of unicode, optional) Course IDs to filter on.
team_id (unicode, optional): The team_id to filter on.'

@classmethod
def get_memberships(cls, username=None, course_ids=None, team_id=None):

    queryset = cls.objects.all()
    if (username is not None):
        queryset = queryset.filter(user__username=username)
    if (course_ids is not None):
        queryset = queryset.filter(team__course_id__in=course_ids)
    if (team_id is not None):
        queryset = queryset.filter(team__team_id=team_id)
    return queryset
