Home | Trees | Indices | Help |
---|
|
1 # Need a UserForm base class here 2 # from django.db import models 3 from django import forms 4 from django.forms import ModelForm 5 from django.contrib.auth.models import User 6 from django.utils.safestring import mark_safe 7 from django.contrib.gis.geos import fromstr 8 from django.conf import settings 9 from madrona.manipulators.manipulators import display_kml 103613 from madrona.features.models import PolygonFeature, PointFeature, LineFeature 14 model = self.form_instance.Meta.model 15 if issubclass(model, PolygonFeature): 16 type = 'polygon' 17 elif issubclass(model, LineFeature): 18 type = 'linestring' 19 else: 20 type = 'point' 21 kml = '' 22 if name == 'geometry_final': 23 output = super(ShapeInput, self).render(name, '', attrs) 24 else: 25 output = super(ShapeInput, self).render(name, value, attrs) 26 if value: 27 geo = fromstr(value) 28 geo.srid = settings.GEOMETRY_DB_SRID 29 kml = display_kml(geo) 30 return mark_safe(""" 31 <script class="%s" id="%s_kml" type="application/vnd.google-earth.kml+xml"> 32 %s 33 </script> 34 %s 35 """ % (type, name, kml, output))38 user = forms.ModelChoiceField(User.objects.all(),widget=forms.HiddenInput()) 394241 exclude = ('sharing_groups','content_type','object_id',)44 geometry_orig = forms.CharField(widget=ShapeInput()) 45 geometry_final = forms.CharField(widget=ShapeInput(), required=False) 46 manipulators = forms.CharField(widget=forms.HiddenInput(), required=False) 475549 exclude = ('sharing_groups','content_type','object_id',)5052 super(SpatialFeatureForm, self).__init__(*args, **kwargs) 53 self.fields['geometry_final'].widget.form_instance = self 54 self.fields['geometry_orig'].widget.form_instance = self
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Tue Oct 30 11:31:07 2012 | http://epydoc.sourceforge.net |