diff --git a/membershipworks/models.py b/membershipworks/models.py index 6cd0403..ae4588d 100644 --- a/membershipworks/models.py +++ b/membershipworks/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.db.models import Q class Flag(models.Model): @@ -134,6 +135,14 @@ class Member(models.Model): db_table = "members" ordering = ("first_name", "last_name") + @classmethod + def with_is_active(cls): + return cls.objects.annotate( + is_active=Q(flags__name="Account On Hold", flags__type="label") + | Q(flags__name="CMS Membership on hold", flags__type="level") + | Q(flags__name="Former Members", flags__type="folder") + ) + class MemberFlag(models.Model): member = models.ForeignKey(Member, on_delete=models.PROTECT, db_column="uid")