From: Radek Czajka Date: Mon, 14 Jun 2021 09:49:22 +0000 (+0200) Subject: Daily stats view. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/03e12954f295662d894bc0efa65054bfd63c42b6 Daily stats view. --- diff --git a/src/stats/admin.py b/src/stats/admin.py index 11dfe7e89..9e5ab4744 100644 --- a/src/stats/admin.py +++ b/src/stats/admin.py @@ -10,3 +10,4 @@ class VisitsAdmin(admin.ModelAdmin): admin.site.register(models.Visits, VisitsAdmin) +admin.site.register(models.DayVisits, VisitsAdmin) diff --git a/src/stats/urls.py b/src/stats/urls.py index 80d261178..1b770a8c8 100644 --- a/src/stats/urls.py +++ b/src/stats/urls.py @@ -4,4 +4,5 @@ from . import views urlpatterns = [ path('top/', views.TopView.as_view(), name='stats_top'), + path('top/daily/', views.TopView.as_view(), name='stats_top'), ] diff --git a/src/stats/views.py b/src/stats/views.py index 4ff85f494..93cda3797 100644 --- a/src/stats/views.py +++ b/src/stats/views.py @@ -6,6 +6,7 @@ from . import models class TopView(PermissionRequiredMixin, TemplateView): + model = models.Visits permission_required = 'stats.view_visits' template_name = 'stats/top.html' @@ -13,7 +14,7 @@ class TopView(PermissionRequiredMixin, TemplateView): 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']: @@ -27,3 +28,6 @@ class TopView(PermissionRequiredMixin, TemplateView): ctx['visits'] = visits return ctx + +class DailyTopView(TopView): + model = models.DayVisits