Commit 8a623c3d91a92024b388364cf715c35b2529156d
1 parent
4f73094e
Exists in
master
and in
39 other branches
Adding cache to message display
Showing
2 changed files
with
8 additions
and
1 deletions
Show diff stats
src/super_archives/templates/superarchives/tags/display_message.html
1 | +{% load cache %} | |
2 | + | |
3 | +{% cache cache_timeout 'display_message' cache_key %} | |
1 | 4 | {% for message, class in messages %} |
2 | 5 | {% if class == 'reply' %} |
3 | 6 | <button class="btn btn-info btn-xs" onclick="$(this).next().toggle();">...</button> |
4 | 7 | <pre style="display: none; color: #707";>{% else %}<pre>{% endif %}{{ message }}</pre> |
5 | 8 | {% endfor %} |
9 | +{% endcache %} | ... | ... |
src/super_archives/templatetags/superarchives.py
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | import re |
3 | 3 | |
4 | 4 | from django import template |
5 | +from django.core.cache import cache | |
5 | 6 | |
6 | 7 | from html2text import html2text |
7 | 8 | |
... | ... | @@ -68,4 +69,6 @@ def display_message(email, thread): |
68 | 69 | else: |
69 | 70 | messages.append((join(block), 'normal')) |
70 | 71 | |
71 | - return {'messages': messages} | |
72 | + return {'messages': messages, | |
73 | + 'cache_key': email.pk, | |
74 | + 'cache_timeout': cache.default_timeout} | ... | ... |