From 581ffb970c3593c925dd4256eb4276c5b9625f92 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 12 Jun 2024 10:31:50 +0200 Subject: [PATCH] Remove code unneded since 2015. --- src/reporting/templatetags/reporting_stats.py | 41 +++---------------- 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/src/reporting/templatetags/reporting_stats.py b/src/reporting/templatetags/reporting_stats.py index bca84f1d3..c4ce84cf4 100644 --- a/src/reporting/templatetags/reporting_stats.py +++ b/src/reporting/templatetags/reporting_stats.py @@ -1,7 +1,6 @@ # This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # -from functools import wraps from django import template from catalogue.models import Book @@ -9,52 +8,22 @@ from catalogue.models import Book register = template.Library() -class StatsNode(template.Node): - def __init__(self, value, varname=None): - self.value = value - self.varname = varname - - def render(self, context): - if self.varname: - context[self.varname] = self.value - return '' - else: - return str(self.value) - - -def register_counter(f): - """Turns a simple counting function into a registered counter tag. - - You can run a counter tag as a simple {% tag_name %} tag, or - as {% tag_name var_name %} to store the result in a variable. - - """ - @wraps(f) - def wrapped(parser, token): - try: - tag_name, args = token.contents.split(None, 1) - except ValueError: - args = None - return StatsNode(f(), args) - - return register.tag(wrapped) - - -@register_counter +@register.simple_tag def count_books_all(): return Book.objects.all().count() -@register_counter +@register.simple_tag def count_books(): + print('count', Book.objects.filter(children=None).count()) return Book.objects.filter(children=None).count() -@register_counter +@register.simple_tag def count_books_parent(): return Book.objects.exclude(children=None).count() -@register_counter +@register.simple_tag def count_books_root(): return Book.objects.filter(parent=None).count() -- 2.20.1