diff options
Diffstat (limited to 'chimere/widgets.py')
-rw-r--r-- | chimere/widgets.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/chimere/widgets.py b/chimere/widgets.py index f8bb11b..bffd42f 100644 --- a/chimere/widgets.py +++ b/chimere/widgets.py @@ -600,6 +600,33 @@ class AreaWidget(forms.TextInput): values.append(value) return values + +class PolygonChooserWidget(forms.TextInput): + """ + Manage the edition of polygon on a map + """ + class Media: + css = { + "all": settings.MAP_CSS_URLS + + ["%schimere/css/forms.css" % settings.STATIC_URL] + } + js = settings.MAP_JS_URLS + list(settings.JQUERY_JS_URLS) + \ + ["%schimere/js/jquery.chimere.js" % settings.STATIC_URL] + + def render(self, name, value, attrs=None, area_name='', initialized=True): + # To be done + return super(PolygonChooserWidget, self).render(name, value, attrs) + + +class PolygonField(models.PolygonField): + ''' + Set the widget for the form field + ''' + def formfield(self, **keys): + defaults = {'widget': RouteChooserWidget} + keys.update(defaults) + return super(PolygonField, self).formfield(**keys) + RE_XAPI = re.compile( '(node|way)\[(.*=.*)\]\[bbox=' '(-*[0-9]*.[0-9]*,-*[0-9]*.[0-9]*,-*[0-9]*.[0-9]*,-*[0-9]*.[0-9]*)\]') @@ -754,3 +781,4 @@ from south.modelsinspector import add_introspection_rules add_introspection_rules([], ["^chimere\.widgets\.PointField"]) add_introspection_rules([], ["^chimere\.widgets\.SelectMultipleField"]) add_introspection_rules([], ["^chimere\.widgets\.RouteField"]) +add_introspection_rules([], ["^chimere\.widgets\.PolygonField"]) |