Mercurial > public > sg101
diff bandmap/models.py @ 843:09ed84a7394c
For issue #76, store pre-rendered HTML for each band map entry.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 13 Oct 2014 16:48:43 -0500 |
parents | 2c4f28b1c12a |
children |
line wrap: on
line diff
--- a/bandmap/models.py Sun Oct 12 14:59:43 2014 -0500 +++ b/bandmap/models.py Mon Oct 13 16:48:43 2014 -0500 @@ -5,6 +5,7 @@ from django.db import models from django.contrib.auth.models import User +from django.template.loader import render_to_string class BandEntryManager(models.Manager): @@ -25,6 +26,7 @@ note = models.CharField(max_length=255, blank=True) is_active = models.BooleanField(default=True, db_index=True) is_approved = models.BooleanField(default=False, db_index=True) + html = models.TextField(blank=True) objects = BandEntryManager() @@ -38,4 +40,6 @@ def save(self, *args, **kwargs): if not self.pk and not self.date_submitted: self.date_submitted = datetime.datetime.now() + html = render_to_string('bandmap/balloon.html', {'band': self}) + self.html = html.strip().replace('\n', '') super(BandEntry, self).save(*args, **kwargs)