summaryrefslogtreecommitdiff
path: root/chimere/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/models.py')
-rw-r--r--chimere/models.py35
1 files changed, 29 insertions, 6 deletions
diff --git a/chimere/models.py b/chimere/models.py
index c393cba..a059b35 100644
--- a/chimere/models.py
+++ b/chimere/models.py
@@ -360,6 +360,13 @@ class Importer(models.Model):
def display_categories(self):
return u"\n".join([cat.name for cat in self.categories.all()])
+STATUS = (('S', _(u'Submited')),
+ ('A', _(u'Available')),
+ ('M', _(u'Modified')),
+ ('D', _(u'Disabled')),
+ ('I', _(u'Imported')))
+STATUS_DCT = dict(STATUS)
+
class GeographicItem(models.Model):
name = models.CharField(_(u"Name"), max_length=150)
categories = SelectMultipleField(SubCategory)
@@ -371,12 +378,6 @@ class GeographicItem(models.Model):
null=True)
submiter_comment = models.TextField(_(u"Submitter comment"), max_length=200,
blank=True, null=True)
- STATUS = (('S', _(u'Submited')),
- ('A', _(u'Available')),
- ('M', _(u'Modified')),
- ('D', _(u'Disabled')),
- ('I', _(u'Imported')))
- STATUS_DCT = dict(STATUS)
status = models.CharField(_(u"Status"), max_length=1, choices=STATUS)
import_key = models.CharField(_(u"Import key"), max_length=200,
blank=True, null=True)
@@ -1166,6 +1167,28 @@ def getDateCondition():
date_condition += "%(alias)s.end_date >='" + now + "')) "
return date_condition
+class AggregatedRoute(models.Model):
+ '''
+ Database view for aggregated routes
+ '''
+ route = models.MultiLineStringField()
+ subcategory = models.ForeignKey(SubCategory)
+ status = models.CharField(_(u"Status"), max_length=1, choices=STATUS)
+ class Meta:
+ managed = False
+ db_table = 'chimere_aggregated_routes'
+
+ def getGeoJSON(self, color="#000"):
+ '''Return a GeoJSON string
+ '''
+ if '#' not in color:
+ color = '#' + color
+ attributes = {'id':self.id, 'name':json.dumps(u'Aggregated route'),
+ 'color':color, 'geometry':self.route.geojson,}
+ return u'{"type":"Feature", "geometry":%(geometry)s, '\
+ u'"properties":{"pk": %(id)d, "name": %(name)s, '\
+ u'"color":"%(color)s"}}' % attributes
+
class SimplePoint:
"""
Point in the map (not in the database)