comparison 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
comparison
equal deleted inserted replaced
819:38db6ec61af3 820:9a0df7bd2409
1 """Models for the bandmap application.
2
3 """
4 import datetime
5
6 from django.db import models
7 from django.contrib.auth.models import User
8
9
10 class BandEntry(models.Model):
11 """Represents a band entry on the band map."""
12 name = models.CharField(max_length=128)
13 user = models.ForeignKey(User)
14 date_submitted = models.DateTimeField()
15 date_approved = models.DateTimeField(null=True, blank=True)
16 url = models.URLField(blank=True, max_length=200)
17 location = models.CharField(max_length=255)
18 lat = models.FloatField()
19 lon = models.FloatField()
20 note = models.CharField(max_length=255, blank=True)
21 is_active = models.BooleanField(default=True, db_index=True)
22 is_approved = models.BooleanField(default=False, db_index=True)
23
24 class Meta:
25 ordering = ['name']
26 verbose_name_plural = 'band map entries'
27
28 def __unicode__(self):
29 return u"BandMap entry for {}".format(self.name)
30
31 def save(self, *args, **kwargs):
32 if not self.pk and not self.date_submitted:
33 self.date_submitted = datetime.datetime.now()
34 super(BandEntry, self).save(*args, **kwargs)