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

Order cancellations by cancellation date

Closes #616
parent ba1aa79f
......@@ -151,29 +151,36 @@ class Event(models.Model, metaclass=ModelTranslateMeta):
return self.registrationinformationfield_set.count() > 0
def reached_participants_limit(self):
"""Is this event up to capacity?"""
return (self.max_participants is not None and
self.max_participants <= self.registration_set.filter(
date_cancelled=None).count())
@property
def registrations(self):
"""Queryset with all non-cancelled registrations"""
return self.registration_set.filter(date_cancelled=None)
@property
def participants(self):
"""Return the active participants"""
if self.max_participants is not None:
return self.registrations.order_by('date')[:self.max_participants]
return self.registrations.order_by('date')
@property
def queue(self):
"""Return the waiting queue"""
if self.max_participants is not None:
return self.registrations.order_by('date')[self.max_participants:]
return []
@property
def cancellations(self):
return self.registration_set.exclude(date_cancelled=None)
"""Return a queryset with the cancelled events"""
return (self.registration_set
.exclude(date_cancelled=None)
.order_by('date_cancelled'))
@property
def registration_allowed(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