Add is_active
annotatation helper to membershipworks.Member
This commit is contained in:
parent
fe624c421f
commit
245e946fc2
@ -1,4 +1,5 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.db.models import Q
|
||||||
|
|
||||||
|
|
||||||
class Flag(models.Model):
|
class Flag(models.Model):
|
||||||
@ -134,6 +135,14 @@ class Member(models.Model):
|
|||||||
db_table = "members"
|
db_table = "members"
|
||||||
ordering = ("first_name", "last_name")
|
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):
|
class MemberFlag(models.Model):
|
||||||
member = models.ForeignKey(Member, on_delete=models.PROTECT, db_column="uid")
|
member = models.ForeignKey(Member, on_delete=models.PROTECT, db_column="uid")
|
||||||
|
Loading…
Reference in New Issue
Block a user