summaryrefslogtreecommitdiff
path: root/chimere/main/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/main/widgets.py')
-rw-r--r--chimere/main/widgets.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/chimere/main/widgets.py b/chimere/main/widgets.py
index 44e8ac8..2653c19 100644
--- a/chimere/main/widgets.py
+++ b/chimere/main/widgets.py
@@ -38,7 +38,7 @@ class ManyToManyField_NoSyncdb(models.ManyToManyField):
super(ManyToManyField_NoSyncdb, self).__init__(*args, **kwargs)
self.creates_table = False
-def getMapJS():
+def getMapJS(area_name=''):
'''Variable initialization for drawing the map
'''
# projection, center and bounds definitions
@@ -52,6 +52,9 @@ def getMapJS():
js += u"var media_path = '%s';\n" % settings.MEDIA_URL
js += u"var map_layer = %s;\n" % settings.MAP_LAYER
js += u"var restricted_extent;\n"
+
+ if area_name:
+ js += u"var area_name='%s';\n" % area_name
if settings.RESTRICTED_EXTENT:
restricted_extent_str = [str(coord) \
for coord in settings.RESTRICTED_EXTENT]
@@ -81,7 +84,7 @@ class PointChooserWidget(forms.TextInput):
js = URL_OSM_JS + ["%sedit_map.js" % settings.MEDIA_URL,
"%sbase.js" % settings.MEDIA_URL,]
- def render(self, name, value, attrs=None):
+ def render(self, name, value, attrs=None, area_name=''):
'''
Render a map and latitude, longitude information field
'''
@@ -99,7 +102,7 @@ class PointChooserWidget(forms.TextInput):
value = None
else:
value = None
- tpl = getMapJS()
+ tpl = getMapJS(area_name)
tpl += u'<script src="%sedit_map.js"></script>\n' % settings.MEDIA_URL
tpl += u"""<div id='map_edit'></div>
<div id='live_lonlat'>
@@ -112,8 +115,8 @@ value='%f'/></p>
</div>
<input type='hidden' name='%s' id='id_%s' value="%s"/>
""" % (_("Latitude"), value_y, _("Longitude"), value_x, name, name, val)
- tpl += """<script type='text/javascript'><!--
-init();"""
+ tpl += "<script type='text/javascript'><!--\n"
+ tpl += "init();\n"
if value:
tpl += '''var mylonlat = new OpenLayers.LonLat(%f,%f);
putMarker(mylonlat.transform(epsg_display_projection,
@@ -149,11 +152,11 @@ class RouteChooserWidget(forms.TextInput):
js = ["%sedit_route_map.js" % settings.MEDIA_URL,
"%sbase.js" % settings.MEDIA_URL,] + URL_OSM_JS
- def render(self, name, value, attrs=None):
+ def render(self, name, value, attrs=None, area_name=''):
'''
Render a map and latitude, longitude information field
'''
- tpl = getMapJS()
+ tpl = getMapJS(area_name)
help_create = ''
if not value:
help_create = """<h3>%s</h3>
@@ -198,8 +201,8 @@ onclick='toggleDrawOff();'>%s</div>
<hr class='spacer'/>
<input type='hidden' name='%s' id='id_%s' value="%s"/>
""" % (style, help_modify, name, name, value)
- tpl += """<script type='text/javascript'><!--
-init();"""
+ tpl += "<script type='text/javascript'><!--\n"
+ tpl += "init();\n"
if value:
val = value
if type(value) == unicode: