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