diff --git a/www/conservancy/apps/worldmap/models.py b/www/conservancy/apps/worldmap/models.py new file mode 100644 index 0000000000000000000000000000000000000000..16643a6f43157ccd9412ea4c08bf997edadd07d9 --- /dev/null +++ b/www/conservancy/apps/worldmap/models.py @@ -0,0 +1,28 @@ +from django.db import models + +class EarthLocation(models.Model): + """Represents latitude and longitude, with a label""" + + label = models.CharField(max_length=300, unique=True) + latitude = models.DecimalField(max_digits=9, decimal_places=6) + longitude = models.DecimalField(max_digits=9, decimal_places=6) + + date_created = models.DateTimeField(auto_now_add=True) + date_last_modified = models.DateTimeField(auto_now=True) + + class Meta: + unique_together = (("latitude", "longitude"),) + + def __unicode__(self): + return self.label + + def google_maps_link(self): + return ("http://maps.google.com/maps?ll=%s,%s&z=15" + % (self.latitude, self.longitude)) + + default_map_link = google_maps_link + + def html_map_link(self): # for Admin, fixme: fix_ampersands + return 'map link' % self.default_map_link() + html_map_link.allow_tags = True +