Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Need a UserForm base class here # from django.db import models
from madrona.features.models import PolygonFeature, PointFeature, LineFeature model = self.form_instance.Meta.model if issubclass(model, PolygonFeature): type = 'polygon' elif issubclass(model, LineFeature): type = 'linestring' else: type = 'point' kml = '' if name == 'geometry_final': output = super(ShapeInput, self).render(name, '', attrs) else: output = super(ShapeInput, self).render(name, value, attrs) if value: geo = fromstr(value) geo.srid = settings.GEOMETRY_DB_SRID kml = display_kml(geo) return mark_safe(""" <script class="%s" id="%s_kml" type="application/vnd.google-earth.kml+xml"> %s </script> %s """ % (type, name, kml, output))
super(SpatialFeatureForm, self).__init__(*args, **kwargs) self.fields['geometry_final'].widget.form_instance = self self.fields['geometry_orig'].widget.form_instance = self |