@permission_required('<STR_LIT>')<EOL>def dashboard(request):
end_time = now()<EOL>start_time = end_time - timedelta(days=<NUM_LIT:7>)<EOL>defaults = {'<STR_LIT:start>': start_time, '<STR_LIT:end>': end_time}<EOL>form = DashboardForm(data=request.GET or defaults)<EOL>if form.is_valid():<EOL><INDENT>start_time = form.cleaned_data['<STR_LIT:start>']<EOL>end_time = form.cleaned_data['<STR_LIT:end>']<EOL><DEDENT>try:<EOL><INDENT>obj = Visitor.objects.order_by('<STR_LIT>')[<NUM_LIT:0>]<EOL>track_start_time = obj.start_time<EOL><DEDENT>except (IndexError, Visitor.DoesNotExist):<EOL><INDENT>track_start_time = now()<EOL><DEDENT>warn_incomplete = (start_time < track_start_time)<EOL>user_stats = Visitor.objects.user_stats(start_time, end_time)<EOL>visitor_stats = Visitor.objects.stats(start_time, end_time)<EOL>if TRACK_PAGEVIEWS:<EOL><INDENT>pageview_stats = Pageview.objects.stats(start_time, end_time)<EOL><DEDENT>else:<EOL><INDENT>pageview_stats = None<EOL><DEDENT>context = {<EOL>'<STR_LIT>': form,<EOL>'<STR_LIT>': track_start_time,<EOL>'<STR_LIT>': warn_incomplete,<EOL>'<STR_LIT>': user_stats,<EOL>'<STR_LIT>': visitor_stats,<EOL>'<STR_LIT>': pageview_stats,<EOL>}<EOL>return render(request, '<STR_LIT>', context)<EOL>
Counts, aggregations and more!