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

Get active members through a manager

parent cf572a45
......@@ -179,7 +179,7 @@ class Registration(models.Model):
blank=True,
null=True,
limit_choices_to=(Q(user__membership__until__isnull=True) |
Q(user__membership__until__gt=timezone.now()))
Q(user__membership__until__gt=timezone.now().date()))
)
name = models.CharField(
......
from django.utils import timezone
from django.db import models
from django.db.models import Q
from django.core import validators
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
......@@ -10,9 +11,20 @@ from localflavor.generic.models import IBANField
from utils.validators import validate_file_extension
class ActiveMemberManager(models.Manager):
"""Get all active members"""
def get_queryset(self):
return (super().get_queryset()
.filter(Q(user__membership__until__isnull=True) |
Q(user__membership__until__gt=timezone.now().date())))
class Member(models.Model):
"""This class describes a member"""
objects = models.Manager()
active_members = ActiveMemberManager()
# No longer yearly membership as a type, use expiration date instead.
PROGRAMME_CHOICES = (
('computingscience', _('Computing Science')),
......
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