Remove code unneded since 2015.
authorRadek Czajka <rczajka@rczajka.pl>
Wed, 12 Jun 2024 08:31:50 +0000 (10:31 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Wed, 12 Jun 2024 08:31:50 +0000 (10:31 +0200)
src/reporting/templatetags/reporting_stats.py

index bca84f1..c4ce84c 100644 (file)
@@ -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()