Mercurial > public > sg101
annotate bandmap/models.py @ 820:9a0df7bd2409
Bandmap application work in progress.
Model defined.
Map is displaying.
Initial display of add form.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 21 Sep 2014 18:20:29 -0500 |
parents | |
children | 2c4f28b1c12a |
rev | line source |
---|---|
bgneal@820 | 1 """Models for the bandmap application. |
bgneal@820 | 2 |
bgneal@820 | 3 """ |
bgneal@820 | 4 import datetime |
bgneal@820 | 5 |
bgneal@820 | 6 from django.db import models |
bgneal@820 | 7 from django.contrib.auth.models import User |
bgneal@820 | 8 |
bgneal@820 | 9 |
bgneal@820 | 10 class BandEntry(models.Model): |
bgneal@820 | 11 """Represents a band entry on the band map.""" |
bgneal@820 | 12 name = models.CharField(max_length=128) |
bgneal@820 | 13 user = models.ForeignKey(User) |
bgneal@820 | 14 date_submitted = models.DateTimeField() |
bgneal@820 | 15 date_approved = models.DateTimeField(null=True, blank=True) |
bgneal@820 | 16 url = models.URLField(blank=True, max_length=200) |
bgneal@820 | 17 location = models.CharField(max_length=255) |
bgneal@820 | 18 lat = models.FloatField() |
bgneal@820 | 19 lon = models.FloatField() |
bgneal@820 | 20 note = models.CharField(max_length=255, blank=True) |
bgneal@820 | 21 is_active = models.BooleanField(default=True, db_index=True) |
bgneal@820 | 22 is_approved = models.BooleanField(default=False, db_index=True) |
bgneal@820 | 23 |
bgneal@820 | 24 class Meta: |
bgneal@820 | 25 ordering = ['name'] |
bgneal@820 | 26 verbose_name_plural = 'band map entries' |
bgneal@820 | 27 |
bgneal@820 | 28 def __unicode__(self): |
bgneal@820 | 29 return u"BandMap entry for {}".format(self.name) |
bgneal@820 | 30 |
bgneal@820 | 31 def save(self, *args, **kwargs): |
bgneal@820 | 32 if not self.pk and not self.date_submitted: |
bgneal@820 | 33 self.date_submitted = datetime.datetime.now() |
bgneal@820 | 34 super(BandEntry, self).save(*args, **kwargs) |