gremmie@1: """ gremmie@1: Models for the member map application. gremmie@1: """ bgneal@266: import datetime gremmie@1: from django.db import models gremmie@1: from django.contrib.auth.models import User gremmie@1: bgneal@153: from core.markup import site_markup gremmie@1: bgneal@153: gremmie@1: class MapEntry(models.Model): gremmie@1: """Represents a user's entry on the map.""" gremmie@1: user = models.ForeignKey(User) gremmie@1: location = models.CharField(max_length=255) gremmie@1: lat = models.FloatField() gremmie@1: lon = models.FloatField() gremmie@1: message = models.TextField(blank=True) bgneal@266: html = models.TextField(blank=True) bgneal@266: date_updated = models.DateTimeField() gremmie@1: gremmie@1: def __unicode__(self): bgneal@266: return u'Map entry for %s' % self.user.username gremmie@1: gremmie@1: class Meta: gremmie@1: ordering = ('-date_updated', ) gremmie@1: verbose_name_plural = 'map entries' gremmie@1: bgneal@182: def save(self, *args, **kwargs): bgneal@266: self.html = site_markup(self.message) bgneal@266: self.date_updated = datetime.datetime.now() bgneal@182: super(MapEntry, self).save(*args, **kwargs) gremmie@1: