urlpatterns = [
path('top/', views.TopView.as_view(), name='stats_top'),
+ path('top/daily/', views.TopView.as_view(), name='stats_top'),
]
class TopView(PermissionRequiredMixin, TemplateView):
+ model = models.Visits
permission_required = 'stats.view_visits'
template_name = 'stats/top.html'
ctx = super().get_context_data(**kwargs)
form = forms.VisitsForm(self.request.GET)
assert form.is_valid()
- visits = models.Visits.objects.all()
+ visits = self.model.objects.all()
if form.cleaned_data['date_since']:
visits = visits.filter(date__gte=form.cleaned_data['date_since'].replace(day=1))
if form.cleaned_data['date_until']:
ctx['visits'] = visits
return ctx
+
+class DailyTopView(TopView):
+ model = models.DayVisits