|
6 | 6 |
|
7 | 7 | from django.db import models |
8 | 8 | from django.core import checks |
| 9 | +from django.core.cache import caches |
9 | 10 | from django.core.exceptions import ValidationError |
10 | 11 | from django.urls import reverse as urlreverse |
11 | 12 | from django.core.validators import URLValidator |
@@ -159,11 +160,12 @@ def get_file_name(self): |
159 | 160 | def revisions(self): |
160 | 161 | revisions = [] |
161 | 162 | doc = self.doc if isinstance(self, DocHistory) else self |
162 | | - for e in doc.docevent_set.filter(type='new_revision').distinct().order_by("time", "id"): |
| 163 | + for e in doc.docevent_set.filter(type='new_revision').distinct(): |
163 | 164 | if e.rev and not e.rev in revisions: |
164 | 165 | revisions.append(e.rev) |
165 | 166 | if not doc.rev in revisions: |
166 | 167 | revisions.append(doc.rev) |
| 168 | + revisions.sort() |
167 | 169 | return revisions |
168 | 170 |
|
169 | 171 | def href(self, meeting=None): |
@@ -435,11 +437,21 @@ def htmlized(self): |
435 | 437 | return text |
436 | 438 | if not name.endswith('.txt'): |
437 | 439 | return None |
438 | | - html = None |
| 440 | + html = "" |
439 | 441 | if text: |
440 | | - # The path here has to match the urlpattern for htmlized documents |
441 | | - html = markup(text, path=settings.HTMLIZER_URL_PREFIX) |
442 | | - #html = re.sub(r'<hr[^>]*/>','', html) |
| 442 | + cache = caches['htmlized'] |
| 443 | + key = name.split('.')[0] |
| 444 | + html = cache.get(key) |
| 445 | + if not html: |
| 446 | + debug.say('cache miss for %s' % key) |
| 447 | + # The path here has to match the urlpattern for htmlized |
| 448 | + # documents in order to produce correct intra-document links |
| 449 | + html = markup(text, path=settings.HTMLIZER_URL_PREFIX) |
| 450 | + if html: |
| 451 | + debug.say('cache set for %s' % key) |
| 452 | + cache.set(key, html, settings.HTMLIZER_CACHE_TIME) |
| 453 | + else: |
| 454 | + debug.say('cache hit for %s' % key) |
443 | 455 | return html |
444 | 456 |
|
445 | 457 | class Meta: |
|
0 commit comments