added a since parameter to the hanchan queries to return only hanchans since the give date and time
This commit is contained in:
@@ -13,7 +13,7 @@ class HanchanManager(models.Manager):
|
||||
"""
|
||||
use_for_related_fields = True
|
||||
|
||||
def confirmed_hanchans(self, user=None, until=None, **filter_args):
|
||||
def confirmed_hanchans(self, user=None, since=None, until=None, **filter_args):
|
||||
""" Return all valid and confirmed Hanchans.
|
||||
|
||||
:param user: Only return Hanchans where this user participated.
|
||||
@@ -24,11 +24,13 @@ class HanchanManager(models.Manager):
|
||||
return self.user_hanchans(user, confirmed=True, until=until,
|
||||
**filter_args)
|
||||
hanchans = self.filter(confirmed=True, **filter_args)
|
||||
if since:
|
||||
hanchans = hanchans.filter(start__gt=since)
|
||||
if until:
|
||||
hanchans = hanchans.filter(start__lte=until)
|
||||
return hanchans
|
||||
|
||||
def dan_hanchans(self, user, **filter_args):
|
||||
def dan_hanchans(self, user, since = None, **filter_args):
|
||||
""" Return all Hanchans where a specific user has participated and had
|
||||
gain dan points and make his gamestats availabale.
|
||||
|
||||
@@ -42,11 +44,13 @@ class HanchanManager(models.Manager):
|
||||
models.Q(player3=user, player3_dan_points__isnull=False) |
|
||||
models.Q(player4=user, player4_dan_points__isnull=False)
|
||||
).filter(confirmed=True, **filter_args)
|
||||
if since:
|
||||
queryset = queryset.filter(start__gt=since)
|
||||
queryset = queryset.select_related().order_by('-start')
|
||||
[hanchan.get_playerdata(user) for hanchan in queryset]
|
||||
return queryset
|
||||
|
||||
def kyu_hanchans(self, user, **filter_args):
|
||||
def kyu_hanchans(self, user, since = None, **filter_args):
|
||||
""" Return all Hanchans where a specific user has participated and had
|
||||
gain kyū points and make his gamestats availabale.
|
||||
|
||||
@@ -60,6 +64,8 @@ class HanchanManager(models.Manager):
|
||||
models.Q(player3=user, player3_kyu_points__isnull=False) |
|
||||
models.Q(player4=user, player4_kyu_points__isnull=False)
|
||||
).filter(confirmed=True, **filter_args)
|
||||
if since:
|
||||
queryset = queryset.filter(start__gt=since)
|
||||
queryset = queryset.select_related().order_by('-start')
|
||||
[hanchan.get_playerdata(user) for hanchan in queryset]
|
||||
return queryset
|
||||
|
||||
Reference in New Issue
Block a user