Mercurial > public > sg101
comparison gpp/membermap/models.py @ 153:13d052fbe4f1
Fixing #28, cosmetic issues with member map. Also fixed a bug involving the smiley and markdown interactions. Single quotes were getting HTML REMOVED by markdown.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 19 Dec 2009 19:34:16 +0000 |
parents | dbd703f7d63a |
children | 5c889b587416 |
comparison
equal
deleted
inserted
replaced
152:bc657962941e | 153:13d052fbe4f1 |
---|---|
5 from django.contrib.auth.models import User | 5 from django.contrib.auth.models import User |
6 from django.template.loader import render_to_string | 6 from django.template.loader import render_to_string |
7 from django.template.defaultfilters import escapejs | 7 from django.template.defaultfilters import escapejs |
8 import django.utils.simplejson as json | 8 import django.utils.simplejson as json |
9 | 9 |
10 from core.markup import site_markup | |
10 | 11 |
11 # Create your models here. | 12 |
12 class MapEntry(models.Model): | 13 class MapEntry(models.Model): |
13 """Represents a user's entry on the map.""" | 14 """Represents a user's entry on the map.""" |
14 user = models.ForeignKey(User) | 15 user = models.ForeignKey(User) |
15 location = models.CharField(max_length=255) | 16 location = models.CharField(max_length=255) |
16 lat = models.FloatField() | 17 lat = models.FloatField() |
25 class Meta: | 26 class Meta: |
26 ordering = ('-date_updated', ) | 27 ordering = ('-date_updated', ) |
27 verbose_name_plural = 'map entries' | 28 verbose_name_plural = 'map entries' |
28 | 29 |
29 def save(self, force_insert=False, force_update=False): | 30 def save(self, force_insert=False, force_update=False): |
30 msg = render_to_string('membermap/markdown.html', {'entry': self}).strip() | 31 msg = render_to_string('membermap/markdown.html', { |
32 'user': self.user, | |
33 'msg': site_markup(self.message)}).strip() | |
34 | |
31 self.json = json.dumps({'name': self.user.username, | 35 self.json = json.dumps({'name': self.user.username, |
32 'lat': '%10.6f' % self.lat, | 36 'lat': '%10.6f' % self.lat, |
33 'lon': '%10.6f' % self.lon, | 37 'lon': '%10.6f' % self.lon, |
34 'message': msg, | 38 'message': msg, |
35 }) | 39 }) |
36 super(MapEntry, self).save(force_insert, force_update) | 40 super(MapEntry, self).save(force_insert, force_update) |
37 | 41 |
38 # vim: ts=4 sw=4 |