Commit 9439e67fc84a0ed8f8d4006535b1ab33d0318f11

Authored by janek37
1 parent fbbcf7a1

wyświetlanie nazwy użytkownika i poprawka do paginacji

common/decorators.py
... ... @@ -73,36 +73,4 @@ def render(template=None, mimetype=None):
73 73 RequestContext(request), mimetype=mimetype)
74 74 return output
75 75 return renderer
76   - return decorator
77   -
78   -# TODO wywalić
79   -def simple_tag(register, takes_context=False):
80   - def decorator(func):
81   - params, xx, xxx, defaults = getargspec(func)
82   - if takes_context:
83   - if params[0] == 'context':
84   - params = params[1:]
85   - else:
86   - raise TemplateSyntaxError("Any tag function decorated with takes_context=True must have a first argument of 'context'")
87   -
88   - class SimpleNode(Node):
89   - def __init__(self, vars_to_resolve):
90   - self.vars_to_resolve = map(Variable, vars_to_resolve)
91   -
92   - def render(self, context):
93   - resolved_vars = [var.resolve(context) for var in self.vars_to_resolve]
94   - if takes_context:
95   - args = [context] + resolved_vars
96   - else:
97   - args = resolved_vars
98   - try:
99   - return func(*args)
100   - except Exception as e:
101   - raise
102   - return type(e).__name__+': '+str(e)
103   -
104   - compile_func = curry(generic_tag_compiler, params, defaults, getattr(func, "_decorated_function", func).__name__, SimpleNode)
105   - compile_func.__doc__ = func.__doc__
106   - register.tag(getattr(func, "_decorated_function", func).__name__, compile_func)
107   - return func
108   - return decorator
  76 + return decorator
109 77 \ No newline at end of file
... ...
paginer/templatetags/pagination_tags.py
... ... @@ -4,7 +4,6 @@ from django import template
4 4 #from django.http import Http404
5 5 from django.core.paginator import Paginator, InvalidPage
6 6 from django.conf import settings
7   -from common.decorators import simple_tag
8 7 from paginer import types
9 8  
10 9 register = template.Library()
... ... @@ -13,7 +12,7 @@ DEFAULT_PAGINATION = getattr(settings, 'PAGINER_DEFAULT_PAGINATION', 10)
13 12 DEFAULT_WINDOW = getattr(settings, 'PAGINER_DEFAULT_WINDOW', 4)
14 13 DEFAULT_ORPHANS = getattr(settings, 'PAGINER_DEFAULT_ORPHANS', 0)
15 14  
16   -@simple_tag(register, takes_context=True)
  15 +@register.simple_tag(takes_context=True)
17 16 def autopaginate(context, id, page=1, ajax=False,
18 17 paginate_by=DEFAULT_PAGINATION, orphans=DEFAULT_ORPHANS):
19 18 list_type = context['paginer'][id]['type']
... ...
templates/base.html
... ... @@ -43,7 +43,7 @@
43 43 {# if debug #}
44 44 <span id="show-debug">debug</span>
45 45 {# endif #}
46   - <strong>{% filter force_escape %}{% firstof user.first_name user.username %}{% endfilter %}</strong>
  46 + <strong>{% filter force_escape %}{{ user.username }}{% endfilter %}</strong>
47 47 {% block userlinks %}
48 48 <a href="{% url 'settings' %}">
49 49 Ustawienia</a> /
... ...