mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 01:29:16 +02:00
See #248: can now filter on invitation status and delete invitations
This commit is contained in:
parent
7b0148a533
commit
7cfa61292a
8 changed files with 67 additions and 20 deletions
|
@ -157,12 +157,13 @@ def generate_code(length=10):
|
|||
|
||||
|
||||
class InvitationQuerySet(models.QuerySet):
|
||||
def open(self):
|
||||
def open(self, include=True):
|
||||
now = timezone.now()
|
||||
qs = self.annotate(_users=models.Count("users"))
|
||||
qs = qs.filter(_users=0)
|
||||
qs = qs.exclude(expiration_date__lte=now)
|
||||
return qs
|
||||
query = models.Q(_users=0, expiration_date__gt=now)
|
||||
if include:
|
||||
return qs.filter(query)
|
||||
return qs.exclude(query)
|
||||
|
||||
|
||||
class Invitation(models.Model):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue