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()
|
_, start_date, end_date = _get_dates()
|
||||||
if source is None:
|
if source is None:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
nb_max = settings.KHAGANAT_LOGS_MAX_DAYS - settings.KHAGANAT_LOGS_MIN_DAYS
|
||||||
lst = Entry.objects.filter(
|
lst = Entry.objects.filter(
|
||||||
hidden=False,
|
|
||||||
source=source,
|
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')
|
date=TruncDate('created')
|
||||||
).values('date').annotate(
|
).values('date').annotate(
|
||||||
nb=Count('date')
|
nb=Count('date')
|
||||||
).order_by('-date')
|
).order_by('-date')[:nb_max]
|
||||||
return [o['date'] for o in lst]
|
return [o['date'] for o in lst]
|
||||||
|
|
||||||
def get_source(self):
|
def get_source(self):
|
||||||
|
|
Loading…
Reference in a new issue