Allow admins to see more days from sources
This commit is contained in:
parent
9f490febdf
commit
49c0cbf16e
1 changed files with 10 additions and 4 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue