Allow admins to see more days from sources

This commit is contained in:
Rodolphe Breard 2018-06-09 19:02:47 +02:00
parent 9f490febdf
commit 49c0cbf16e

View file

@ -106,15 +106,21 @@ class EntriesView(generic.ListView):
_, start_date, end_date = _get_dates()
if source is None:
return []
nb_max = settings.KHAGANAT_LOGS_MAX_DAYS - settings.KHAGANAT_LOGS_MIN_DAYS
lst = Entry.objects.filter(
hidden=False,
source=source,
created__range=(start_date, end_date)
).annotate(
)
if not self.request.user.is_staff:
lst = lst.filter(
hidden=False,
created__range=(start_date, end_date)
)
lst = lst.annotate(
date=TruncDate('created')
).values('date').annotate(
nb=Count('date')
).order_by('-date')
).order_by('-date')[:nb_max]
return [o['date'] for o in lst]
def get_source(self):